-
Notifications
You must be signed in to change notification settings - Fork 108
Expand file tree
/
Copy pathcomplex.rs
More file actions
52 lines (46 loc) · 997 Bytes
/
complex.rs
File metadata and controls
52 lines (46 loc) · 997 Bytes
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// build-pass
use spirv_std::spirv;
use spirv_std::{ByteAddressableBuffer, glam::Vec2};
pub struct Complex {
x: u32,
y: f32,
n: Nesty,
v: Vec2,
a: [f32; 7],
m: [Nesty; 2],
}
pub struct Nesty {
x: f32,
y: f32,
z: f32,
}
#[spirv(fragment)]
pub fn load(
#[spirv(descriptor_set = 0, binding = 0, storage_buffer)] buf: &[u32],
out: &mut Nesty,
) {
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 Nesty,
) {
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],
val: Nesty,
) {
unsafe {
let mut buf = ByteAddressableBuffer::from_mut_slice(buf);
buf.store(5, val);
}
}