mirror of
https://github.com/Rust-GPU/rust-gpu.git
synced 2026-06-08 02:29:51 +09: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
39 lines
752 B
Rust
39 lines
752 B
Rust
// build-pass
|
|
|
|
use spirv_std::spirv;
|
|
use spirv_std::{glam::Vec4, ByteAddressableBuffer};
|
|
|
|
#[spirv(matrix)]
|
|
pub struct Mat4 {
|
|
x: Vec4,
|
|
y: Vec4,
|
|
z: Vec4,
|
|
w: Vec4,
|
|
}
|
|
|
|
#[spirv(fragment)]
|
|
pub fn load(
|
|
#[spirv(descriptor_set = 0, binding = 0, storage_buffer)] buf: &mut [u32],
|
|
out: &mut Vec4,
|
|
outmat: &mut Mat4,
|
|
) {
|
|
unsafe {
|
|
let buf = ByteAddressableBuffer::new(buf);
|
|
*out = buf.load(5);
|
|
*outmat = buf.load(5);
|
|
}
|
|
}
|
|
|
|
#[spirv(fragment)]
|
|
pub fn store(
|
|
#[spirv(descriptor_set = 0, binding = 0, storage_buffer)] buf: &mut [u32],
|
|
val: Vec4,
|
|
valmat: Mat4,
|
|
) {
|
|
unsafe {
|
|
let mut buf = ByteAddressableBuffer::new(buf);
|
|
buf.store(5, val);
|
|
buf.store(5, valmat);
|
|
}
|
|
}
|