From: Matt Turner Date: Tue, 28 Jan 2014 22:44:39 +0000 (-0800) Subject: glsl: Expand non-expr & non-swizzle scalar rvalues in vectorizing. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=606544214e0e45d1d93de16b4ac4851d8d71eb87;p=mesa.git glsl: Expand non-expr & non-swizzle scalar rvalues in vectorizing. --- 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); } }