mirror of
https://github.com/gfx-rs/wgpu.git
synced 2025-02-27 14:23:40 +00:00

Push constants need to be configured by the consumer which must pass the bind target of the constant buffer used for the push constants.
22 lines
432 B
WebGPU Shading Language
22 lines
432 B
WebGPU Shading Language
struct PushConstants {
|
|
multiplier: f32
|
|
}
|
|
var<push_constant> pc: PushConstants;
|
|
|
|
struct FragmentIn {
|
|
@location(0) color: vec4<f32>
|
|
}
|
|
|
|
@vertex
|
|
fn vert_main(
|
|
@location(0) pos : vec2<f32>,
|
|
@builtin(vertex_index) vi: u32,
|
|
) -> @builtin(position) vec4<f32> {
|
|
return vec4<f32>(f32(vi) * pc.multiplier * pos, 0.0, 1.0);
|
|
}
|
|
|
|
@fragment
|
|
fn main(in: FragmentIn) -> @location(0) vec4<f32> {
|
|
return in.color * pc.multiplier;
|
|
}
|