Skip to content

Commit

Permalink
[spirv] Stop naga causing undefined behavior in `rayQueryGet*Intersec…
Browse files Browse the repository at this point in the history
…tion` (#6752)

Co-authored-by: Connor Fitzgerald <[email protected]>
  • Loading branch information
Vecvec and cwfitzgerald authored Jan 17, 2025
1 parent d5d5157 commit bdef8c0
Show file tree
Hide file tree
Showing 11 changed files with 914 additions and 376 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ Bottom level categories:

## Unreleased

### Bug Fixes

#### Vulkan

- Stop naga causing undefined behavior when a ray query misses. By @Vecvec in [#6752](https://github.com/gfx-rs/wgpu/pull/6752).

### Changes

#### Refactored internal trace path parameter
Expand Down
15 changes: 14 additions & 1 deletion naga/src/back/spv/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1736,7 +1736,20 @@ impl BlockContext<'_> {
}
crate::Expression::ArrayLength(expr) => self.write_runtime_array_length(expr, block)?,
crate::Expression::RayQueryGetIntersection { query, committed } => {
self.write_ray_query_get_intersection(query, block, committed)
let query_id = self.cached[query];
let func_id = self
.writer
.write_ray_query_get_intersection_function(committed, self.ir_module);
let ray_intersection = self.ir_module.special_types.ray_intersection.unwrap();
let intersection_type_id = self.get_type_id(LookupType::Handle(ray_intersection));
let id = self.gen_id();
block.body.push(Instruction::function_call(
intersection_type_id,
id,
func_id,
&[query_id],
));
id
}
};

Expand Down
2 changes: 2 additions & 0 deletions naga/src/back/spv/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,8 @@ pub struct Writer {

// Just a temporary list of SPIR-V ids
temp_list: Vec<Word>,

ray_get_intersection_function: Option<Word>,
}

bitflags::bitflags! {
Expand Down
Loading

0 comments on commit bdef8c0

Please sign in to comment.