How do I get dx9 shader debugging to work?

Started by
4 comments, last by bobofjoe 14 years, 1 month ago
I am writing a DX9 app. My shader has an error, but I dont know what the error is. So how do I get shader debugging to work correctly? I ran dx control panel, and enabled shader debugging, and maxed debug level, but the only error I get from visual studio is like this: ... c:\program files (x86)\microsoft directx sdk (august 2009)\samples\c++\direct3d\instancing\instancing.cpp(1145): D3DXCreateEffectFromFile( pd3dDevice, str, NULL, NULL, dwShaderFlags, NULL, &g_pEffect, NULL ) hr=E_FAIL (0x80004005) ... This is not the shader compiler error that I want to see.
-goodbye-
Advertisement
One of the parameters of the D3DXCreateEffectFromFile function is a **ID3DXBuffer which you can use to get the compiler errors. If I remember correctly, you don't have to allocate the buffer yourself - the function will do that for you if the parameter is non-null.

Be sure to initialize your error buffer pointer to null before calling D3DXCreateEffectFromFile. After you call the function, you can check if the error buffer is still null or not. In case it was allocated, you can use the buffer's GetBufferPointer method to gain access to the error text. The text is in ANSI format. If you do a debug break upon having a non-null error buffer pointer, you can view the error text easily in the watch window by casting the buffer's data pointer to a char[].

Niko Suni

I tried that, but the pointer is NULL after the call fails.


LPD3DXBUFFER* ppCompilationErrors = NULL;
hr = D3DXCreateEffectFromFile( pd3dDevice, str, NULL, NULL, dwShaderFlags, NULL, &g_pEffect, ppCompilationErrors);


ppCompilationErrors is still null


Anyone know how to enable shader debugging for HLSL DX9 ?????????????????
-goodbye-
This has absolutely nothing to do with shader debugging. Shader debugging lets you step through a shader line by line and watch values...your shader isn't even compiling so you can't debug it. I would try compiling your shader with fxc.exe and see if that works. If it does, then debug your app and make sure that the filepath and device pointer you're passing are valid.
ok i figured it out. I was using the pointer incorrectly. Here is the working code if anyone is curious.


LPD3DXBUFFER ppCompilationErrors = NULL;
hr = D3DXCreateEffectFromFile( pd3dDevice, str, NULL, NULL, dwShaderFlags,
NULL, &g_pEffect, &ppCompilationErrors);

if(hr!=0)
{
char* pText = (char*)ppCompilationErrors->GetBufferPointer();
_asm int 3h;
}
-goodbye-
Don't use _asm to insert a breakpoint in your code, use the documented and supported DebugBreak() function.

[size=1]Visit my website, rawrrawr.com

This topic is closed to new replies.

Advertisement