skia2/tests/sksl/shared/Matrices.metal
John Stiles 56233d1379 Migrate matrix SkSL test to dm.
This uncovered a bug in Metal code generation of `matX *= matY` which is
now fixed. (It was emitting the helper function more than once.)

Change-Id: I0aeb0efe7ab5fbf5592a8ca6f4f5b50354d3d7f4
Bug: skia:11262
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/365489
Commit-Queue: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-02-03 20:42:57 +00:00

41 lines
1.2 KiB
Metal

#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct Uniforms {
float4 colorGreen;
float4 colorRed;
};
struct Inputs {
};
struct Outputs {
float4 sk_FragColor [[color(0)]];
};
thread float2x2& operator*=(thread float2x2& left, thread const float2x2& right) {
left = left * right;
return left;
}
fragment Outputs fragmentMain(Inputs _in [[stage_in]], constant Uniforms& _uniforms [[buffer(0)]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) {
Outputs _out;
(void)_out;
float2x2 _1_m3 = float2x2(float2(1.0, 2.0), float2(3.0, 4.0));
_1_m3 *= float2x2(1.0);
float2x2 _2_m5 = float2x2(float2x2(float2(1.0, 2.0), float2(3.0, 4.0))[0].x);
float2x2 _3_m6 = float2x2(float2(1.0, 2.0), float2(3.0, 4.0));
_3_m6 += _2_m5;
float4x4 _4_m11 = float4x4(2.0);
_4_m11 -= float4x4(1.0);
float2x2 _6_m3 = float2x2(float2(1.0, 2.0), float2(3.0, 4.0));
_6_m3 *= float2x2(1.0);
float2x2 _7_m5 = float2x2(float2x2(float2(1.0, 2.0), float2(3.0, 4.0))[0].x);
float2x2 _8_m6 = float2x2(float2(1.0, 2.0), float2(3.0, 4.0));
_8_m6 += _7_m5;
float4x4 _9_m11 = float4x4(2.0);
_9_m11 -= float4x4(1.0);
_out.sk_FragColor = _uniforms.colorGreen;
return _out;
}