2021-03-16 14:40:11 +00:00
|
|
|
#include <metal_stdlib>
|
|
|
|
#include <simd/simd.h>
|
|
|
|
using namespace metal;
|
2021-03-15 18:58:57 +00:00
|
|
|
struct Uniforms {
|
2021-08-20 14:10:02 +00:00
|
|
|
float testInput;
|
|
|
|
float2x2 testMatrix2x2;
|
|
|
|
float4 colorGreen;
|
|
|
|
float4 colorRed;
|
2020-12-09 23:00:47 +00:00
|
|
|
};
|
2021-03-15 18:58:57 +00:00
|
|
|
struct Inputs {
|
|
|
|
};
|
2020-12-09 23:00:47 +00:00
|
|
|
struct Outputs {
|
|
|
|
float4 sk_FragColor [[color(0)]];
|
|
|
|
};
|
2021-08-20 14:10:02 +00:00
|
|
|
|
|
|
|
float4 float4_from_float2x2(float2x2 x) {
|
|
|
|
return float4(x[0].xy, x[1].xy);
|
|
|
|
}
|
2021-03-15 18:58:57 +00:00
|
|
|
fragment Outputs fragmentMain(Inputs _in [[stage_in]], constant Uniforms& _uniforms [[buffer(0)]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) {
|
2021-01-19 18:07:55 +00:00
|
|
|
Outputs _out;
|
2021-01-22 03:24:28 +00:00
|
|
|
(void)_out;
|
2021-08-20 14:10:02 +00:00
|
|
|
float4 input = float4_from_float2x2(_uniforms.testMatrix2x2) * float4(1.0, 1.0, -1.0, -1.0);
|
|
|
|
const uint4 expectedB = uint4(1065353216u, 1073741824u, 3225419776u, 3229614080u);
|
|
|
|
_out.sk_FragColor = ((as_type<uint>(input.x) == 1065353216u && all(as_type<uint2>(input.xy) == uint2(1065353216u, 1073741824u))) && all(as_type<uint3>(input.xyz) == uint3(1065353216u, 1073741824u, 3225419776u))) && all(as_type<uint4>(input) == expectedB) ? _uniforms.colorGreen : _uniforms.colorRed;
|
2021-01-19 18:07:55 +00:00
|
|
|
return _out;
|
2020-12-09 23:00:47 +00:00
|
|
|
}
|