mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-29 10:13:34 +00:00
36 lines
830 B
Plaintext
36 lines
830 B
Plaintext
// language: metal2.2
|
|
#include <metal_stdlib>
|
|
#include <simd/simd.h>
|
|
|
|
using metal::uint;
|
|
|
|
struct PushConstants {
|
|
uint index;
|
|
char _pad1[12];
|
|
metal::float2 double_;
|
|
};
|
|
struct FragmentIn {
|
|
metal::float4 color;
|
|
uint primitive_index;
|
|
};
|
|
|
|
struct main_Input {
|
|
metal::float4 color [[user(loc0), center_perspective]];
|
|
};
|
|
struct main_Output {
|
|
metal::float4 member [[color(0)]];
|
|
};
|
|
fragment main_Output main_(
|
|
main_Input varyings [[stage_in]]
|
|
, uint primitive_index [[primitive_id]]
|
|
, constant PushConstants& pc [[buffer(1)]]
|
|
) {
|
|
const FragmentIn in = { varyings.color, primitive_index };
|
|
uint _e4 = pc.index;
|
|
if (in.primitive_index == _e4) {
|
|
return main_Output { in.color };
|
|
} else {
|
|
return main_Output { metal::float4(metal::float3(1.0) - in.color.xyz, in.color.w) };
|
|
}
|
|
}
|