skia2/tests/sksl/intrinsics/golden/MatrixCompMult.metal
John Stiles d06d4a983f Fix matrixCompMult halfNxM implementation and add unit tests.
The existing code didn't work properly with half types since the $mat
type encompassed both halfNxM and floatNxM. This was fixed by splitting
the half types out of $mat into a separate $matH generic.

Unit tests now compile properly for GLSL, but generate errors in SPIR-V
and generate Metal code which attempts to call a non-existent intrinsic.

Change-Id: I2fff10f0dd7f00534bf6b1d5b13354543694194e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/342926
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2020-12-10 20:51:59 +00:00

29 lines
702 B
Metal

#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct Inputs {
};
struct Outputs {
float4 sk_FragColor [[color(0)]];
};
struct Globals {
float3x3 a;
float3x3 b;
float4x4 c;
float4x4 d;
};
fragment Outputs fragmentMain(Inputs _in [[stage_in]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) {
Globals globalStruct{{}, {}, {}, {}};
thread Globals* _globals = &globalStruct;
(void)_globals;
Outputs _outputStruct;
thread Outputs* _out = &_outputStruct;
_out->sk_FragColor.xyz = matrixCompMult(_globals->a, _globals->b)[0];
_out->sk_FragColor = matrixCompMult(_globals->c, _globals->d)[0];
return *_out;
}