forked from Rust-GPU/rust-gpu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharr.rs
37 lines (33 loc) · 852 Bytes
/
arr.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// build-pass
use spirv_std::spirv;
use spirv_std::{glam::Vec4, ByteAddressableBuffer};
#[spirv(fragment)]
pub fn load(
#[spirv(descriptor_set = 0, binding = 0, storage_buffer)] buf: &[u32],
out: &mut [i32; 4],
) {
unsafe {
let buf = ByteAddressableBuffer::from_slice(buf);
*out = buf.load(5);
}
}
#[spirv(fragment)]
pub fn load_mut(
#[spirv(descriptor_set = 0, binding = 0, storage_buffer)] buf: &mut [u32],
out: &mut [i32; 4],
) {
unsafe {
let buf = ByteAddressableBuffer::from_mut_slice(buf);
*out = buf.load(5);
}
}
#[spirv(fragment)]
pub fn store(
#[spirv(descriptor_set = 0, binding = 0, storage_buffer)] buf: &mut [u32],
#[spirv(flat)] val: [i32; 4],
) {
unsafe {
let mut buf = ByteAddressableBuffer::from_mut_slice(buf);
buf.store(5, val);
}
}