Original:DXUT11 Frame Analysis (4)--Debugging related
DXUT11 Frame Analysis (4)--Debugging related
1. Debugging differences between D3D8/9 and D3D10/11
As soon as DXSDK is installed, there is a debugging tool for DirectX ControlPanel, as shown in. Here you can set Direct3D 9 as the Debug runtime (debug D3d9 Runtime) or retail runtime (Retaild3d9 runtime). Note that the settings here are global, and if you change to debug run, all programs that use D3D9 will go into debug mode, which will make these programs run slowly.
Starting from Vista, the system's own interface is rendered using D3D, which must change the method above, or the system will easily get stuck. Starting with Direct3D 10.0, the API layering mechanism has been used to debug the SDK debug layer. If you need to debug a program, you can use the D3dxx_create_device_debug tag when you create the D3D device or add the program you want to debug to the debug list with the Control Panel tool above:
2. Debug information output function
The following functions are defined in DXUTMISC.H:
[CPP]View PlainCopy
- void WINAPI Dxutoutputdebugstringw (lpcwstrstrmsg, ...);
- void WINAPI Dxutoutputdebugstringa (lpcstrstrmsg, ...);
- #ifdef UNICODE
- #define Dxutoutputdebugstring Dxutoutputdebugstringw
- #else
- #define Dxutoutputdebugstring Dxutoutputdebugstringa
- #endif
Format the string and print debug information by calling the API function OutputDebugString. For example, we write a sentence in the ond3d11framerender of EmptyProject11 this sample:
Dxutoutputdebugstring (L "Test \ n");
Debug run, this debug message will be printed in the Output window whenever you run to this sentence:
3. The D3D structure is converted into strings for easy display
[CPP]View PlainCopy
- void WINAPI dxuttracedecl (d3dvertexelement9decl[max_fvf_decl_size]);
- wchar* WINAPI dxuttraced3ddeclusagetostring ( BYTE u);
- wchar* WINAPI dxuttraced3ddeclmethodtostring ( BYTE m);
- wchar* WINAPI dxuttraced3ddecltypetostring ( BYTE t);
- wchar* WINAPI dxuttracewindowsmessage (uintumsg);
4. D3d10 or more version debug information
[CPP]View PlainCopy
- void Dxut_setdebugname (idirect3dresource9* pObj,const char* pstrname)
- void Dxut_setdebugname (idxgiobject* pObj,const char* pstrname)
- void Dxut_setdebugname (id3d10device* pObj,const char* pstrname)
- void Dxut_setdebugname (id3d10devicechild* pObj,const char* pstrname)
- void Dxut_setdebugname (id3d11device* pObj,const char* pstrname)
- void Dxut_setdebugname (id3d11devicechild* pObj,const char* pstrname) <span style="FONT-SIZE:18PX;" >
- </span>
Specifies an easy-to-read name for an object, which can be easily seen when a memory leak occurs at the debug layer.
5. PIX-Assisted debugging
[CPP]View PlainCopy
- #ifdef profile
- Profile was defined, so these macros call the D3dperffunctions
- #define Dxut_beginperfevent (color, pstrmessage) dxut_dynamic_d3dperf_beginevent (color, pstrmessage)
- #define Dxut_endperfevent () dxut_dynamic_d3dperf_endevent ()
- #define Dxut_setperfmarker (color, pstrmessage) dxut_dynamic_d3dperf_setmarker (color, pstrmessage)
- #else
- Profile isn't defined, so these macros does nothing
- #define Dxut_beginperfevent (color, pstrmessage) (__noop)
- #define Dxut_endperfevent () (__noop)
- #define Dxut_setperfmarker (color, pstrmessage) (__noop)
- #endif
- Class Cdxutperfeventgenerator
This allows for a simplified use of the d3dperf_beginevent, D3dperf_beginevent, and d3dperf_beginevent three API packages. Mainly used for PIX debugging Direct3D program. Cdxutperfeventgenerator simplifies the implementation of d3dperf_beginevent and d3dperf_beginevent requiring pairing calls by way of classes.
Resources
Http://blogs.msdn.com/b/chuckw/archive/2012/11/30/direct3d-sdk-debug-layer-tricks.aspx
http://msdn.microsoft.com/en-us/library/windows/desktop/ff476881 (v=vs.85). Aspx#debug
"Reprint" DXUT11 Frame Analysis (4)--Debugging related