xref: /aosp_15_r20/external/skia/tests/sksl/shared/ConstGlobal.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;
7constant const int SEVEN = 7;
8constant const int TEN = 10;
9constant const half4x4 MATRIXFIVE = half4x4(5.0h);
10struct Uniforms {
11    half4 colorGreen;
12    half4 colorRed;
13};
14struct Inputs {
15};
16struct Outputs {
17    half4 sk_FragColor [[color(0)]];
18};
19
20thread bool operator==(const half4x4 left, const half4x4 right);
21thread bool operator!=(const half4x4 left, const half4x4 right);
22thread bool operator==(const half4x4 left, const half4x4 right) {
23    return all(left[0] == right[0]) &&
24           all(left[1] == right[1]) &&
25           all(left[2] == right[2]) &&
26           all(left[3] == right[3]);
27}
28thread bool operator!=(const half4x4 left, const half4x4 right) {
29    return !(left == right);
30}
31bool verify_const_globals_biih44(int seven, int ten, half4x4 matrixFive) {
32    return (seven == 7 && ten == 10) && matrixFive == half4x4(5.0h);
33}
34fragment Outputs fragmentMain(Inputs _in [[stage_in]], constant Uniforms& _uniforms [[buffer(0)]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) {
35    Outputs _out;
36    (void)_out;
37    _out.sk_FragColor = verify_const_globals_biih44(SEVEN, TEN, MATRIXFIVE) ? _uniforms.colorGreen : _uniforms.colorRed;
38    return _out;
39}
40