Add a RayQuery::confirm_intersection function (#822)

This commit is contained in:
Ashley 2021-12-09 14:00:35 +01:00 committed by GitHub
parent edd0a67392
commit da7c3ed71f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 2 deletions

View File

@ -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.

View File

@ -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();
}
}

View File

@ -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();
}
}