xref: /aosp_15_r20/external/skia/resources/sksl/shared/CompileTimeConstantVariables.sksl (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
1const int kConstant = 0;
2const int kOtherConstant = 1;
3const int kAnotherConstant = 2;
4const float kFloatConstant = 2.14;
5const float kFloatConstantAlias = kFloatConstant;
6const half4 kConstVec = half4(1, 0.2, kFloatConstant, 1);
7
8uniform half4 colorGreen;
9
10half4 main(float2) {
11    const float kLocalFloatConstant = 1.0 + kFloatConstantAlias;
12    const float kLocalFloatConstantAlias = kLocalFloatConstant;
13    int integerInput = int(colorGreen.g);
14
15    if (integerInput == kConstant) {
16        return half4(kFloatConstant);
17    } else if (integerInput == kOtherConstant) {
18        return colorGreen;  // the shader is expected to always take this path
19    } else if (integerInput == kAnotherConstant) {
20        return kConstVec;
21    } else if (kLocalFloatConstantAlias < colorGreen.r * kLocalFloatConstant) {
22        return half4(kLocalFloatConstantAlias);
23    } else if (kFloatConstantAlias >= colorGreen.r * kFloatConstantAlias) {
24        return half4(0);
25    } else {
26        return half4(1, 0, 0, 1);
27    }
28}
29