#[cfg(target_arch = "spirv")]
use core::arch::asm;
#[spirv_std_macros::gpu_only]
#[doc(alias = "OpReportIntersectionKHR")]
#[inline]
pub unsafe fn report_intersection(hit: f32, hit_kind: u32) -> bool {
unsafe {
let mut result = false;
asm! {
"%bool = OpTypeBool",
"%result = OpReportIntersectionKHR %bool {hit} {hit_kind}",
"OpStore {result} %result",
result = in(reg) &mut result,
hit = in(reg) hit,
hit_kind = in(reg) hit_kind,
};
result
}
}
#[spirv_std_macros::gpu_only]
#[doc(alias = "OpIgnoreIntersectionKHR")]
#[inline]
pub unsafe fn ignore_intersection() -> ! {
unsafe {
asm!("OpIgnoreIntersectionKHR", options(noreturn));
}
}
#[spirv_std_macros::gpu_only]
#[doc(alias = "OpTerminateRayKHR")]
#[inline]
pub unsafe fn terminate_ray() -> ! {
unsafe {
asm!("OpTerminateRayKHR", options(noreturn));
}
}
#[spirv_std_macros::gpu_only]
#[doc(alias = "OpExecuteCallableKHR")]
#[inline]
pub unsafe fn execute_callable<T, const ID: usize>(data: &T) {
unsafe {
asm! {
"%u32 = OpTypeInt 32 0",
"%id = OpConstant %u32 {id}",
"OpExecuteCallableKHR %id {data}",
id = const ID,
data = in(reg) data,
};
}
}