From da7c3ed71f27d67e05c0d2a4d3c839db14daf1f8 Mon Sep 17 00:00:00 2001 From: Ashley Date: Thu, 9 Dec 2021 14:00:35 +0100 Subject: [PATCH] Add a RayQuery::confirm_intersection function (#822) --- crates/spirv-std/src/ray_tracing.rs | 18 ++++++++++++++++-- ...s => ray_query_confirm_intersection_khr.rs} | 1 + tests/ui/arch/ray_query_terminate_khr.rs | 1 + 3 files changed, 18 insertions(+), 2 deletions(-) rename tests/ui/arch/{ray_query_proceed_khr.rs => ray_query_confirm_intersection_khr.rs} (92%) diff --git a/crates/spirv-std/src/ray_tracing.rs b/crates/spirv-std/src/ray_tracing.rs index c1e6ccc729..1d878ebcdf 100644 --- a/crates/spirv-std/src/ray_tracing.rs +++ b/crates/spirv-std/src/ray_tracing.rs @@ -288,9 +288,9 @@ impl RayQuery { } /// Terminates further execution of a ray query; further calls to - /// [`Self::proceed`] will return `false`.The value returned by any prior + /// [`Self::proceed`] will return `false`. The value returned by any prior /// execution of [`Self::proceed`] with the same ray query object must have - /// been true. Refer to the client API specification for more details. + /// been true. #[spirv_std_macros::gpu_only] #[doc(alias = "OpRayQueryTerminateKHR")] #[inline] @@ -298,6 +298,20 @@ impl RayQuery { asm!("OpRayQueryTerminateKHR {}", in(reg) self) } + /// Confirms a triangle intersection to be included in the determination + /// of the closest hit for a ray query. + /// + /// [`Self::proceed()`] must have been called on this object, and it must + /// have returned true. The current intersection candidate must have a + /// [`Self::get_candidate_intersection_type()`] of + /// [`CandidateIntersection::Triangle`]. + #[spirv_std_macros::gpu_only] + #[doc(alias = "OpRayQueryConfirmIntersectionKHR")] + #[inline] + pub unsafe fn confirm_intersection(&self) { + asm!("OpRayQueryConfirmIntersectionKHR {}", in(reg) self) + } + /// Returns the type of the current candidate intersection. /// /// [`Self::proceed()`] must have been called on this object, and it must have returned true. diff --git a/tests/ui/arch/ray_query_proceed_khr.rs b/tests/ui/arch/ray_query_confirm_intersection_khr.rs similarity index 92% rename from tests/ui/arch/ray_query_proceed_khr.rs rename to tests/ui/arch/ray_query_confirm_intersection_khr.rs index bd8f11e11e..35a8b08d1f 100644 --- a/tests/ui/arch/ray_query_proceed_khr.rs +++ b/tests/ui/arch/ray_query_confirm_intersection_khr.rs @@ -10,5 +10,6 @@ pub fn main(#[spirv(descriptor_set = 0, binding = 0)] accel: &AccelerationStruct spirv_std::ray_query!(let mut handle); handle.initialize(accel, RayFlags::NONE, 0, Vec3::ZERO, 0.0, Vec3::ZERO, 0.0); assert!(handle.proceed()); + handle.confirm_intersection(); } } diff --git a/tests/ui/arch/ray_query_terminate_khr.rs b/tests/ui/arch/ray_query_terminate_khr.rs index bf33246a58..af3fb0ea4e 100644 --- a/tests/ui/arch/ray_query_terminate_khr.rs +++ b/tests/ui/arch/ray_query_terminate_khr.rs @@ -9,6 +9,7 @@ pub fn main(#[spirv(descriptor_set = 0, binding = 0)] accel: &AccelerationStruct unsafe { spirv_std::ray_query!(let mut handle); handle.initialize(accel, RayFlags::NONE, 0, Vec3::ZERO, 0.0, Vec3::ZERO, 0.0); + assert!(handle.proceed()); handle.terminate(); } }