wgpu/tests/in/push-constants.wgsl
João Capucho 9df243c42c
hlsl-out: Add support for push constants (#2005)
Push constants need to be configured by the consumer which must pass the
bind target of the constant buffer used for the push constants.
2022-08-29 11:58:02 +01:00

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;
}