Issue of Shader Symbol not being output in UE5.4

(This is a translation of a [Japanese [Content removed] by Lin Chia Jui.)

Due to our development circumstances, we have fixed the engine to UE5.4.

When we see a crash related to graphics, we output AfterMath. However, Shader Symbols are not output. So it’s very difficult to investigate the crash. For Shader Symbols to be output, we have edited the configuration file based on the page below, as follows:

https://dev.epicgames.com/documentation/ja\-jp/unreal\-engine/shader\-debugging\-workflows\-unreal\-engine

Config:

[ProjectDir]\Config\[Platform]\[Platform]Engine.ini

Console variables that have been added:

[ShaderCompiler]

r.InvalidateCachedShaders=1

r.Shaders.Symbols=1

r.Shaders.GenerateSymbols=1

r.Shaders.WriteSymbols=1

r.Shaders.SymbolsInfo=1

r.Shaders.WriteSymbols.Zip=1

r.Shaders.AllowUniqueSymbols=1

r.Shaders.ExtraData=1

r.Shaders.Optimize=0

r.Shaders.KeepDebugInfo=1

r.ShaderDevelopmentMode=1

r.DumpShaderDebugInfo=1

r.CompileShadersForDevelopment=1

When packaging the project, the files are generated, as shown on the reference page, in [ProjectDir]/Saved/ShaderSymbols/[Platform]/ShaderSymbols.zip, but the ShaderSymbols.zip is 0 KB and contains no files.

Questions:

(1) Did I set correctly?

(2) Does the following fix relate to the issue?

The above fix seems to depend on features in UE5.6. If this fix resolves the issue in UE5.6, is there a way to apply the fix to UE5.4, as well?

I looked over the fix. Shader Serialization, Shader Compiler, and Material Stats have been changed since UE5.4, and the fix seems to involve dependencies on these updates. That’s why I am asking this..

Thanks.

Hi Masahiro Yamakawa

you might need this CL if you are working with Vulkan -

https://github.com/EpicGames/UnrealEngine/commit/8cd18edb7220cabb31fcda78f2584cedd6b6f8a1

If you read this reddit post the debug markers for Vulkan were disabled in UE5.4 -

https://www.reddit.com/r/unrealengine/comments/1hlsmna/unusually\_high\_gpu\_time\_50ms\_on\_low\_end\_mobile/

Hope it helps

Best Regards

Rahul Gupta

(Not an Epic Games Employee)

[mention removed]​

(This is a translation of a Japanese post by Lin Chia Jui.)

Thank you very much for your reply.

Sorry for the insufficient information. We use DirectX.

If you have any related information, could you please share it with us?

Thanks.

Hi [mention removed]​

You can optionally set the Symbol Path in the ConsoleVaribales.ini using r.Shaders.SymbolPathOverride= and try that to see if you are getting any Shader symbol information and then link that Directory to the Tool you are using. Anecdotally I also set the r.DumpShaderDebugInfo=0 to get the complete debug shader info shaders rather than those that are just failing. I don’t recall any or know of any D3D12 specific switches that might have been added to the Engine itself in the Past recent versions of the API.

Also, I don’t think you can zip them and the project needs to exist as loose files to my knowledge and not a compressed archive. and it need to be a debug/development configuration build as well. The Consolevariable.ini also has a few additional comments that might be of worth taking a further look into for the variable values as well.

Hope it helps

Best Regards

Rahul Gupta

(Not an Epic Games Employee)

(This is a translation of a Japanese post by Lin Chia Jui.)

Thank you very much for your advice. I tried changing the ini file as shown below and tested it on my local machine. However, as before, no symbols are being output. The changes are highlighted in bold.

[ShaderCompiler]

r.Shaders.Symbols=1

r.Shaders.GenerateSymbols=1

r.Shaders.WriteSymbols=1

r.Shaders.SymbolsInfo=1

r.Shaders.WriteSymbols.Zip=0

r.Shaders.AllowUniqueSymbols=1

r.Shaders.ExtraData=1

r.Shaders.Optimize=0

r.ShaderDevelopmentMode=1

r.DumpShaderDebugInfo=0

r.CompileShadersForDevelopment=1

r.Shaders.SymbolPathOverride=“[ProjectPath]\Saved\TestShaderSymbols”

I tried another approach:

I incorporated the fix, which I had mentioned in my first post, into UE 5.4.4.

(Unreal Engine Issues and Bug Tracker (UE\-252263\))

In my environment, .pdb and .dxil files were output.

(*Please note that I have not confirmed if it works properly yet.)

It seems that the above fix also enables the use of r.Shaders.WriteSymbols.Zip.

However, there seems to be a restriction when using Windows:

Setting “r.Shaders.WriteSymbols.Zip=1” in [ShaderCompiler] causes the ZipWriter to retain write permissions for the Zip at the specified path when the Editor starts. When trying to cook the project via the project launcher in the Editor, a new ZipWriter tries to write the same files, but fails due to lack of write permissions.

To handle this restriction:

Before cooking, you need to set “r.Shaders.WriteSymbols.Zip=1” in [ShaderCompiler_BuildMachine], and “r.Shaders.WriteSymbols.Zip=0” in [ShaderCompiler], and then start the Editor.

I’ll try to see if .pdb and .dxil files can be used after packaging.

Thank you.

Hi there,

We solved a similar issue in UE 5.5. These shader symbol output issues and Aftermath symbol association have been solved in 5.6. However, earlier version of the Engine will likely have issues. Integrating the fix you mentioned and getting dxil and pdb outputs is indeed the first step. To test the symbols I would use PIX in editor to verify the shader symbols are working correctly (run the project with the -AttachPix launch argument, see documentation here) before trying to test this in builds or with Aftermath. Take a capture using PIX, set your PDB search paths in the PIX settings to the folder where your PDBs are being output, click the Start Analysis button, and see if you can see the shader code association properly:

Note: Clicking the `+` button is important after you select the folder that contains your shader PDB files.

[Image Removed]

Though I encourage you to test this yourself first, unfortunately, at least in 5.5, we found that backporting the fix you mentioned was not quite enough to be able to associate the shader source code in Aftermath. To get this to work we also had to backport the following two commits:

This first commit fixed the shader code association in aftermath. Note that we also needed to additionally set the r.GPUCrashDebugging.Aftermath.DumpShaderDebugInfo=1 CVAR for association to work.

This second commit was also required to fix a threading error introduced by the changes in the first commit.

Unfortunately backporting these commits to 5.4 may be fairly difficult, as there have been many changes between 5.4 and 5.6, and the fixing commits for these issues touch many files, many of which have had intermediate changes which may also be required. Please let me know how you go with this. If you manage to backport these changes successfully, it would be good if you could provide a git patch, with the fixing commit(s), here to help others who are also experiencing the same issues.

Regarding the ZipWriter issue, I would need a git patch with your current changes to be able to test this issue.

Regards,

Lance Chaney

[mention removed]​

(This is a translation of a Japanese post by Lin Chia Jui.)

Thank you very much for sharing the information.

I tried using PIX, and found the shader symbol association could be done without any issues.

[Image Removed]Also, thank you for providing the commits for Aftermath. I haven’t been able to test how they work yet, so I’ll consider whether to backport them after testing. As you pointed out, there have been extensive changes between 5.4 and 5.6. So I guess testing will take much time and effort.

>Regarding the ZipWriter issue, I would need a git patch with your current changes to be able to test this issue.

I haven’t made any changes to the source code. It will be OK whether you set r.Shaders.WriteSymbols.Zip to 0 or 1 if the PC does not build packages. Only the PCs used for building packages should be configured as follows:

[ShaderCompiler]
r.Shaders.WriteSymbols.Zip=0
 
[ShaderCompiler_BuildMachine] 
r.Shaders.WriteSymbols.Zip=1 

Thank you.