skia2/resources/sksl/intrinsics/Transpose.sksl
John Stiles 1e45dcd12f Add compile-time optimization for transpose().
Change-Id: I9ddb80b8886827250e243dc9174bb3679e70df9b
Bug: skia:12202
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/440262
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-08-18 13:49:04 +00:00

42 lines
2.2 KiB
Plaintext

uniform float2x2 testMatrix2x2;
uniform float3x3 testMatrix3x3;
uniform half4 colorGreen, colorRed;
half4 main(float2 coords) {
float2x3 testMatrix2x3 = float2x3(1, 2, 3, 4, 5, 6);
const float2x4 testMatrix2x4 = float2x4(1, 2, 3, 4, 5, 6, 7, 8);
const float3x2 testMatrix3x2 = float3x2(1, 2, 3, 4, 5, 6);
const float3x4 testMatrix3x4 = float3x4(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12);
const float4x2 testMatrix4x2 = float4x2(1, 2, 3, 4, 5, 6, 7, 8);
const float4x3 testMatrix4x3 = float4x3(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12);
const float4x4 testMatrix4x4 = float4x4(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16);
return (transpose(testMatrix2x2) == float2x2(1, 3,
2, 4) &&
transpose(testMatrix2x3) == float3x2(1, 4,
2, 5,
3, 6) &&
transpose(testMatrix2x4) == float4x2(1, 5,
2, 6,
3, 7,
4, 8) &&
transpose(testMatrix3x2) == float2x3(1, 3, 5,
2, 4, 6) &&
transpose(testMatrix3x3) == float3x3(1, 4, 7,
2, 5, 8,
3, 6, 9) &&
transpose(testMatrix3x4) == float4x3(1, 5, 9,
2, 6, 10,
3, 7, 11,
4, 8, 12) &&
transpose(testMatrix4x2) == float2x4(1, 3, 5, 7,
2, 4, 6, 8) &&
transpose(testMatrix4x3) == float3x4(1, 4, 7, 10,
2, 5, 8, 11,
3, 6, 9, 12) &&
transpose(testMatrix4x4) == float4x4(1, 5, 9, 13,
2, 6, 10, 14,
3, 7, 11, 15,
4, 8, 12, 16)) ? colorGreen : colorRed;
}