Jump to content

  • Log In with Google      Sign In   
  • Create Account


Rarosu

Member Since 16 Jun 2010
Offline Last Active Aug 22 2012 01:26 PM
-----

Topics I've Started

Effects11: Check for supported shader version?

17 August 2012 - 05:27 AM

Hello,

I'm getting a problem when creating an effect using the Effects11 framework:

D3D11: ERROR: ID3D11Device::CreateVertexShader: Shader must be vs_4_0 or vs_4_1. Shader version provided: vs_5_0 [ STATE_CREATION ERROR #167: CREATEVERTEXSHADER_INVALIDSHADERTYPE ]
First-chance exception at 0x000007fefde9cacd in WarSettlers.exe: Microsoft C++ exception: _com_error at memory location 0x0018e620..
D3D11: ERROR: ID3D11Device::CreatePixelShader: Shader must be ps_4_0 or ps_4_1. Shader version provided: ps_5_0 [ STATE_CREATION ERROR #193: CREATEPIXELSHADER_INVALIDSHADERTYPE ]
First-chance exception at 0x000007fefde9cacd in WarSettlers.exe: Microsoft C++ exception: _com_error at memory location 0x0018e620..

So my card isn't supporting a shader version higher than 4.1. Fair enough. I can switch adapter and then it works fine. My problem is that D3DX11CreateEffectFromMemory from which these errors originate returns S_OK. And then the program breaks because it cannot find a bound vertex and pixel shader. I'd really like to be able to catch this and output a proper error to the user, so my question is if there is any way of detecting this?

The code I use for compiling and creating an effect below:

// Compile the effect
ID3D10Blob* shader;
ID3D10Blob* errors;

HRESULT result = D3DX11CompileFromFile("Resources/Effects/BasicColor.fx",
	NULL,
	NULL,
	NULL,
	"fx_5_0",
	D3D10_SHADER_ENABLE_STRICTNESS | D3D10_SHADER_DEBUG,
	0,
	NULL,
	&shader,
	&errors,
	NULL);

if (FAILED(result))
{
	std::string errorMessage;
	if (errors != NULL)
	{
		errorMessage = static_cast(errors->GetBufferPointer());
	}
	else
	{
		errorMessage = "Could not find effect file";
	}

	throw DirectXErrorM(result, errorMessage);
}

result = D3DX11CreateEffectFromMemory(shader->GetBufferPointer(), shader->GetBufferSize(), 0, GetD3D().GetDevice().Resource(), &m_effect.Resource());
if (FAILED(result))
{
	throw DirectXErrorM(result, "Failed to create effect from compiled blob.");
}

Does anyone have any idea on how to check if the vertex- and pixel shader have been actually created by the effect?

PARTNERS