7b361499c9
This adds Analysis::IsConstantExpression, to determine if an expression is a constant-expression. It now expands to cover 'const' local and global variables, because we also enforce that the initializer on those variables is - in turn - a constant expression. This fixes 10837 - previously you could initialize a const variable with a non-constant expression, and we'd emit GLSL that contained that same pattern, which would fail to compile at the driver level. That should not be possible any longer. Bug: skia:10679 Bug: skia:10837 Change-Id: I517820ef4da57fff45768c0b04c55aebc18d3272 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/375856 Reviewed-by: John Stiles <johnstiles@google.com> Commit-Queue: Brian Osman <brianosman@google.com>
15 lines
378 B
Plaintext
15 lines
378 B
Plaintext
uniform half4 colorGreen, colorRed;
|
|
|
|
half4 main() {
|
|
const float4 a = float4(0);
|
|
const float4 b = float4(1);
|
|
// This is a constant-expression in GLSL, but not in SkSL (yet).
|
|
// We can't declare this const, and we can't eliminate it. skbug.com/10835
|
|
/*const*/ float4 c = abs(b);
|
|
if (a == b || b != c) {
|
|
return colorRed;
|
|
} else {
|
|
return colorGreen;
|
|
}
|
|
}
|