diff options
author | Timothy Arceri <tarceri@itsqueeze.com> | 2018-06-28 09:23:20 +1000 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2018-07-03 10:24:58 -0700 |
commit | 45bea64814c6324ed03903a27792381a7b611953 (patch) | |
tree | 8d33060a26eaca7751b064f22b5ccd6132261730 | |
parent | fb39f5d2e88961b7e84df6a0303ac94553668456 (diff) |
glsl: skip comparison opt when adding vars of different size
The spec allows adding scalars with a vector or matrix. In this case
the opt was losing swizzle and size information.
This fixes a bug with Doom (2016) shaders.
Fixes: 34ec1a24d61f ("glsl: Optimize (x + y cmp 0) into (x cmp -y).")
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
(cherry picked from commit 2a5121bf355001e2c69ba05e8d9be4ed633c7bf4)
-rw-r--r-- | src/compiler/glsl/opt_algebraic.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/compiler/glsl/opt_algebraic.cpp b/src/compiler/glsl/opt_algebraic.cpp index 1a8ee36165..ff4be26957 100644 --- a/src/compiler/glsl/opt_algebraic.cpp +++ b/src/compiler/glsl/opt_algebraic.cpp @@ -709,6 +709,12 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir) if (!is_vec_zero(zero)) continue; + /* We are allowed to add scalars with a vector or matrix. In that + * case lets just exit early. + */ + if (add->operands[0]->type != add->operands[1]->type) + continue; + /* Depending of the zero position we want to optimize * (0 cmp x+y) into (-x cmp y) or (x+y cmp 0) into (x cmp -y) */ |