Skip to main content
GameDev.net gamedev.net
🔒 Locked

HLSL debugger in VS7

Started by rpsathe Sep 26, 2005 at 2:43 AM 2 replies 1.2k views
Original Post
rpsathe
rpsathe
I am able to use HLSL debugger only in a limited capacity. I have a code that looks like following float3 Reflect = normalize(2 * diff * Normal - LightDir); float temp1 = (float) dot(Reflect, ViewDir); float specular = pow(saturate(dot(Reflect, ViewDir)), 8); // R.V^n Output.RGBColor = specular * g_LightSpecular[0] * g_MaterialSpecularColor; I am able to step thru'. When I insert following line between line #2 and #3 in this code, float temp1 = dot(Reflect, ViewDir); and try to right click on temp1 and say "Quick Watch" or "Add Watch" it says unable to evaluate the expression. Why does it say so? Any ideas? -R
Giallanon
Giallanon
temp1 is unreferenced so the compiler will automaticaly exclude that line of code.
The shader will never execute that line beacause you are never going to use temp1 anywhere.


PS: How do you setup HLSL debugger? I've downloaded latest DX SDK but I don't see any option to install the HLSL debugger. Is there something to download somewhere?
rpsathe
rpsathe
Hey man,
thanks for your reply. Here's how you set-up the HLSL debugger.

1. Go to Start->Control Panel->DirectX
2. Open it.
3. Click on D3D Tab.
4. On the right, check Use Debug Version of HLSL.
5. In thr right bottom quadrant, check the box that says Enable Shader Debug.
6. Also set the Maximum Validation.
7. Click Okay.
8. Then back into your code. (If you're using BasicHLSL template that comes with SDK) uncomment the lines

#define DEBUG_PS
#define DEBUG_VS

Make sure there's a code in ModifyDeviceSettings that enables Reference Rasterizer somewhere down in your code.


#ifdef DEBUG_VS
if( pDeviceSettings->DeviceType != D3DDEVTYPE_REF )
{
pDeviceSettings->BehaviorFlags &= ~D3DCREATE_HARDWARE_VERTEXPROCESSING;
pDeviceSettings->BehaviorFlags &= ~D3DCREATE_PUREDEVICE;
pDeviceSettings->BehaviorFlags |= D3DCREATE_SOFTWARE_VERTEXPROCESSING;
}
#endif
#ifdef DEBUG_PS
pDeviceSettings->DeviceType = D3DDEVTYPE_REF;
#endif
// For the first device created if its a REF device, optionally display a warning dialog box
static bool s_bFirstTime = true;
if( s_bFirstTime )
{
s_bFirstTime = false;
if( pDeviceSettings->DeviceType == D3DDEVTYPE_REF )
DXUTDisplaySwitchingToREFWarning();
}


Once you're done with that. If you want to catch syntax errors from your .fx file, open Visual Studio command prompt and compile .fx file using fxc (command line compiler for HLSL). fxc foo.fx ..simple.

Then go back to your Visual Studio, set breakpoint in your .fx file.
Click Debug->Direct3D->Start with Direct3D Debuggine.

And your breakpoint should be hit.
Hope this helps

Now I am gonna try what you suggested. Will assign it to 0 first and then evaluate the dot product.

Have a good day.
-Rahul

Giallanon
Giallanon
Hello again.

Quote:

Now I am gonna try what you suggested. Will assign it to 0 first and then evaluate the dot product.

I'm not sure this will work, I think you have to use temp1 in order to calculate something usefull..for example you could try with this:
Output.RGBColor = temp1 * specular * g_LightSpecular[0] * g_MaterialSpecularColor;



Quote:

Then go back to your Visual Studio, set breakpoint in your .fx file.
Click Debug->Direct3D->Start with Direct3D Debuggine.

Eheh this is the problem..I can't see "Debug->Direct3D->Start debug" menu.
The SDK say it should be a checkbox to click during the SDK installation in order to install this feature but I don't see it :(

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.