7cfa1ce9db
This implementation leans heavily into DSL. I also reworked the `normalize` intrinsic to use more DSL to shrink the implementation. $genType faceforward($genType N, $genType I, $genType Nref); $genHType faceforward($genHType N, $genHType I, $genHType Nref); Change-Id: I73ab11d3fe449d2f2c0ae0d745fc39824fc64771 Bug: skia:12034 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/412637 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>
23 lines
1.1 KiB
Plaintext
23 lines
1.1 KiB
Plaintext
uniform half4 N, I, NRef;
|
|
uniform half4 colorGreen, colorRed;
|
|
|
|
half4 main(float2 xy) {
|
|
|
|
const half4 constN = half4(1, 2, 3, 4);
|
|
const half4 constI = half4(1, 1, -100, 1);
|
|
const half4 constNRef = half4(1);
|
|
|
|
half4 expectedPos = half4(1, 2, 3, 4);
|
|
half4 expectedNeg = -half4(1, 2, 3, 4);
|
|
|
|
return (faceforward(N.x, I.x, NRef.x ) == expectedNeg.x &&
|
|
faceforward(N.xy, I.xy, NRef.xy ) == expectedNeg.xy &&
|
|
faceforward(N.xyz, I.xyz, NRef.xyz ) == expectedPos.xyz &&
|
|
faceforward(N.xyzw, I.xyzw, NRef.xyzw ) == expectedPos.xyzw &&
|
|
faceforward(constN.x, constI.x, constNRef.x ) == expectedNeg.x &&
|
|
faceforward(constN.xy, constI.xy, constNRef.xy ) == expectedNeg.xy &&
|
|
faceforward(constN.xyz, constI.xyz, constNRef.xyz ) == expectedPos.xyz &&
|
|
faceforward(constN.xyzw, constI.xyzw, constNRef.xyzw) == expectedPos.xyzw) ? colorGreen
|
|
: colorRed;
|
|
}
|