xref: /aosp_15_r20/external/skia/resources/sksl/intrinsics/IntBitsToFloat.sksl (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
1*c8dee2aaSAndroid Build Coastguard Workeruniform float2x2 testMatrix2x2;
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    const float4 constVal = float4(-1, 0, 1, 2);
6*c8dee2aaSAndroid Build Coastguard Worker    const int4 expectedA = int4(-0x40800000, 0x00000000, 0x3F800000, 0x40000000);
7*c8dee2aaSAndroid Build Coastguard Worker
8*c8dee2aaSAndroid Build Coastguard Worker    float4 inputVal = float4(testMatrix2x2) * float4(1, 1, -1, -1);
9*c8dee2aaSAndroid Build Coastguard Worker    int4 expectedB = int4(0x3F800000, 0x40000000, -0x3FC00000, -0x3F800000);
10*c8dee2aaSAndroid Build Coastguard Worker
11*c8dee2aaSAndroid Build Coastguard Worker    return (constVal.x    == intBitsToFloat(expectedA.x)    &&
12*c8dee2aaSAndroid Build Coastguard Worker            constVal.xy   == intBitsToFloat(expectedA.xy)   &&
13*c8dee2aaSAndroid Build Coastguard Worker            constVal.xyz  == intBitsToFloat(expectedA.xyz)  &&
14*c8dee2aaSAndroid Build Coastguard Worker            constVal.xyzw == intBitsToFloat(expectedA.xyzw) &&
15*c8dee2aaSAndroid Build Coastguard Worker            inputVal.x    == intBitsToFloat(expectedB.x)    &&
16*c8dee2aaSAndroid Build Coastguard Worker            inputVal.xy   == intBitsToFloat(expectedB.xy)   &&
17*c8dee2aaSAndroid Build Coastguard Worker            inputVal.xyz  == intBitsToFloat(expectedB.xyz)  &&
18*c8dee2aaSAndroid Build Coastguard Worker            inputVal.xyzw == intBitsToFloat(expectedB.xyzw)) ? colorGreen : colorRed;
19*c8dee2aaSAndroid Build Coastguard Worker}
20