mirror of
https://github.com/EmbarkStudios/rust-gpu.git
synced 2025-05-03 05:37:24 +00:00

* 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
27 lines
603 B
Rust
27 lines
603 B
Rust
// build-pass
|
|
|
|
use spirv_std::spirv;
|
|
use spirv_std::ByteAddressableBuffer;
|
|
|
|
pub struct EmptyStruct {}
|
|
|
|
#[spirv(fragment)]
|
|
pub fn load(
|
|
#[spirv(descriptor_set = 0, binding = 0, storage_buffer)] buf: &mut [u32],
|
|
#[spirv(flat)] out: &mut EmptyStruct,
|
|
) {
|
|
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]) {
|
|
let val = EmptyStruct {};
|
|
unsafe {
|
|
let mut buf = ByteAddressableBuffer::new(buf);
|
|
buf.store(5, val);
|
|
}
|
|
}
|