skia2/tests/sksl/shared/UniformArray.metal
John Stiles e5d4c43561 Add SkSL test for uniform arrays.
These weren't used anywhere in our test suite.

Change-Id: I35e8607ad2dbddf8f403668bd2b2636a8964d304
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/455777
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-10-05 13:25:00 +00:00

26 lines
711 B
Metal

#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct Uniforms {
array<float, 5> testArray;
float4 colorGreen;
float4 colorRed;
};
struct Inputs {
};
struct Outputs {
float4 sk_FragColor [[color(0)]];
};
fragment Outputs fragmentMain(Inputs _in [[stage_in]], constant Uniforms& _uniforms [[buffer(0)]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) {
Outputs _out;
(void)_out;
for (int index = 0;index < 5; ++index) {
if (_uniforms.testArray[index] != float(index + 1)) {
_out.sk_FragColor = _uniforms.colorRed;
return _out;
}
}
_out.sk_FragColor = _uniforms.colorGreen;
return _out;
}