Skip to content

[Migrated] Using arch::ignore_intersection causes shader compilation to fail #67

Open
@rust-gpu-bot

Description

@rust-gpu-bot

Issue automatically imported from old repo: EmbarkStudios/rust-gpu#1099
Old labels: t: bug
Originally creatd by Steelbirdy on 2023-11-13T21:07:54Z


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`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions