skia2/resources/sksl/shared/ConstVariableComparison.sksl
John Stiles 0bd5578c31 Replace Metal constant keyword with const.
"Constant" is an address space qualifier and can't be applied to a
local variable. "Const" in GLSL (and hypothetically SkSL) is meant to
apply to a constant expression regardless of address space.

Our previous test was not finding any error because the optimizer was
eliminating the constant expressions entirely.

Change-Id: I6cfe8e2a621c79945b33e0166780d81e79890a1b
Bug: skia:11304
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/368517
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2021-02-10 15:23:25 +00:00

13 lines
300 B
Plaintext

uniform half4 colorGreen, colorRed;
half4 main() {
const float4 a = float4(0);
const float4 b = float4(1);
const float4 c = abs(b); // still a Constant Expression, but SkSL cannot eliminate it (today)
if (a == b || b != c) {
return colorRed;
} else {
return colorGreen;
}
}