From: Ian Romanick Date: Mon, 13 Dec 2010 23:42:46 +0000 (-0800) Subject: ir_to_mesa: Don't generate swizzles for record derefs of non-scalar/vectors X-Git-Tag: 062012170305~8345 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2d577ee730c30caacf711babde6542766aa0b655;p=profile%2Fivi%2Fmesa.git ir_to_mesa: Don't generate swizzles for record derefs of non-scalar/vectors This is the same as what the array dereference handler does. Fixes piglit test glsl-link-struct-array (bugzilla #31648). NOTE: This is a candidate for the 7.9 and 7.10 branches. --- diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp index b274a96..490c4ca 100644 --- a/src/mesa/program/ir_to_mesa.cpp +++ b/src/mesa/program/ir_to_mesa.cpp @@ -1569,7 +1569,13 @@ 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); + + /* If the type is smaller than a vec4, replicate the last channel out. */ + if (ir->type->is_scalar() || ir->type->is_vector()) + this->result.swizzle = swizzle_for_size(ir->type->vector_elements); + else + this->result.swizzle = SWIZZLE_NOOP; + this->result.index += offset; }