Пример #1
0
HANDLE CDx11GraphicDevice::GetOutputBufferSharedHandle()
{
	HRESULT result = S_OK;
	Framework::Win32::CComPtr<IDXGIResource> resource;
	assert(!m_outputBuffer.IsEmpty());
	result = m_outputBuffer->QueryInterface<IDXGIResource>(&resource);
	assert(SUCCEEDED(result));
	if(FAILED(result))
	{
		return INVALID_HANDLE_VALUE;
	}
	HANDLE sharedHandle = INVALID_HANDLE_VALUE;
	result = resource->GetSharedHandle(&sharedHandle);
	assert(SUCCEEDED(result));
	return sharedHandle;
}
Пример #2
0
void CDx11Effect::CompilePixelShader(const std::string& shaderText)
{
	assert(m_pixelShader.IsEmpty());

	Framework::Win32::CComPtr<ID3DBlob> pixelShaderCode;
	Framework::Win32::CComPtr<ID3DBlob> pixelShaderErrors;

	UINT compileFlags = 0;
#ifdef _DEBUG
	compileFlags |= D3DCOMPILE_DEBUG;
#endif

	HRESULT result = D3DCompile(shaderText.c_str(), shaderText.length() + 1, "ps", nullptr, nullptr, "PixelProgram",
		"ps_5_0", compileFlags, 0, &pixelShaderCode, &pixelShaderErrors);
	if(FAILED(result))
	{
		if(!pixelShaderErrors.IsEmpty())
		{
			OutputDebugStringA(shaderText.c_str());
			OutputDebugStringA("\r\n");
			OutputDebugStringA(reinterpret_cast<const char*>(pixelShaderErrors->GetBufferPointer()));
		}
		DebugBreak();
	}

	result = m_device->CreatePixelShader(pixelShaderCode->GetBufferPointer(), pixelShaderCode->GetBufferSize(), nullptr, &m_pixelShader);
	assert(SUCCEEDED(result));
}