Enabling Direct3D Debug Information (Direct3D 9)
Are you trying to find out more information about Direct3D objects during debug? For instance, the following screen shot shows what you typically see when you look at a Direct3D interface in the watch window.
You can enable the core debug objects so that a mirrored object which contains all of the properties of the object can be viewed in the watch window. Simply include the following #define in your code before the D3D9.h file:
To enable debug information, the #define must get built before the D3D9.h file (Any program using DXUT will automatically enable D3D_DEBUG_INFO when the program is compiled for debug). If you are running a SDK sample, you can see this in DXStdAfx.h (which affects all the C++ samples). You must also be running the debug Direct3D runtime (which can be enabled from the Control Panel if necessary).
Here's an example using the BasicHLSL Sample.
- Add the #define to the Dxstdafx.h file before line 37.
- Build a debug project.
- Set a breakpoint at line 307 in BasicHLSL.cpp
- Run the debugger.
The following screen shot shows the kind of detailed information you can get about a Direct3D texture object from the watch window.
The object property names are visible and the values are correct only when the debug runtime is enabled. When running against the retail runtime, the values are invalid.
With Direct3D debug enabled, you can also look at a call stack each time an object is created. This will make your application very slow, but can be used to check for resource leaks. To write out the call stack, set the following registry key to 1:
Building your application with debug enabled will give you access to this additional variable:
This variable will store the call stack each time that an object is created. This will make your application very slow, but can be used to debug resource leaks.