Skip to content

Commit

Permalink
Add a RayQuery::confirm_intersection function (#822)
Browse files Browse the repository at this point in the history
  • Loading branch information
expenses authored Dec 9, 2021
1 parent edd0a67 commit da7c3ed
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
18 changes: 16 additions & 2 deletions crates/spirv-std/src/ray_tracing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,16 +288,30 @@ 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]
pub unsafe fn terminate(&self) {
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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
1 change: 1 addition & 0 deletions tests/ui/arch/ray_query_terminate_khr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}

0 comments on commit da7c3ed

Please sign in to comment.