blob: 16aad7fa52b8379e065b1e484fcd460f272a2d88 [file] [log] [blame]
Michael Ludwigbf58add2021-03-16 10:40:11 -04001#include <metal_stdlib>
2#include <simd/simd.h>
3using namespace metal;
John Stiles639e8122021-05-24 10:52:23 -04004struct Uniforms {
John Stilesed2baba2021-09-20 19:09:13 -04005 float4 colorGreen;
6 float4 colorRed;
John Stiles639e8122021-05-24 10:52:23 -04007};
John Stilesaeae3a52020-09-25 13:35:58 -04008struct Inputs {
9};
10struct Outputs {
11 float4 sk_FragColor [[color(0)]];
12};
John Stiles639e8122021-05-24 10:52:23 -040013fragment Outputs fragmentMain(Inputs _in [[stage_in]], constant Uniforms& _uniforms [[buffer(0)]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) {
John Stilesf7410bd2021-01-19 13:07:55 -050014 Outputs _out;
John Stiles37279172021-01-21 22:24:28 -050015 (void)_out;
John Stilesed2baba2021-09-20 19:09:13 -040016 float4 color;
17 switch (int(_uniforms.colorGreen.y)) {
John Stilesaeae3a52020-09-25 13:35:58 -040018 case 0:
John Stilesed2baba2021-09-20 19:09:13 -040019 color = _uniforms.colorRed;
John Stilesd288d8b2021-09-20 21:56:26 +000020 break;
John Stilesaeae3a52020-09-25 13:35:58 -040021 case 1:
John Stilesed2baba2021-09-20 19:09:13 -040022 color = _uniforms.colorGreen;
John Stilesd288d8b2021-09-20 21:56:26 +000023 break;
John Stilesaeae3a52020-09-25 13:35:58 -040024 default:
John Stilesed2baba2021-09-20 19:09:13 -040025 color = _uniforms.colorRed;
26 break;
John Stilesaeae3a52020-09-25 13:35:58 -040027 }
John Stilesed2baba2021-09-20 19:09:13 -040028 _out.sk_FragColor = color;
John Stilesf7410bd2021-01-19 13:07:55 -050029 return _out;
John Stilesaeae3a52020-09-25 13:35:58 -040030}