Mesa (master): glsl: Expand non-expr & non-swizzle scalar rvalues in vectorizing.

Matt Turner mattst88 at kemper.freedesktop.org
Fri Jan 31 18:21:46 UTC 2014


Module: Mesa
Branch: master
Commit: 606544214e0e45d1d93de16b4ac4851d8d71eb87
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=606544214e0e45d1d93de16b4ac4851d8d71eb87

Author: Matt Turner <mattst88 at gmail.com>
Date:   Tue Jan 28 14:44:39 2014 -0800

glsl: Expand non-expr & non-swizzle scalar rvalues in vectorizing.

---

 src/glsl/opt_vectorize.cpp |   14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/src/glsl/opt_vectorize.cpp b/src/glsl/opt_vectorize.cpp
index 5ad1320..8ee81f1 100644
--- a/src/glsl/opt_vectorize.cpp
+++ b/src/glsl/opt_vectorize.cpp
@@ -106,9 +106,10 @@ public:
  * the nodes of the tree (expression float log2 (swiz z   (var_ref v0))),
  * rewriting it into     (expression vec3  log2 (swiz xyz (var_ref v0))).
  *
- * The function modifies only ir_expressions and ir_swizzles. For expressions
- * it sets a new type and swizzles any scalar dereferences into appropriately
- * sized vector arguments. For example, if combining
+ * The function operates on ir_expressions (and its operands) and ir_swizzles.
+ * For expressions it sets a new type and swizzles any non-expression and non-
+ * swizzle scalar operands into appropriately sized vector arguments. For
+ * example, if combining
  *
  * (assign (x) (var_ref r1) (expression float + (swiz x (var_ref v0) (var_ref v1))))
  * (assign (y) (var_ref r1) (expression float + (swiz y (var_ref v0) (var_ref v1))))
@@ -146,9 +147,10 @@ rewrite_swizzle(ir_instruction *ir, void *data)
                                            mask->num_components, 1);
       for (unsigned i = 0; i < 4; i++) {
          if (expr->operands[i]) {
-            ir_dereference *deref = expr->operands[i]->as_dereference();
-            if (deref && deref->type->is_scalar()) {
-               expr->operands[i] = new(ir) ir_swizzle(deref, 0, 0, 0, 0,
+            ir_rvalue *rval = expr->operands[i]->as_rvalue();
+            if (rval && rval->type->is_scalar() &&
+                !rval->as_expression() && !rval->as_swizzle()) {
+               expr->operands[i] = new(ir) ir_swizzle(rval, 0, 0, 0, 0,
                                                       mask->num_components);
             }
          }




More information about the mesa-commit mailing list