[UE4]How to use Visual Studio Graphics Debugger to debug shader

posted in: 未分類 | 0

Note: This article is translated by Lingotek.

Basically the official recommended shader debug process is to use Renderdoc plugin:
https://github. com/temaran/ue4renderdocplugin

The plugin was integrated into engine plugin in 4.17, so you can just use it.

But, when we using Visual Studio, you will find there also has a Graphics Debugger called Visual Studio Graphics Debugger:

After start the program, you will find engine just emit following error message:

DX11 Feature level 10.0 is required to run the engine.

Is there any way to use this tool?

We need to modify the consolevariables.ini file (please manually add it to your Project’s Config folder),
and insert the following code:


[Startup] r.GraphicsAdapter=0

0 means that we will use of the first graphics Adapter, the detail definition in the engine is here:

static TAutoConsoleVariable CVarGraphicsAdapter(
TEXT("r.GraphicsAdapter"),
-1,
TEXT("User request to pick a specific graphics adapter
(e.g. when using a integrated graphics card with a discrete one)\n")
TEXT("At the moment this only works on Direct3D 11.
Unless a specific adapter is chosen we reject
Microsoft adapters because we don't want the software emulation.\n")
TEXT(" -2: Take the first one that fulfills the criteria\n")
TEXT(" -1: Favour non integrated because there are usually faster (default)\n")
TEXT(" 0: Adapter #0\n")
TEXT(" 1: Adapter #1, ..."),
ECVF_RenderThreadSafe);

The default number is -1.

After modify config file, you can start capture frame for analysis.

Here are some screenshots:

But, It’s not a good idea to adjust ConsoleVariables.ini, because it affects the final shipping results.

So it would be a good idea to be able to pass in the parameters from console command line to decide whether to turn on the feature.
To do this, I slightly modified the the engine and sent a pull request to the official github:
https://github. com/epicgames/unrealengine/pull/4163

If the official has accepted this PR,
You can just add -DebugGraphics to your UnrealVS toolbar to turn on the feature.
Remember add -d3ddebug and -emitdrawevents, so you can get more complete message for graphics debugger.

Comment