[−][src]Macro geyser::shader
Creates a module containing a shader.
Note that this macro only works when placed outside of any scope.
This is useful for dealing with push constants.
- Example
use geyser::Cryo; //Use shader geyser::shader! { name: TestShader, src: " #version 450 layout(push_constant) uniform PushConstantData { int add; } pc; layout(set = 0, binding = 0) buffer Buf { int data[]; } buf; void main() { uint idx = gl_GlobalInvocationID.x; buf.data[idx] = idx + pc.add; } " } fn main() { // Initialize vulkan let cryo = Cryo::new(); // Create pipeline from the cryo and the shader previously created. let pipeline = compute_pipeline!{ cryo, TestShader }; // Create the push constant struct let pc = PushConstantData { add: 42, }; // Create a buffer let buf = cryo.buffer_from_data(vec![0; 200]); // Create a descriptor set pointing to the buffer let set = descriptor_set!([buf], pipeline); // Dispatch the shader pipeline.dispatch([200, 1, 1], set.clone(), pc); // Display the result buf.read().expect("Failed to read from buffer") .iter().enumerate().for_each(|(i, x)| println!("Index: {} equals: {}", i, *x)); }