skia2/tests/sksl/intrinsics/Mod.glsl
John Stiles e5240a2498 Implement compile-time optimization for mod().
$genType mod($genType x, float y);
$genType mod($genType x, $genType y);
$genHType mod($genHType x, half y);
$genHType mod($genHType x, $genHType y);

Change-Id: I406eafbe824d7aa55012196521e6f10cac50ed19
Bug: skia:12034
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/412376
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-05-25 22:07:53 +00:00

12 lines
954 B
GLSL

out vec4 sk_FragColor;
uniform vec4 testInputs;
uniform vec4 colorGreen;
uniform vec4 colorRed;
uniform vec4 colorWhite;
vec4 main() {
vec4 expectedA = vec4(0.75, 0.0, 0.75, 0.25);
vec4 expectedB = vec4(0.25, 0.0, 0.75, 1.0);
return ((((((((((((((mod(testInputs.x, 1.0) == expectedA.x && mod(testInputs.xy, 1.0) == expectedA.xy) && mod(testInputs.xyz, 1.0) == expectedA.xyz) && mod(testInputs, 1.0) == expectedA) && 0.75 == expectedA.x) && vec2(0.75, 0.0) == expectedA.xy) && vec3(0.75, 0.0, 0.75) == expectedA.xyz) && vec4(0.75, 0.0, 0.75, 0.25) == expectedA) && mod(testInputs.x, colorWhite.x) == expectedA.x) && mod(testInputs.xy, colorWhite.xy) == expectedA.xy) && mod(testInputs.xyz, colorWhite.xyz) == expectedA.xyz) && mod(testInputs, colorWhite) == expectedA) && 0.25 == expectedB.x) && vec2(0.25, 0.0) == expectedB.xy) && vec3(0.25, 0.0, 0.75) == expectedB.xyz) && vec4(0.25, 0.0, 0.75, 1.0) == expectedB ? colorGreen : colorRed;
}