mirror of
https://github.com/EmbarkStudios/rust-gpu.git
synced 2024-11-22 06:45:13 +00:00
c3a9b9fd3e
* Accept `#[rust_gpu::spirv()]` attributes rather than `#[spirv()]` in backend * Implemented `#[spirv(..)]` proc macro attribute for all platforms that conditionally translates to `#[rust_gpu::spirv()]` based on platform * Changed `SpirvBuilder` to always apply `register_tool(rust_gpu)` attribute to shader crates * Updated docs * Added changelog
42 lines
731 B
Rust
42 lines
731 B
Rust
// build-pass
|
|
|
|
use spirv_std::spirv;
|
|
use spirv_std::{glam::Vec2, ByteAddressableBuffer};
|
|
|
|
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: &mut [u32],
|
|
out: &mut Nesty,
|
|
) {
|
|
unsafe {
|
|
let buf = ByteAddressableBuffer::new(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::new(buf);
|
|
buf.store(5, val);
|
|
}
|
|
}
|