Skip to content

Commit da7c3ed

Browse files
authored
Add a RayQuery::confirm_intersection function (#822)
1 parent edd0a67 commit da7c3ed

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

crates/spirv-std/src/ray_tracing.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,16 +288,30 @@ impl RayQuery {
288288
}
289289

290290
/// Terminates further execution of a ray query; further calls to
291-
/// [`Self::proceed`] will return `false`.The value returned by any prior
291+
/// [`Self::proceed`] will return `false`. The value returned by any prior
292292
/// execution of [`Self::proceed`] with the same ray query object must have
293-
/// been true. Refer to the client API specification for more details.
293+
/// been true.
294294
#[spirv_std_macros::gpu_only]
295295
#[doc(alias = "OpRayQueryTerminateKHR")]
296296
#[inline]
297297
pub unsafe fn terminate(&self) {
298298
asm!("OpRayQueryTerminateKHR {}", in(reg) self)
299299
}
300300

301+
/// Confirms a triangle intersection to be included in the determination
302+
/// of the closest hit for a ray query.
303+
///
304+
/// [`Self::proceed()`] must have been called on this object, and it must
305+
/// have returned true. The current intersection candidate must have a
306+
/// [`Self::get_candidate_intersection_type()`] of
307+
/// [`CandidateIntersection::Triangle`].
308+
#[spirv_std_macros::gpu_only]
309+
#[doc(alias = "OpRayQueryConfirmIntersectionKHR")]
310+
#[inline]
311+
pub unsafe fn confirm_intersection(&self) {
312+
asm!("OpRayQueryConfirmIntersectionKHR {}", in(reg) self)
313+
}
314+
301315
/// Returns the type of the current candidate intersection.
302316
///
303317
/// [`Self::proceed()`] must have been called on this object, and it must have returned true.

tests/ui/arch/ray_query_proceed_khr.rs renamed to tests/ui/arch/ray_query_confirm_intersection_khr.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@ pub fn main(#[spirv(descriptor_set = 0, binding = 0)] accel: &AccelerationStruct
1010
spirv_std::ray_query!(let mut handle);
1111
handle.initialize(accel, RayFlags::NONE, 0, Vec3::ZERO, 0.0, Vec3::ZERO, 0.0);
1212
assert!(handle.proceed());
13+
handle.confirm_intersection();
1314
}
1415
}

tests/ui/arch/ray_query_terminate_khr.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ pub fn main(#[spirv(descriptor_set = 0, binding = 0)] accel: &AccelerationStruct
99
unsafe {
1010
spirv_std::ray_query!(let mut handle);
1111
handle.initialize(accel, RayFlags::NONE, 0, Vec3::ZERO, 0.0, Vec3::ZERO, 0.0);
12+
assert!(handle.proceed());
1213
handle.terminate();
1314
}
1415
}

0 commit comments

Comments
 (0)