diff options
author | Ian Romanick <ian.d.romanick@intel.com> | 2010-11-15 13:41:06 -0800 |
---|---|---|
committer | Ian Romanick <ian.d.romanick@intel.com> | 2010-11-16 12:11:02 -0800 |
commit | 2d2d6a80c14612de683001d24cbbbb9a8f620dd5 (patch) | |
tree | 96202c46b13de3e15d2c6ed1b8d21e031118380d | |
parent | 38e55153af031e48125b1cd0a5d939bb92379ddc (diff) |
glsl: Simplify generation of swizzle for vector constructors
-rw-r--r-- | src/glsl/ast_function.cpp | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/glsl/ast_function.cpp b/src/glsl/ast_function.cpp index e9e8d25001..924e35afc0 100644 --- a/src/glsl/ast_function.cpp +++ b/src/glsl/ast_function.cpp @@ -577,18 +577,17 @@ emit_inline_vector_constructor(const glsl_type *type, const ir_constant *const c = param->as_constant(); if (c == NULL) { - /* Generate a swizzle in case rhs_components != rhs->type->vector_elements. */ - unsigned swiz[4] = { 0, 0, 0, 0 }; - for (unsigned i = 0; i < rhs_components; i++) - swiz[i] = i; - /* Mask of fields to be written in the assignment. */ const unsigned write_mask = ((1U << rhs_components) - 1) << base_component; ir_dereference *lhs = new(ctx) ir_dereference_variable(var); - ir_rvalue *rhs = new(ctx) ir_swizzle(param, swiz, rhs_components); + + /* Generate a swizzle so that LHS and RHS sizes match. + */ + ir_rvalue *rhs = + new(ctx) ir_swizzle(param, 0, 1, 2, 3, rhs_components); ir_instruction *inst = new(ctx) ir_assignment(lhs, rhs, NULL, write_mask); |