Falcor icon indicating copy to clipboard operation
Falcor copied to clipboard

--debug-shaders option no effect

Open AndrewChan2022 opened this issue 1 year ago • 4 comments

I am using PIX to capture frame, and the shader always show "PDB missing" even if I enable --debug-shaders options.

pix settings: Screenshot 2024-01-01 162455

screen shot: Screenshot 2024-01-01 162133

AndrewChan2022 avatar Jan 01 '24 08:01 AndrewChan2022

I use the master branch.

the slang version is v2023320

<package name="slang" version="2023.3.20" remotes="github-slang-windows" platforms="windows-x86_64"/>

I build this slang version myself and add hard code debug info just before dxc compile, and without --debug-shaders, then I get the hlsl code in PIX.

AndrewChan2022 avatar Jan 02 '24 03:01 AndrewChan2022

I build this slang version myself and add hard code debug info just before dxc compile, and without --debug-shaders, then I get the hlsl code in PIX.

Curious, what flags did you provide to dxc? Was it just /Zi or also /Fd?

skallweitNV avatar Jan 08 '24 08:01 skallweitNV

I've checked with NSight Graphics and there is source level information when --debug-shaders is enabled. However, there is a caveat. If the shader cache is enabled (on by default) then changing the debug level setting on the shader compilation does not seem to invalidate the cached compiled shader, so if you run once without --debug-shaders followed by a run with --debug-shaders you get the cached shader without debug information. That is a bug in slang's shader cache and we have to fix that. As a workaround, you can manually delete the shader cache (delete .shadercache folder in the runtime directory) or disable the shader cache by running Mogwai with --shadercache="".

skallweitNV avatar Jan 09 '24 12:01 skallweitNV

A fix in slang is up for review https://github.com/shader-slang/slang/pull/3439

skallweitNV avatar Jan 09 '24 13:01 skallweitNV

I build this slang version myself and add hard code debug info just before dxc compile, and without --debug-shaders, then I get the hlsl code in PIX.

Curious, what flags did you provide to dxc? Was it just /Zi or also /Fd?

I insert /Zi before -no-warning inside function DXCDownstreamCompiler::compile

   args.add(L"-Zi");               // new code
   args.add(L"-no-warnings");       // old code

AndrewChan2022 avatar May 24 '24 12:05 AndrewChan2022

I've checked with NSight Graphics and there is source level information when --debug-shaders is enabled. However, there is a caveat. If the shader cache is enabled (on by default) then changing the debug level setting on the shader compilation does not seem to invalidate the cached compiled shader, so if you run once without --debug-shaders followed by a run with --debug-shaders you get the cached shader without debug information. That is a bug in slang's shader cache and we have to fix that. As a workaround, you can manually delete the shader cache (delete .shadercache folder in the runtime directory) or disable the shader cache by running Mogwai with --shadercache="".

So I use the private build only refresh the cache 🤣

AndrewChan2022 avatar May 24 '24 12:05 AndrewChan2022