Jump to content
  • Advertisement
Sign in to follow this  
Fire Lancer

D3d10 load effect failing, but no error info

This topic is 3495 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

For some reason this has started to just fail, but not provide any debugging infomation:
	unsigned shaderFlags = D3D10_SHADER_ENABLE_STRICTNESS;
#ifdef _DEBUG
	shaderFlags |= D3D10_SHADER_DEBUG;
#endif
	hr = D3DX10CreateEffectFromResource(
		Module, MAKEINTRESOURCE(IDR_FX_PRIMITIVE), L"primitive.fx",
		NULL, NULL, "fx_4_0", shaderFlags, 0, device, NULL, NULL, &primEffect, NULL, NULL);
	if(FAILED(hr))throw WinError(L"Failed to load effect: primitive.fx",hr);
...
class WinError : public fllib::exception::Error
{
public:
	WinError(const std::wstring &msg, HRESULT error)
		:Error(msg + L"\n\n")
	{
		wchar_t *formatted;
		FormatMessage(
			FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
			0, error, 0, (wchar_t*)&formatted, 1, 0);
		str += formatted;
		LocalFree(formatted);
	}
};


D3D10 sends nothing to the Visual Studio output window like it does normally, and my exception class just formats the hr as "Unspecified error" Hers the shader I was trying to load if it makes any diffrence:
matrix Projection;

struct VS_INPUT
{
    float4 Pos : SV_POSITION;
};
struct PS_INPUT
{
    float4 Pos : SV_POSITION;
};

float4 VS(VS_INPUT input)
{
    PS_INPUT output = (PS_INPUT)0;
    output.Pos = mul(input.Pos, Projection);
    return output;
}

float4 PS(PS_INPUT input):SV_Target
{
    return float4(0.0f, 1.0f, 1.0f, 1.0f);
}


technique10 Render
{
    pass P0
    {
        SetVertexShader  (CompileShader(vs_4_0, VS()));
        SetGeometryShader(NULL );
        SetPixelShader   (CompileShader(ps_4_0, PS()));
    }
}


Share this post


Link to post
Share on other sites
Advertisement
Hey,
there's a far less complicated way to recieve debug info for a shader than that fiendishly complex looking chuck of code, the following code is directx9, but will most likely work on 10 with some minor changes;


LPD3DXBUFFER pBuffer;

if(FAILED(D3DXCreateEffectFromFile(pd3dDevice, strEffectFilePath, NULL, NULL, dwShaderFlags, NULL, &m_pEffect, &pBuffer)))
{
// if effect could not compile, output shader debug info
LPVOID pCompileErrors = pBuffer->GetBufferPointer();
MessageBox(NULL, (const char*)pCompileErrors, "Compile Error", MB_OK|MB_ICONEXCLAMATION);
PostQuitMessage(0);
}

Share this post


Link to post
Share on other sites
Yep, leet bix's technique is the recommended approach under D3D10 as well. You'll want to use ID3D10Blob* instead of LPD3DXBUFFER, and you'll want to be passing it in as the penultimate parameter to CreateEffectFromResource (after primEffect).

Share this post


Link to post
Share on other sites
Ok thanks, I didnt realise there was an extra output that contained error info for loading shaders, I thought the extra outputs were only for non blocking load calls with the new d3d10 threading stuff.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!