xref: /aosp_15_r20/external/skia/tests/sksl/shared/SwizzleByConstantIndex.metal (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
1#include <metal_stdlib>
2#include <simd/simd.h>
3#ifdef __clang__
4#pragma clang diagnostic ignored "-Wall"
5#endif
6using namespace metal;
7struct Uniforms {
8    half4 testInputs;
9    half4 colorGreen;
10    half4 colorRed;
11};
12struct Inputs {
13};
14struct Outputs {
15    half4 sk_FragColor [[color(0)]];
16};
17fragment Outputs fragmentMain(Inputs _in [[stage_in]], constant Uniforms& _uniforms [[buffer(0)]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) {
18    Outputs _out;
19    (void)_out;
20    half4 _0_v = _uniforms.testInputs;
21    half _1_x = _0_v.x;
22    half _2_y = _0_v.y;
23    half _3_z = _0_v.z;
24    half _4_w = _0_v.w;
25    half4 a = half4(_1_x, _2_y, _3_z, _4_w);
26    half _9_x = _uniforms.testInputs.x;
27    half _10_y = _uniforms.testInputs.y;
28    half _11_z = _uniforms.testInputs.z;
29    half _12_w = _uniforms.testInputs.w;
30    half4 b = half4(_9_x, _10_y, _11_z, _12_w);
31    half4 c = half4(0.0h, 1.0h, 2.0h, 3.0h);
32    _out.sk_FragColor = (all(a == half4(-1.25h, 0.0h, 0.75h, 2.25h)) && all(b == half4(-1.25h, 0.0h, 0.75h, 2.25h))) && all(c == half4(0.0h, 1.0h, 2.0h, 3.0h)) ? _uniforms.colorGreen : _uniforms.colorRed;
33    return _out;
34}
35