Sign in to follow this  
Hello Kitty

How do I get dx9 shader debugging to work?

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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[].

Share this post


Link to post
Share on other sites
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 ?????????????????

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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;
}

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this