From 85e93da18ca2c967ca12870b62ab1aac2f0b880c Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 22 Jul 2010 16:11:08 -0700 Subject: [PATCH] ir_to_mesa: Fix the swizzles on record and array dereferences. Fixes: glsl1-struct (1) glsl1-struct (2) glsl1-struct (3) glsl1-struct (4) --- src/mesa/shader/ir_to_mesa.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index ba45c87e59c..c397838e259 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -1151,7 +1151,10 @@ ir_to_mesa_visitor::visit(ir_dereference_variable *ir) src_reg.file = entry->file; src_reg.index = entry->index; /* If the type is smaller than a vec4, replicate the last channel out. */ - src_reg.swizzle = swizzle_for_size(ir->var->type->vector_elements); + if (ir->type->is_scalar() || ir->type->is_vector()) + src_reg.swizzle = swizzle_for_size(ir->var->type->vector_elements); + else + src_reg.swizzle = SWIZZLE_NOOP; src_reg.reladdr = NULL; src_reg.negate = 0; @@ -1231,7 +1234,10 @@ ir_to_mesa_visitor::visit(ir_dereference_array *ir) } /* If the type is smaller than a vec4, replicate the last channel out. */ - src_reg.swizzle = swizzle_for_size(ir->type->vector_elements); + if (ir->type->is_scalar() || ir->type->is_vector()) + src_reg.swizzle = swizzle_for_size(ir->type->vector_elements); + else + src_reg.swizzle = SWIZZLE_NOOP; this->result = src_reg; } @@ -1250,6 +1256,7 @@ ir_to_mesa_visitor::visit(ir_dereference_record *ir) break; offset += type_size(struct_type->fields.structure[i].type); } + this->result.swizzle = swizzle_for_size(ir->type->vector_elements); this->result.index += offset; } @@ -1322,7 +1329,6 @@ ir_to_mesa_visitor::visit(ir_assignment *ir) int i; assert(!ir->lhs->type->is_array()); - assert(ir->lhs->type->base_type != GLSL_TYPE_STRUCT); ir->rhs->accept(this); r = this->result; -- 2.30.2