bool CD3DVertexShader::Create(const std::wstring& vertexFile, D3D11_INPUT_ELEMENT_DESC* vertexLayout, unsigned int vertexLayoutSize) { ReleaseShader(); ID3D11Device* pDevice = g_Windowing.Get3D11Device(); if (!pDevice) return false; if (FAILED(D3DReadFileToBlob(vertexFile.c_str(), &m_VSBuffer))) { CLog::Log(LOGERROR, __FUNCTION__ " - Failed to load the vertex shader."); return false; } if (vertexLayout && vertexLayoutSize) { m_vertexLayoutSize = vertexLayoutSize; m_vertexLayout = new D3D11_INPUT_ELEMENT_DESC[vertexLayoutSize]; for (unsigned int i = 0; i < vertexLayoutSize; ++i) m_vertexLayout[i] = vertexLayout[i]; } else return false; m_inited = CreateInternal(); if (m_inited) g_Windowing.Register(this); return m_inited; }
BufferTextureData* BufferTextureData::CreateForYCbCr(ClientIPCAllocator* aAllocator, gfx::IntSize aYSize, gfx::IntSize aCbCrSize, StereoMode aStereoMode, TextureFlags aTextureFlags) { uint32_t bufSize = ImageDataSerializer::ComputeYCbCrBufferSize(aYSize, aCbCrSize); if (bufSize == 0) { return nullptr; } uint32_t yOffset; uint32_t cbOffset; uint32_t crOffset; ImageDataSerializer::ComputeYCbCrOffsets(aYSize.width, aYSize.height, aCbCrSize.width, aCbCrSize.height, yOffset, cbOffset, crOffset); YCbCrDescriptor descriptor = YCbCrDescriptor(aYSize, aCbCrSize, yOffset, cbOffset, crOffset, aStereoMode); return CreateInternal(aAllocator, descriptor, gfx::BackendType::NONE, bufSize, aTextureFlags); }
BufferTextureData* BufferTextureData::CreateForYCbCr(KnowsCompositor* aAllocator, gfx::IntSize aYSize, gfx::IntSize aCbCrSize, StereoMode aStereoMode, TextureFlags aTextureFlags) { uint32_t bufSize = ImageDataSerializer::ComputeYCbCrBufferSize(aYSize, aCbCrSize); if (bufSize == 0) { return nullptr; } uint32_t yOffset; uint32_t cbOffset; uint32_t crOffset; ImageDataSerializer::ComputeYCbCrOffsets(aYSize.width, aYSize.height, aCbCrSize.width, aCbCrSize.height, yOffset, cbOffset, crOffset); bool hasIntermediateBuffer = aAllocator ? ComputeHasIntermediateBuffer(gfx::SurfaceFormat::YUV, aAllocator->GetCompositorBackendType()) : true; YCbCrDescriptor descriptor = YCbCrDescriptor(aYSize, aCbCrSize, yOffset, cbOffset, crOffset, aStereoMode, hasIntermediateBuffer); return CreateInternal(aAllocator ? aAllocator->GetTextureForwarder() : nullptr, descriptor, gfx::BackendType::NONE, bufSize, aTextureFlags); }
bool CD3DVertexShader::Create(const void* code, size_t codeLength, D3D11_INPUT_ELEMENT_DESC* vertexLayout, unsigned int vertexLayoutSize) { ReleaseShader(); ID3D11Device* pDevice = g_Windowing.Get3D11Device(); if (!pDevice) return false; // trick to load bytecode into ID3DBlob if (FAILED(D3DStripShader(code, codeLength, D3DCOMPILER_STRIP_REFLECTION_DATA, &m_VSBuffer))) { CLog::Log(LOGERROR, __FUNCTION__ " - Failed to load the vertex shader."); return false; } if (vertexLayout && vertexLayoutSize) { m_vertexLayoutSize = vertexLayoutSize; m_vertexLayout = new D3D11_INPUT_ELEMENT_DESC[vertexLayoutSize]; for (unsigned int i = 0; i < vertexLayoutSize; ++i) m_vertexLayout[i] = vertexLayout[i]; } else return false; m_inited = CreateInternal(); if (m_inited) g_Windowing.Register(this); return m_inited; }
BufferTextureData* BufferTextureData::CreateForYCbCrWithBufferSize(KnowsCompositor* aAllocator, int32_t aBufferSize, YUVColorSpace aYUVColorSpace, uint32_t aBitDepth, TextureFlags aTextureFlags) { if (aBufferSize == 0 || !gfx::Factory::CheckBufferSize(aBufferSize)) { return nullptr; } bool hasIntermediateBuffer = aAllocator ? ComputeHasIntermediateBuffer(gfx::SurfaceFormat::YUV, aAllocator->GetCompositorBackendType()) : true; // Initialize the metadata with something, even if it will have to be rewritten // afterwards since we don't know the dimensions of the texture at this point. BufferDescriptor desc = YCbCrDescriptor(gfx::IntSize(), 0, gfx::IntSize(), 0, 0, 0, 0, StereoMode::MONO, aYUVColorSpace, aBitDepth, hasIntermediateBuffer); return CreateInternal(aAllocator ? aAllocator->GetTextureForwarder() : nullptr, desc, gfx::BackendType::NONE, aBufferSize, aTextureFlags); }
// static already_AddRefed<nsIRunnable> IDBVersionChangeEvent::CreateRunnableInternal(const nsAString& aType, const nsAString& aVersion, nsIDOMEventTarget* aTarget) { nsCOMPtr<nsIDOMEvent> event = CreateInternal(aType, aVersion); NS_ENSURE_TRUE(event, nsnull); nsCOMPtr<nsIRunnable> runnable(new EventFiringRunnable(aTarget, event)); return runnable.forget(); }
bool CD3DTexture::Create(UINT width, UINT height, UINT mipLevels, D3D11_USAGE usage, DXGI_FORMAT format, const void* pixels /* nullptr */, unsigned int srcPitch /* 0 */) { m_width = width; m_height = height; m_mipLevels = mipLevels; // create the texture Release(); if (format == DXGI_FORMAT_UNKNOWN) format = DXGI_FORMAT_B8G8R8A8_UNORM; // DXGI_FORMAT_UNKNOWN if (!g_Windowing.IsFormatSupport(format, D3D11_FORMAT_SUPPORT_TEXTURE2D)) { CLog::Log(LOGERROR, __FUNCTION__" - unsupported texture format %d", format); return false; } m_cpuFlags = 0; if (usage == D3D11_USAGE_DYNAMIC || usage == D3D11_USAGE_STAGING) { m_cpuFlags |= D3D11_CPU_ACCESS_WRITE; if (usage == D3D11_USAGE_STAGING) m_cpuFlags |= D3D11_CPU_ACCESS_READ; } m_format = format; m_usage = usage; m_bindFlags = 0; // D3D11_BIND_SHADER_RESOURCE; if (D3D11_USAGE_DEFAULT == usage && g_Windowing.IsFormatSupport(format, D3D11_FORMAT_SUPPORT_RENDER_TARGET)) m_bindFlags |= D3D11_BIND_RENDER_TARGET; if ( D3D11_USAGE_STAGING != m_usage ) { if (g_Windowing.IsFormatSupport(format, D3D11_FORMAT_SUPPORT_SHADER_LOAD) || g_Windowing.IsFormatSupport(format, D3D11_FORMAT_SUPPORT_SHADER_SAMPLE)) { m_bindFlags |= D3D11_BIND_SHADER_RESOURCE; } if (g_Windowing.IsFormatSupport(format, D3D11_FORMAT_SUPPORT_DECODER_OUTPUT)) { m_bindFlags |= D3D11_BIND_DECODER; } } if (!CreateInternal(pixels, srcPitch)) { CLog::Log(LOGERROR, "%s - failed to create texture.", __FUNCTION__); return false; } g_Windowing.Register(this); return true; }
/* virtual */ SysStatus FileLinuxPacket::dup(FileLinuxRef& newSocket) { SysStatus rc; ObjectHandle copyOH; rc = giveAccessByClient(copyOH, DREFGOBJ(TheProcessRef)->getPID()); if (_FAILURE(rc)) return rc; rc = CreateInternal(newSocket, copyOH, stubHolder->transType, openFlags, sDomain, sType, sProtocol); return rc; }
void CD3DTexture::RestoreTexture() { // yay, we're back - make a new copy of the texture if (!m_texture && m_data) { if (!CreateInternal(m_data, m_pitch)) { CLog::Log(LOGERROR, "%s: failed restore texture", __FUNCTION__); } delete[] m_data; m_data = NULL; m_pitch = 0; } }
BufferTextureData* BufferTextureData::CreateForYCbCrWithBufferSize(ClientIPCAllocator* aAllocator, int32_t aBufferSize, TextureFlags aTextureFlags) { if (aBufferSize == 0 || !gfx::Factory::CheckBufferSize(aBufferSize)) { return nullptr; } // Initialize the metadata with something, even if it will have to be rewritten // afterwards since we don't know the dimensions of the texture at this point. BufferDescriptor desc = YCbCrDescriptor(gfx::IntSize(), gfx::IntSize(), 0, 0, 0, StereoMode::MONO); return CreateInternal(aAllocator, desc, gfx::BackendType::NONE, aBufferSize, aTextureFlags); }
bool CD3DPixelShader::Create(const std::wstring& wstrFile) { ReleaseShader(); ID3D11Device* pDevice = g_Windowing.Get3D11Device(); if (!pDevice) return false; if (FAILED(D3DReadFileToBlob(wstrFile.c_str(), &m_PSBuffer))) { CLog::Log(LOGERROR, __FUNCTION__ " - Failed to load the vertex shader."); return false; } m_inited = CreateInternal(); if (m_inited) g_Windowing.Register(this); return m_inited; }
Packet * PacketFactory::CreatePacket( int type ) { assert( type >= 0 ); assert( type < m_numPacketTypes ); Packet * packet = CreateInternal( type ); if ( !packet ) { m_error = PACKET_FACTORY_ERROR_FAILED_TO_ALLOCATE_PACKET; return NULL; } #if YOJIMBO_DEBUG_PACKET_LEAKS allocated_packets[packet] = type; assert( allocated_packets.find( packet ) != allocated_packets.end() ); #endif // #if YOJIMBO_DEBUG_PACKET_LEAKS m_numAllocatedPackets++; return packet; }
bool CD3DPixelShader::Create(const void* code, size_t codeLength) { ReleaseShader(); ID3D11Device* pDevice = g_Windowing.Get3D11Device(); if (!pDevice) return false; // trick to load bytecode into ID3DBlob if (FAILED(D3DStripShader(code, codeLength, D3DCOMPILER_STRIP_REFLECTION_DATA, &m_PSBuffer))) { CLog::Log(LOGERROR, __FUNCTION__ " - Failed to load the vertex shader."); return false; } m_inited = CreateInternal(); if (m_inited) g_Windowing.Register(this); return m_inited; }
void CD3DPixelShader::OnCreateDevice() { if (m_PSBuffer && !m_PS) m_inited = CreateInternal(); }
void CD3DVertexShader::OnCreateDevice() { if (m_VSBuffer && !m_VS) m_inited = CreateInternal(); }