mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-23 23:34:29 +00:00
602368d9f0
* Hack in support for PrimitiveID on Vulkan * Rename to PrimitiveIndex and add preliminary support for GLSL, HLSL and MSL * Implement as an extra WGSL built-in * Update extra.wgsl outputs * Run rustfmt; fix WGSL writer * Add rustfmt changes I forgot * Update extra.wgsl test output for WGSL fix * Bump macOS version to 10.15 in validate-msl to support primitive_index
21 lines
462 B
WebGPU Shading Language
21 lines
462 B
WebGPU Shading Language
[[block]]
|
|
struct PushConstants {
|
|
index: u32;
|
|
double: vec2<f64>;
|
|
};
|
|
var<push_constant> pc: PushConstants;
|
|
|
|
struct FragmentIn {
|
|
[[location(0)]] color: vec4<f32>;
|
|
[[builtin(primitive_index)]] primitive_index: u32;
|
|
};
|
|
|
|
[[stage(fragment)]]
|
|
fn main(in: FragmentIn) -> [[location(0)]] vec4<f32> {
|
|
if (in.primitive_index % 2u == 0u) {
|
|
return in.color;
|
|
} else {
|
|
return vec4<f32>(vec3<f32>(1.0) - in.color.rgb, in.color.a);
|
|
}
|
|
}
|