skia2/resources/sksl/intrinsics/Dot.sksl
John Stiles 419d2ced2d Implement compile-time optimization for dot().
float dot($genType x, $genType y);
half dot($genHType x, $genHType y);

Change-Id: Ia8b893eaddd8b4325c34143c80fb0ae05b111666
Bug: skia:12034
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/412339
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-05-26 15:05:08 +00:00

18 lines
778 B
Plaintext

uniform half4 inputA, inputB;
uniform half4 colorGreen, colorRed;
half4 main(float2 coords) {
const half4 constValA = half4(1, 2, 3, 4);
const half4 constValB = half4(5, 6, 7, 8);
half4 expected = half4(5, 17, 38, 70);
return (dot(inputA.x, inputB.x) == expected.x &&
dot(inputA.xy, inputB.xy) == expected.y &&
dot(inputA.xyz, inputB.xyz) == expected.z &&
dot(inputA.xyzw, inputB.xyzw) == expected.w &&
dot(constValA.x, constValB.x) == expected.x &&
dot(constValA.xy, constValB.xy) == expected.y &&
dot(constValA.xyz, constValB.xyz) == expected.z &&
dot(constValA.xyzw, constValB.xyzw) == expected.w) ? colorGreen : colorRed;
}