xref: /aosp_15_r20/external/skia/resources/sksl/intrinsics/ClampUInt.sksl (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
1*c8dee2aaSAndroid Build Coastguard Workeruniform half4 testInputs;
2*c8dee2aaSAndroid Build Coastguard Workeruniform half4 colorGreen, colorRed;
3*c8dee2aaSAndroid Build Coastguard Worker
4*c8dee2aaSAndroid Build Coastguard Workerhalf4 main(float2 coords) {
5*c8dee2aaSAndroid Build Coastguard Worker    uint4 uintValues      = uint4(testInputs * 100 + 200);
6*c8dee2aaSAndroid Build Coastguard Worker
7*c8dee2aaSAndroid Build Coastguard Worker    uint4 expectedA       = uint4( 100,  200,  275, 300);
8*c8dee2aaSAndroid Build Coastguard Worker
9*c8dee2aaSAndroid Build Coastguard Worker    const uint4 clampLow  = uint4( 100,    0,    0, 300);
10*c8dee2aaSAndroid Build Coastguard Worker    const uint4 constVal  = uint4(  75,  200,  275, 425);
11*c8dee2aaSAndroid Build Coastguard Worker    uint4 expectedB       = uint4( 100,  200,  250, 425);
12*c8dee2aaSAndroid Build Coastguard Worker    const uint4 clampHigh = uint4( 300,  400,  250, 500);
13*c8dee2aaSAndroid Build Coastguard Worker
14*c8dee2aaSAndroid Build Coastguard Worker    return (clamp(uintValues.x,    100, 300)                      == expectedA.x     &&
15*c8dee2aaSAndroid Build Coastguard Worker            clamp(uintValues.xy,   100, 300)                      == expectedA.xy    &&
16*c8dee2aaSAndroid Build Coastguard Worker            clamp(uintValues.xyz,  100, 300)                      == expectedA.xyz   &&
17*c8dee2aaSAndroid Build Coastguard Worker            clamp(uintValues.xyzw, 100, 300)                      == expectedA.xyzw  &&
18*c8dee2aaSAndroid Build Coastguard Worker            clamp(constVal.x,      100, 300)                      == expectedA.x     &&
19*c8dee2aaSAndroid Build Coastguard Worker            clamp(constVal.xy,     100, 300)                      == expectedA.xy    &&
20*c8dee2aaSAndroid Build Coastguard Worker            clamp(constVal.xyz,    100, 300)                      == expectedA.xyz   &&
21*c8dee2aaSAndroid Build Coastguard Worker            clamp(constVal.xyzw,   100, 300)                      == expectedA.xyzw  &&
22*c8dee2aaSAndroid Build Coastguard Worker            clamp(uintValues.x,    clampLow.x,    clampHigh.x   ) == expectedB.x     &&
23*c8dee2aaSAndroid Build Coastguard Worker            clamp(uintValues.xy,   clampLow.xy,   clampHigh.xy  ) == expectedB.xy    &&
24*c8dee2aaSAndroid Build Coastguard Worker            clamp(uintValues.xyz,  clampLow.xyz,  clampHigh.xyz ) == expectedB.xyz   &&
25*c8dee2aaSAndroid Build Coastguard Worker            clamp(uintValues.xyzw, clampLow.xyzw, clampHigh.xyzw) == expectedB.xyzw  &&
26*c8dee2aaSAndroid Build Coastguard Worker            clamp(constVal.x,      clampLow.x,    clampHigh.x   ) == expectedB.x     &&
27*c8dee2aaSAndroid Build Coastguard Worker            clamp(constVal.xy,     clampLow.xy,   clampHigh.xy  ) == expectedB.xy    &&
28*c8dee2aaSAndroid Build Coastguard Worker            clamp(constVal.xyz,    clampLow.xyz,  clampHigh.xyz ) == expectedB.xyz   &&
29*c8dee2aaSAndroid Build Coastguard Worker            clamp(constVal.xyzw,   clampLow.xyzw, clampHigh.xyzw) == expectedB.xyzw) ? colorGreen
30*c8dee2aaSAndroid Build Coastguard Worker                                                                                     : colorRed;
31*c8dee2aaSAndroid Build Coastguard Worker}
32