Skip to content

Instantly share code, notes, and snippets.

@hasenbanck
Last active July 17, 2020 14:59
Show Gist options
  • Save hasenbanck/4bf7e5b34c1f5a397d88cb96dd20e54b to your computer and use it in GitHub Desktop.
Save hasenbanck/4bf7e5b34c1f5a397d88cb96dd20e54b to your computer and use it in GitHub Desktop.
layout(push_constant) uniform VertexConstants {
mat4 mvp;
} pc;
layout(push_constant) uniform FragmentConstants {
vec4 sun_color;
} pc;
// Init
let render_pipeline_layout =
device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
bind_group_layouts: &[&bind_group_layout],
push_constant_ranges: &[
wgpu::PushConstantRange {
stages: wgpu::ShaderStage::VERTEX,
range: 0..64,
},
wgpu::PushConstantRange {
stages: wgpu::ShaderStage::FRAGMENT,
range: 64..80,
},
],
});
// Draw
pass.set_push_constants(wgpu::ShaderStage::VERTEX, 0, vertex_push_constant);
pass.set_push_constants(wgpu::ShaderStage::FRAGMENT, 64, fragment_push_constant);
pass.draw(0..7, 0..1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment