Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add RayQuery::confirm_intersection #822

Merged
merged 1 commit into from
Dec 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Copy link
Contributor Author

@expenses expenses Dec 9, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed this line just because it wasn't consistent with the rest of the docs and seems to have just been copied from https:/KhronosGroup/SPIRV-Registry/blob/main/extensions/KHR/SPV_KHR_ray_query.asciidoc.

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