HLSL compiler output

Started by
2 comments, last by mwadelin 12 years, 10 months ago
Hi Guys,

I'm using C++ and visual studio 2008 with directx10 to create a 3d app. However the royal pain in the arse is when the D3DX10CreateEffectFromFile doesn't compile a shader because of a syntax error. Is there anyway to get the errors that happen when trying to compile an .fx file to come up in the output window of the IDE?

See I'm used to using XNA where my shader errors would appear in the Error/output window at compile time. Is this something that is only available in managed languages then?

Thanks
Mike
Advertisement
There is. From the MSDN docs, the second to last parameter would be a ID3D10Blob that contains any compile errors. Then you could use that as output to your console or window or wherever else.

E.g.


ID3D10Blob* pErrors = 0;
D3DX10CreateEffectFromFile("myShader.fx", NULL, NULL, "fx_4_0", shaderFlags, 0, pDevice, NULL, NULL, &pEffect, &pErrors, NULL);
char* pCompileErrors = static_cast<char*>(pErrors->GetBufferPointer());
most of the same as above,easily way i use is following.


if(FAILED(D3DX11CompileFromFile( L"ComputeRay.hlsl", 0, 0, "CS","cs_5_0",0, 0, 0, &pBlob, &pErrors, 0 )))
{
char* ms=(char*)pErrors->GetBufferPointer();
MessageBoxA(0,ms,NULL,MB_OK);
}


i believe there is more sophisticated way like you said output window or something.
Thanks guys, yeah I'll prob have a look into linking it into the output window later but a popup will do for now :D

This topic is closed to new replies.

Advertisement