aboutsummaryrefslogtreecommitdiffstats
path: root/src/glsl/opt_vectorize.cpp
diff options
context:
space:
mode:
authorMatt Turner <[email protected]>2014-01-28 14:44:39 -0800
committerMatt Turner <[email protected]>2014-01-31 10:21:50 -0800
commit606544214e0e45d1d93de16b4ac4851d8d71eb87 (patch)
tree6eb96360490d778ebcc294048441560e320424de /src/glsl/opt_vectorize.cpp
parent3f49a8c9a5b6f72eef05fa0382bb8c0db714f492 (diff)
glsl: Expand non-expr & non-swizzle scalar rvalues in vectorizing.
Diffstat (limited to 'src/glsl/opt_vectorize.cpp')
-rw-r--r--src/glsl/opt_vectorize.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/glsl/opt_vectorize.cpp b/src/glsl/opt_vectorize.cpp
index 5ad1320bd69..8ee81f1a329 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);
}
}