#[cfg(target_arch = "spirv")]
use core::arch::asm;
use core::marker::PhantomData;
#[spirv(runtime_array)]
pub struct RuntimeArray<T> {
_do_not_touch: u32,
_phantom: PhantomData<T>,
}
impl<T> RuntimeArray<T> {
#[spirv_std_macros::gpu_only]
pub unsafe fn index(&self, index: usize) -> &T {
asm! {
"%result = OpAccessChain _ {arr} {index}",
"OpReturnValue %result",
arr = in(reg) self,
index = in(reg) index,
options(noreturn),
}
}
#[spirv_std_macros::gpu_only]
pub unsafe fn index_mut(&mut self, index: usize) -> &mut T {
asm! {
"%result = OpAccessChain _ {arr} {index}",
"OpReturnValue %result",
arr = in(reg) self,
index = in(reg) index,
options(noreturn),
}
}
}