Disable constant-variable substitution when optimization is off.
When optimization is disabled, I did not expect to see arithmetic like `color * ONE` disappear (even though it's just a constant fold): const vec4 ONE = half4(1); vec4 x = color * ONE; Change-Id: Id24a632712591c73a904b90e5efdba092d846c0e Reviewed-on: https://skia-review.googlesource.com/c/skia/+/382477 Commit-Queue: Ethan Nicholas <ethannicholas@google.com> Auto-Submit: John Stiles <johnstiles@google.com> Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
This commit is contained in:
parent
0dd1a77e12
commit
be6cbf331c
@ -312,9 +312,16 @@ std::unique_ptr<Expression> ConstantFolder::Simplify(const Context& context,
|
||||
Operator op,
|
||||
const Expression& rightExpr,
|
||||
const Type& resultType) {
|
||||
// Replace constant variables with trivial initial-values.
|
||||
const Expression* left = GetConstantValueForVariable(leftExpr);
|
||||
const Expression* right = GetConstantValueForVariable(rightExpr);
|
||||
// When optimization is enabled, replace constant variables with trivial initial-values.
|
||||
const Expression* left;
|
||||
const Expression* right;
|
||||
if (context.fConfig->fSettings.fOptimize) {
|
||||
left = GetConstantValueForVariable(leftExpr);
|
||||
right = GetConstantValueForVariable(rightExpr);
|
||||
} else {
|
||||
left = &leftExpr;
|
||||
right = &rightExpr;
|
||||
}
|
||||
|
||||
// If this is the comma operator, the left side is evaluated but not otherwise used in any way.
|
||||
// So if the left side has no side effects, it can just be eliminated entirely.
|
||||
|
Loading…
Reference in New Issue
Block a user