aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorIan Romanick <[email protected]>2010-11-19 17:16:12 -0800
committerIan Romanick <[email protected]>2010-11-19 17:17:25 -0800
commitbb756bb0a6935b7e0d8fd2f9d61c0437fef7d770 (patch)
tree71099cdef00d5abbd01a0d6aec76ccb409f75cef /src
parent63684a9ae7a66f68df1f2c68cd9358e5622122a3 (diff)
glsl: Fix matrix constructors with vector parameters
When the semantics of write masks in assignments were changed, this code was not correctly updated. Fixes piglit test glsl-mat-from-vec-ctor-01.
Diffstat (limited to 'src')
-rw-r--r--src/glsl/ast_function.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/glsl/ast_function.cpp b/src/glsl/ast_function.cpp
index 924e35afc09..1e66033348c 100644
--- a/src/glsl/ast_function.cpp
+++ b/src/glsl/ast_function.cpp
@@ -627,21 +627,21 @@ assign_to_matrix_column(ir_variable *var, unsigned column, unsigned row_base,
assert(column_ref->type->components() >= (row_base + count));
assert(src->type->components() >= (src_base + count));
- /* Generate a swizzle that puts the first element of the source at the
- * location of the first element of the destination.
+ /* Generate a swizzle that extracts the number of components from the source
+ * that are to be assigned to the column of the matrix.
*/
- unsigned swiz[4] = { src_base, src_base, src_base, src_base };
- for (unsigned i = 0; i < count; i++)
- swiz[i + row_base] = i;
-
- ir_rvalue *const rhs =
- new(mem_ctx) ir_swizzle(src, swiz, count);
+ if (count < src->type->vector_elements) {
+ src = new(mem_ctx) ir_swizzle(src,
+ src_base + 0, src_base + 1,
+ src_base + 2, src_base + 3,
+ count);
+ }
/* Mask of fields to be written in the assignment.
*/
const unsigned write_mask = ((1U << count) - 1) << row_base;
- return new(mem_ctx) ir_assignment(column_ref, rhs, NULL, write_mask);
+ return new(mem_ctx) ir_assignment(column_ref, src, NULL, write_mask);
}