- Home /
How to enable DX debug layer D3D11_CREATE_DEVICE_DEBUG?
I'm developing on Windows and my target platform is also desktop Windows (not metro). I have a native DX plugin that I need more help debugging. How do I enable DX debug layer in Unity? In a non-Unity DX app, I would add the flag D3D11_CREATE_DEVICE_DEBUG
to the D3D11CreateDevice
call. However, I can't do this in Unity due to the fact that Unity internally creates the device on my behalf.
I also tried the following:
Using the DirectX Control Panel to enable the debug layer. However, using it to add debug layer support for my .exe did not make any difference.
Using Visual Studio Debugger to break on
d3d11!D3D11CreateDevice
as inspired by the post here for Windows Phone 8. However, it seems the Watch value for theFlags
parameter is not editable.
Does anyone have any good ideas on how to activate DX debug layers in Unity?
Answer by yangguo · Aug 07, 2015 at 01:50 PM
I figured this out. Follow these instructions for Windows Phone 8 debugging even if you are building for Windows. The main difference is that when you break on d3d11!D3D11CreateDevice, if you have an x86_64 target, you will need to set register r9 to xor with the value 2 which corresponds to the flag D3D11_CREATE_DEVICE_DEBUG.
Answer by bo3bber · Mar 23, 2019 at 08:23 AM
Just wanted to say, Thank you very much!
This helped me solve a problem in my Unity x64 plugin in minutes.
Still r9 in Win10, and the starting value for me was r9=3 to enable Debug layer. Unity version 2017.4.24f1.
Also worth noting that to set the breakpoint on CreateDevice, it is case-sensitive, so it must be precisely "d3d11!D3D11CreateDevice"
Answer by Milek7 · Jan 23 at 01:10 AM
Now you can just append -force-d3d11-debug to command line arguments. (tested on Unity 2020.3)
Your answer
Follow this Question
Related Questions
DLL Import problems - "Not found" & Proper setup? 0 Answers
Any way to hook into the start of a frame, or to have GUI elements write to the depth buffer? 0 Answers
Unhandled Exception: System.TypeLoadException after I put a plugin. 0 Answers
Directx 11device context with debug 1 Answer
Building win32 application of unity3d failes with teamcity plugin 1 Answer