rust-gpu icon indicating copy to clipboard operation
rust-gpu copied to clipboard

Using `arch::ignore_intersection` causes shader compilation to fail

Open Steelbirdy opened this issue 1 year ago • 1 comments

Expected Behaviour

Shader crate successfully compiles

Example & Steps To Reproduce

#[spirv(any_hit)]
pub fn my_any_hit() {
    let p = Vec3A::ZERO;
    if p.length_squared() < 1e-3 {
        unsafe { spirv_std::arch::ignore_intersection(); }
    }
}
  1. Use the above snippet in a shader crate
  2. Compilation fails

Replacing this with the below snippet causes it to compile.

#[spirv(any_hit)]
pub fn my_any_hit() {
    let p = Vec3A::ZERO;
    if p.length_squared() < 1e-3 {
        my_ignore_intersection();
    }
}

#[inline(never)]
fn my_ignore_intersection() {
    unsafe { spirv_std::arch::ignore_intersection(); }
}

System Info

  • Rust: 1.71.0-nightly (1a5f8bce7 2023-05-26)
  • OS: Windows 11
  • GPU: NVIDIA RTX 3060 Ti

Backtrace

Backtrace

  error: Selection must be structured
           OpBranchConditional %1274 %1275 %1276
    |
    = note: module `C:\Users\Pat\CLionProjects\rayven_gpu2\target\spirv-builder\spirv-unknown-vulkan1.2\release\deps\shader.spv`

  warning: an unknown error occurred
    |
    = note: spirv-opt failed, leaving as unoptimized
    = note: module `C:\Users\Pat\CLionProjects\rayven_gpu2\target\spirv-builder\spirv-unknown-vulkan1.2\release\deps\shader.spv`

  error: error:0:0 - Selection must be structured
           OpBranchConditional %1274 %1275 %1276
    |
    = note: spirv-val failed
    = note: module `C:\Users\Pat\CLionProjects\rayven_gpu2\target\spirv-builder\spirv-unknown-vulkan1.2\release\deps\shader.spv`

Steelbirdy avatar Nov 13 '23 21:11 Steelbirdy