mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-22 07:21:04 +01:00
32 lines
769 B
Plaintext
32 lines
769 B
Plaintext
// language: metal2.2
|
|
#include <metal_stdlib>
|
|
#include <simd/simd.h>
|
|
|
|
struct PushConstants {
|
|
metal::uint index;
|
|
char _pad1[12];
|
|
metal::float2 double1;
|
|
};
|
|
struct FragmentIn {
|
|
metal::float4 color;
|
|
metal::uint primitive_index;
|
|
};
|
|
|
|
struct main1Input {
|
|
metal::float4 color [[user(loc0), center_perspective]];
|
|
};
|
|
struct main1Output {
|
|
metal::float4 member [[color(0)]];
|
|
};
|
|
fragment main1Output main1(
|
|
main1Input varyings [[stage_in]]
|
|
, metal::uint primitive_index [[primitive_id]]
|
|
) {
|
|
const FragmentIn in = { varyings.color, primitive_index };
|
|
if ((in.primitive_index % 2u) == 0u) {
|
|
return main1Output { in.color };
|
|
} else {
|
|
return main1Output { metal::float4(metal::float3(1.0) - in.color.xyz, in.color.w) };
|
|
}
|
|
}
|