Skip to content

break in shader causes ICE when compiled with -Od #6183

@Elabajaba

Description

@Elabajaba

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 (69e54e2); 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugBug, regression, crashcrashDXC crashing or hitting an assert

    Type

    No type

    Projects

    Status

    Triaged

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions