Debug shaders with Visual Studio
Use Microsoft Visual Studio to debug shaders on Windows platforms using DirectX 11 or 12.
阅读时间2 分钟最后更新于 1 个月前
You can use Visual Studio to debug shaders in a Unity application on Windows platforms using DirectX 11 or 12. This page contains information on how to do this.
Preparing your shaders
To debug shaders, you must compile them with debug symbols included. To do that, insert the directive into the source code of each shader that you want to debug.
#pragma enable_d3d11_debug_symbolsCreating a placeholder Visual Studio project for Windows Standalone
If you build your application for Windows Standalone, you must create a placeholder Visual Studio project. If you build your application for Universal Windows Platform, Unity generates a Visual Studio project for you.
- Launch Visual Studio.
- Go to File > New > Project > Visual C++ > Empty Project.
- Go to Project > Properties > Configuration Properties > Debugging
- In the Command field, replace $(TargetPath) with the path to your Windows Standalone application (for example, C:\MyApp\MyApp.exe)
- If you want to force the project to run under DirectX 11, select Command Arguments and type -force-d3d11.
Using Visual Studio to debug shaders
For instructions on setting up Visual Studio, see the Microsoft documentation: Install Visual Studio.
For instructions on setting up and using Visual Studio's graphics debugging tools, see the Microsoft documentation: Visual Studio Graphics Diagnostics.