xref: /aosp_15_r20/external/skia/resources/sksl/intrinsics/Smoothstep.sksl (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
1uniform half4 testInputs;
2uniform half4 colorGreen, colorRed;
3
4half4 main(float2 coords) {
5    const half4 constVal   = half4(-1.25, 0, 0.75, 2.25);
6    const half4 constRed   = half4(1, 0, 0, 1);
7    const half4 constGreen = half4(0, 1, 0, 1);
8
9    half4 expectedA = half4(0.0, 0.0, 0.84375, 1.0);
10    half4 expectedB = half4(1.0, 0.0, 1.0, 1.0);
11
12    return (smoothstep(0,             1,               constVal.x)    == expectedA.x     &&
13            smoothstep(0,             1,               constVal.xy)   == expectedA.xy    &&
14            smoothstep(0,             1,               constVal.xyz)  == expectedA.xyz   &&
15            smoothstep(0,             1,               constVal.xyzw) == expectedA.xyzw  &&
16            smoothstep(0,             1,               constVal.x)    == expectedA.x     &&
17            smoothstep(0,             1,               constVal.xy)   == expectedA.xy    &&
18            smoothstep(0,             1,               constVal.xyz)  == expectedA.xyz   &&
19            smoothstep(0,             1,               constVal.xyzw) == expectedA.xyzw  &&
20            smoothstep(colorRed.g,    colorGreen.g,    constVal.x)    == expectedA.x     &&
21            smoothstep(colorRed.g,    colorGreen.g,    constVal.xy)   == expectedA.xy    &&
22            smoothstep(colorRed.g,    colorGreen.g,    constVal.xyz)  == expectedA.xyz   &&
23            smoothstep(colorRed.g,    colorGreen.g,    constVal.xyzw) == expectedA.xyzw  &&
24            smoothstep(constRed.x,    constGreen.x,    constVal.x)    == expectedB.x     &&
25            smoothstep(constRed.xy,   constGreen.xy,   constVal.xy)   == expectedB.xy    &&
26            smoothstep(constRed.xyz,  constGreen.xyz,  constVal.xyz)  == expectedB.xyz   &&
27            smoothstep(constRed.xyzw, constGreen.xyzw, constVal.xyzw) == expectedB.xyzw  &&
28            smoothstep(colorRed.x,    colorGreen.x,    constVal.x)    == expectedB.x     &&
29            smoothstep(colorRed.xy,   colorGreen.xy,   constVal.xy)   == expectedB.xy    &&
30            smoothstep(colorRed.xyz,  colorGreen.xyz,  constVal.xyz)  == expectedB.xyz   &&
31            smoothstep(colorRed.xyzw, colorGreen.xyzw, constVal.xyzw) == expectedB.xyzw)
32                ? colorGreen : colorRed;
33}
34