4

I'm trying to get DirectX 11 debug layer working. So far I've enabled debugging on the device, and that's as far as I can get. I'm not getting any kind of debug output. All the guides I can find are basically just lumps of code without any real explanation of what's going on, so when it gets to applying what's in there to my specific problem it immediately breaks down and I get nowhere. I'm also not actually learning anything about how to use the debug layer, I'm not learning how to best utilise these technologies for my needs etc.

Basically, can anyone provide me with a step by step of how to get the debug output working?

This is what I've got so far:

DXGI_SWAP_CHAIN_DESC swapChainDesc;

ZeroMemory(&swapChainDesc, sizeof(DXGI_SWAP_CHAIN_DESC));

swapChainDesc.BufferCount = 1;
swapChainDesc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
swapChainDesc.OutputWindow = hWnd;
swapChainDesc.SampleDesc.Count = 4;
swapChainDesc.Windowed = true;

D3D_FEATURE_LEVEL featureLevels [] = { D3D_FEATURE_LEVEL_11_0, D3D_FEATURE_LEVEL_10_1, D3D_FEATURE_LEVEL_10_0 };

UINT creationFlags = 0;

#ifdef _DEBUG
creationFlags |= D3D11_CREATE_DEVICE_DEBUG;
#endif

D3D_FEATURE_LEVEL capabilities;
D3D11CreateDeviceAndSwapChain(  NULL,
                                D3D_DRIVER_TYPE_HARDWARE,
                                NULL,
                                creationFlags,
                                featureLevels, //D3D_FEATURE_LEVEL *
                                ARRAYSIZE(featureLevels), //number of feature levels
                                D3D11_SDK_VERSION,
                                &swapChainDesc,
                                &m_swapChain,
                                &m_device,
                                &capabilities,
                                &m_devCon);

Thanks!

Mark
  • 155
  • 3
  • 16
  • Are you sure it has something worth to report? Just have it say something intentional, QI for ID3D11Debug and use ReportLiveDeviceObjects(D3D11_RLDO_DETAIL). I get 7 lines of output in the VS output window. – Hans Passant Jan 25 '15 at 22:10
  • I don't know what QI means. I haven't used ID3D11Debug because I don't know how to set it up. – Mark Jan 25 '15 at 22:22
  • Call m_device's QueryInterface() method to obtain the ID3D11Debug interface pointer. – Hans Passant Jan 25 '15 at 22:49
  • Ok, if I wanted to store that interface pointer in an ID3D11Debug* member (only declared for #ifdef _DEBUG), how do I go about making sure it is managed properly? I imagine the object will be released when m_device is released – Mark Jan 25 '15 at 22:54
  • It is just a test to make sure it is functional. So after calling ReportLiveDeviceObjects(), call its Release() method to release the interface. Looks like you assume you have to do something "special" to get it to produce diagnostics. You don't, it automatically spits info to the Output window when it finds something wrong. – Hans Passant Jan 25 '15 at 22:55
  • I hear I'm supposed to get warnings if I missed out a Release(), but I'm currently not. Have I missed something? – Mark Jan 25 '15 at 23:20
  • 1
    See [Direct3D SDK Debug Layer Tricks](http://blogs.msdn.com/b/chuckw/archive/2012/11/30/direct3d-sdk-debug-layer-tricks.aspx). – Chuck Walbourn Jan 26 '15 at 17:06
  • Setting `D3D11_CREATE_DEVICE_DEBUG` should be enough. As Hans said: you might not be doing anything wrong that needs to be reported. Try calling `AddRef`on your device several times without calling `Release` - you should see something like `D3D11 WARNING: Live Producer at 0x006E4AF4, Refcount: 3. [ STATE_CREATION WARNING #0: UNKNOWN]` in Visual Studio's output window if the debug layer is working. – Christoph Feb 04 '16 at 21:33
  • And you need to make sure that your programme is exiting normally. The live object warnings will not show up if you are killing it using the stop button in the debugger. Just make sure you are exiting cleanly with `PostQuitMessage` on a keyboard or window close event. – Christoph Feb 04 '16 at 21:59

0 Answers0