HLSL debugging?

Started by
2 comments, last by Dunge 15 years, 9 months ago
Hello! I'm currently trying to learn shaders and read whatever I can find about them. I ended up on "Direct3D 10 Shader Model 4.0 Workshop" in the DirectX SDK's Sample Browser. First lesson is supposed to help us understand the debugging aspect, having a bad case letter for a variable (who wasn't really bad at first?!, but I changed it to provoke the error anyway). It is told that I should see a debugging message output who would explain the error. I added the executable file in DirectX Control Panel DX10 debug programs and set it to force on. Upon running the application I get some First-chance exceptions and then
exercise00.cpp(262): D3DX10CreateEffectFromFile( str, NULL, NULL, "fx_4_0", dwShaderFlags, 0, pd3dDevice, NULL, NULL, &g_pEffect10, NULL, NULL ) hr=E_FAIL (0x80004005)
with a messagebox popup saying the same message. As I understand, this is the line creating the effect, but it tells me nothing about the actual error in the effect file (the bad case). DirectX Error Lookup tool for this hr code simply gives "An undetermined error occurred". I then searched this forum and saw a topic about VS2005 who can't debug HLSL. Maybe it's the same thing about VS2008 (which I have) so I went on and tried PIX as suggested. The output log was exactly the same, but I could see a list of all DX calls since the start of the application. Nothing about the actual error though. Any ideas??
Advertisement
An errors from the shader compiler will be put into the ID3D10Blob pointed to by the ppErrors parameter. You'll have to provide one, then pull the error out and look at it.

If you don't want to do that, you an just compile the .fx file using fxc on the command line and it will give you the errors.
Quote:Original post by Dunge
I added the executable file in DirectX Control Panel DX10 debug programs and set it to force on. Upon running the application I get some First-chance exceptions and then
exercise00.cpp(262): D3DX10CreateEffectFromFile( str, NULL, NULL, "fx_4_0", dwShaderFlags, 0, pd3dDevice, NULL, NULL, &g_pEffect10, NULL, NULL ) hr=E_FAIL (0x80004005)

with a messagebox popup saying the same message.


What you call the "debug" message are the error and warning messages from the compiler. It has nothing to do with the ability of VS2005 to debug shaders.

You can, for example, get them from within your code thanks to the ppErrorMsgs argument to the D3DX compile function.
ID3D10Blob *pErrorMsg = NULL;hr = D3DX10CompileFromFile( str, NULL, NULL, "myshader", "vs_4_0",     dwShaderFlags, NULL, NULL, &pVSBuf, &pErrorMsg, NULL );// you can also display a popup here if you preferif (pErrorMsg){    _RPT1(_CRT_WARN, "compilation error : %s\n", (char*) pErrorMsg->GetBufferPointer());     SAFE_RELEASE(pErrorMsg);}


That would display something like that to the debug output:

compilation error : myexample.vsh(56,5): error X3004: undeclared identifier 'Output'


LeGreg
Thanks for the help.
I actually meant the compilation and execution messages rather than actual debugging, sorry if I used the wrong term.

[Edited by - Dunge on July 24, 2008 2:35:54 AM]

This topic is closed to new replies.

Advertisement