• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by yangguo · Jul 23, 2015 at 02:07 PM · pluginwindowsdebugdirectxdirect3d

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 the Flags parameter is not editable.

Does anyone have any good ideas on how to activate DX debug layers in Unity?

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

3 Replies

· Add your reply
  • Sort: 
avatar image
1

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.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

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"

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

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)

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

23 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Trying to build plugin for windows 0 Answers

Prime31 azure plugin can't build 0 Answers

What can we do to allow the Universal Windows Platform to accept the framework from a plugin’s rejected scripts? 1 Answer

How can the native Unity plugin be initialized before the Direct3D rendering device is created? 2 Answers

How would I debug a Unity-plugin from XCode? 3 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges