Unity Issue Tracker - Compiled Shader code has self-assignments and redundant code in the Shaders that use "enable_d3d11_debug_symbols"
Closed
UUM-89984
Compiled Shader code has self-assignments and redundant code in the Shaders that use "enable_d3d11_debug_symbols"
Unity: Shader System
As Designed
6.1.X
6.0.X
2022.3.X
2021.3.X
Turning on debug symbols also turns off all compiler optimizations.
It is expected that the resulting code is different.
How to reproduce:
1. Open the attached “IN-89929.zip” project
2. Select the “NewUnlitShader” Shader Asset in the Project window
3. In the Inspector expand the “Compile and show code” Dropdown button
4. Select the “Metal” option in the Dropdown
5. Press the “Compile and show Code” Button in the Inspector
6. Observe the generated code
Excepted results: Compiled Shader code has no issues
Actual results: Shader has self assignments, such as ‘u_xlat0 = u_xlat0;'
Reproducible on: Windows 11, Windows 10 (user’s)
Not reproducible on: macOS 15.1.1 (Intel)
Notes:
Reporter noted that changing Target Platform to Switch reproduces the issue, but targeting Windows Standalone doesn’t reproduce the issue, however during testing this was not observed issue was always reproducible regardless of Build Target, but using the “Current Build Platform” option in the “Compile and show code” will accordingly show results. If macOS is the Target Platform the issue is reproducible, if the Target Platform is Windows it will not reproduce the issue.
Reproducible with Graphics Platforms: GLES3x, Metal, OpenGLCore
Not reproducible with Graphics Platforms: D3D, Vulkan, WebGPU
Prioritise and Follow this issue
Have a workaround or additional info about this issue?