skia2/resources/sksl/intrinsics/MixFloat.sksl
John Stiles 9c9f60cdb4 Implement additional Runtime Effect intrinsic tests.
Tested in dm:
- max(halfN, halfN)
- max(halfN, half)
- min(halfN, halfN)
- min(halfN, half)
- clamp(halfN, halfN, halfN)
- clamp(halfN, half, half)
- mix(halfN, halfN, halfN)
- mix(halfN, halfN, half)

Compiled outputs only (not in ES2):
- max(intN, intN)
- max(intN, int)
- min(intN, intN)
- min(intN, int)
- clamp(intN, intN, intN)
- clamp(intN, int, int)
- mix(halfN, halfN, boolN)  - broken in Metal/SPIR-V (skia:11222)
- mix(intN, intN, boolN)    - broken in Metal/SPIR-V (skia:11222)

Change-Id: Iaafc5429b16d2a8710b9d171ae281c268c0fd70d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/361438
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2021-01-29 18:23:48 +00:00

21 lines
1.4 KiB
Plaintext

uniform half4 colorGreen, colorRed, colorBlack, colorWhite, testInputs;
half4 main() {
half4 expectedBW = half4(0.5, 0.5, 0.5, 1);
half4 expectedWT = half4(1, 0.5, 1, 2.25);
return (mix(colorGreen, colorRed, 0) == half4(0, 1, 0, 1) &&
mix(colorGreen, colorRed, 0.25) == half4(0.25, 0.75, 0, 1) &&
mix(colorGreen, colorRed, 0.75) == half4(0.75, 0.25, 0, 1) &&
mix(colorGreen, colorRed, 1) == half4(1, 0, 0, 1) &&
mix(colorBlack.x, colorWhite.x, 0.5) == expectedBW.x &&
mix(colorBlack.xy, colorWhite.xy, 0.5) == expectedBW.xy &&
mix(colorBlack.xyz, colorWhite.xyz, 0.5) == expectedBW.xyz &&
mix(colorBlack.xyzw, colorWhite.xyzw, 0.5) == expectedBW.xyzw &&
mix(colorWhite.x, testInputs.x, 0) == expectedWT.x &&
mix(colorWhite.xy, testInputs.xy, half2(0, 0.5)) == expectedWT.xy &&
mix(colorWhite.xyz, testInputs.xyz, half3(0, 0.5, 0)) == expectedWT.xyz &&
mix(colorWhite.xyzw, testInputs.xyzw, half4(0, 0.5, 0, 1)) == expectedWT.xyzw)
? colorGreen : colorRed;
}