skia2/resources/sksl/intrinsics/Reflect.sksl
John Stiles 4ceccaf053 Implement compile-time optimization for reflect().
$genType  reflect($genType  I, $genType  N);
$genHType reflect($genHType I, $genHType N);

Change-Id: I59889ad767829bf7e33838737d7b7f6d1cbc3ece
Bug: skia:12034
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/412777
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-05-26 19:49:29 +00:00

23 lines
973 B
Plaintext

uniform half4 I, N;
uniform half4 colorGreen, colorRed;
half4 main(float2 xy) {
const half4 constI = half4(1, -2, 3, -4);
const half4 constN = half4(-5, 6, -7, 8);
half expectedX = half (-49);
half2 expectedXY = half2(-169, 202);
half3 expectedXYZ = half3(-379, 454, -529);
half4 expectedXYZW = half4(-699, 838, -977, 1116);
return (reflect(I.x, N.x ) == expectedX &&
reflect(I.xy, N.xy ) == expectedXY &&
reflect(I.xyz, N.xyz ) == expectedXYZ &&
reflect(I.xyzw, N.xyzw ) == expectedXYZW &&
reflect(constI.x, constN.x ) == expectedX &&
reflect(constI.xy, constN.xy ) == expectedXY &&
reflect(constI.xyz, constN.xyz ) == expectedXYZ &&
reflect(constI.xyzw, constN.xyzw) == expectedXYZW) ? colorGreen
: colorRed;
}