microsoft / microsoft/DirectXShaderCompiler
`break` in shader causes ICE when compiled with -Od
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 3.7k
- Forks
- 900
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 44
Description
Description
I'm hitting error: cast<X>() argument of incompatible type! when compiling bevy's shaders (https://github.com/bevyengine/bevy) with DXC when doing debug builds. It compiles fine when not doing a debug build.
Steps to Reproduce
I apologize in advance for the huge ugly generated glob of HLSL, but I haven't been able to create a smaller reproduction.
https://godbolt.org/z/djhee9vns
Specifically it's the break on line 563 that causes the miscompilation, and it only happens when compiled with -Od.
If I remove the break and work around it by setting reflection_probe_index to light_probes.reflection_probe_count it compiles and works as expected (but is IMO an ugly workaround).
To reproduce this with bevy, you can clone bevy main (specifically commit 83d6600267f54faa9ead083516c9f42c16491ed5), run the pbr example with the WGPU_BACKEND environment variable set to dx12 and put both dxil.dll and dxcompiler.dll in the root of the repo (cargo run --example pbr with rust 1.75 or newer).
Actual Behavior
Shader fails to compile with error: cast<X>() argument of incompatible type!
Environment
- DXC version: dxcompiler.dll: 1.7 - 1.7.2308.7 (69e54e290); dxil.dll: 1.7(101.7.2308.12). Also happens on 1.6.2112, 1.7.2207, and trunk options on godbolt.
- Host Operating System: Windows 11 23H2, also on compiler explorer
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Godbolt reproduction and the break on line 563, comparing compilation with and without -Od. Then reproduce through Bevy's pbr example using the specified DXC files and DX12 backend. Done means the shader compiles without the incompatible cast<X>() error while retaining the expected behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100