[Migrated] Using `arch::ignore_intersection` causes shader compilation to fail
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 3.4k
- Forks
- 125
- PR merge metrics
- No merged PRs in 30d
Description
Issue automatically imported from old repo: https://github.com/EmbarkStudios/rust-gpu/issues/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(); }
}
}
- Use the above snippet in a shader crate
- 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`
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 by reproducing the failure with the provided any-hit shader snippet and compare it with the helper-function variant. Inspect the generated SPIR-V around the reported OpBranchConditional and use spirv-opt and spirv-val to identify why the direct ignore_intersection call produces an unstructured selection. Done means the original snippet compiles and passes SPIR-V validation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers, computer-graphics
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100