-
Notifications
You must be signed in to change notification settings - Fork 106
Expand file tree
/
Copy pathspirv_vector_macro.rs
More file actions
33 lines (30 loc) · 974 Bytes
/
spirv_vector_macro.rs
File metadata and controls
33 lines (30 loc) · 974 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
// build-pass
// only-vulkan1.2
// compile-flags: -C target-feature=+GroupNonUniform,+GroupNonUniformShuffleRelative,+ext:SPV_KHR_vulkan_memory_model
// compile-flags: -C llvm-args=--disassemble
// normalize-stderr-test "OpSource .*\n" -> ""
// normalize-stderr-test "OpLine .*\n" -> ""
// normalize-stderr-test "%\d+ = OpString .*\n" -> ""
use spirv_std::arch::subgroup_shuffle_up;
use spirv_std::glam::Vec3;
use spirv_std::spirv;
#[spirv_std::spirv_vector]
#[derive(Copy, Clone, Default)]
pub struct MyColor {
pub r: f32,
pub g: f32,
pub b: f32,
}
#[spirv(compute(threads(32)))]
pub fn main(
#[spirv(storage_buffer, descriptor_set = 0, binding = 0)] input: &Vec3,
#[spirv(storage_buffer, descriptor_set = 0, binding = 1)] output: &mut MyColor,
) {
let color = MyColor {
r: input.x,
g: input.y,
b: input.z,
};
// any function that accepts a `VectorOrScalar` would do
*output = subgroup_shuffle_up(color, 5);
}