From 8efc4220ae1046622983ca2f028d066c5d0e19b3 Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Tue, 25 Oct 2022 03:55:26 +0300 Subject: [PATCH] spirv_std::ray_tracing: use actual `OpTypeBool` for `-> bool` intrinsics. --- crates/spirv-std/src/ray_tracing.rs | 31 +++++++++++++++++------------ 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/crates/spirv-std/src/ray_tracing.rs b/crates/spirv-std/src/ray_tracing.rs index deb72c5f44..1998e0078b 100644 --- a/crates/spirv-std/src/ray_tracing.rs +++ b/crates/spirv-std/src/ray_tracing.rs @@ -724,17 +724,19 @@ impl RayQuery { #[doc(alias = "OpRayQueryGetIntersectionFrontFaceKHR")] #[inline] pub unsafe fn get_candidate_intersection_front_face(&self) -> bool { - let result: u32; + let mut result = false; asm! { + "%bool = OpTypeBool", "%u32 = OpTypeInt 32 0", "%intersection = OpConstant %u32 0", - "{result} = OpRayQueryGetIntersectionFrontFaceKHR %u32 {ray_query} %intersection", + "%result = OpRayQueryGetIntersectionFrontFaceKHR %bool {ray_query} %intersection", + "OpStore {result} %result", ray_query = in(reg) self, - result = out(reg) result, + result = in(reg) &mut result, } - result != 0 + result } /// Returns whether the current intersection considered in a ray query was with @@ -749,17 +751,19 @@ impl RayQuery { #[doc(alias = "OpRayQueryGetIntersectionFrontFaceKHR")] #[inline] pub unsafe fn get_committed_intersection_front_face(&self) -> bool { - let result: u32; + let mut result = false; asm! { + "%bool = OpTypeBool", "%u32 = OpTypeInt 32 0", "%intersection = OpConstant %u32 1", - "{result} = OpRayQueryGetIntersectionFrontFaceKHR %u32 {ray_query} %intersection", + "%result = OpRayQueryGetIntersectionFrontFaceKHR %bool {ray_query} %intersection", + "OpStore {result} %result", ray_query = in(reg) self, - result = out(reg) result, + result = in(reg) &mut result, } - result != 0 + result } /// Returns whether a candidate intersection considered in a ray query was with @@ -768,16 +772,17 @@ impl RayQuery { #[doc(alias = "OpRayQueryGetIntersectionCandidateAABBOpaqueKHR")] #[inline] pub unsafe fn get_intersection_candidate_aabb_opaque(&self) -> bool { - let result: u32; + let mut result = false; asm! { - "%u32 = OpTypeInt 8 0", - "{result} = OpRayQueryGetIntersectionCandidateAABBOpaqueKHR %u32 {ray_query}", + "%bool = OpTypeBool", + "%result = OpRayQueryGetIntersectionCandidateAABBOpaqueKHR %bool {ray_query}", + "OpStore {result} %result", ray_query = in(reg) self, - result = out(reg) result, + result = in(reg) &mut result, } - result != 0 + result } /// Gets the object-space ray direction for the current intersection considered