@@ -11,18 +11,41 @@ pub use barrier::{control_barrier, memory_barrier};
1111pub use spirv_std:: arch:: * ;
1212
1313use crate :: glam:: UVec2 ;
14+ #[ cfg( target_arch = "spirv" ) ]
15+ use core:: arch:: asm;
1416use spirv_std:: memory:: Scope ;
1517
1618/// See [`spirv_std::arch::read_clock_khr`]
1719#[ spirv_std_macros:: gpu_only]
1820#[ doc( alias = "OpReadClockKHR" ) ]
1921pub fn read_clock_khr < const SCOPE : Scope > ( ) -> u64 {
20- spirv_std:: arch:: read_clock_khr :: < { SCOPE as u32 } > ( )
22+ unsafe {
23+ let mut result: u64 ;
24+ asm ! {
25+ "%uint = OpTypeInt 32 0" ,
26+ "%scope = OpConstant %uint {scope}" ,
27+ "{result} = OpReadClockKHR typeof*{result} %scope" ,
28+ result = out( reg) result,
29+ scope = const SCOPE as u32 ,
30+ } ;
31+ result
32+ }
2133}
2234
2335/// See [`spirv_std::arch::read_clock_uvec2_khr`]
2436#[ spirv_std_macros:: gpu_only]
2537#[ doc( alias = "OpReadClockKHR" ) ]
2638pub fn read_clock_uvec2_khr < const SCOPE : Scope > ( ) -> UVec2 {
27- spirv_std:: arch:: read_clock_uvec2_khr :: < { SCOPE as u32 } > ( )
39+ unsafe {
40+ let mut result = UVec2 :: default ( ) ;
41+ asm ! {
42+ "%uint = OpTypeInt 32 0" ,
43+ "%scope = OpConstant %uint {scope}" ,
44+ "%result = OpReadClockKHR typeof*{result} %scope" ,
45+ "OpStore {result} %result" ,
46+ result = in( reg) & mut result,
47+ scope = const SCOPE as u32 ,
48+ } ;
49+ result
50+ }
2851}
0 commit comments