summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBryan Cain <[email protected]>2012-10-23 11:58:40 -0500
committerAndreas Boll <[email protected]>2012-10-29 15:49:00 +0100
commit170f0459a2367406d4ec838b2eebdc6ff2f84f2c (patch)
tree097cbf667d75c3881660580f0a5c06eb369d9183 /src
parent96ed6c90eff58ce030c39c2b4db6daf512586b34 (diff)
glsl_to_tgsi: set correct register type for array and structure elements
This fixes an issue where glsl_to_tgsi_visior::get_opcode() would emit the wrong opcode because the register type was GLSL_TYPE_ARRAY/STRUCT instead of GLSL_TYPE_FLOAT/INT/UINT/BOOL, so the function would use the float opcodes for operations on integer or boolean values dereferenced from an array or structure. Assertions have been added to get_opcode() to prevent this bug from reappearing in the future. NOTE: This is a candidate for the stable branches. Reviewed-by: Brian Paul <[email protected]> Tested-by: Andreas Boll <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/mesa/state_tracker/st_glsl_to_tgsi.cpp21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index 705f2b055af..14b72dc8006 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -630,6 +630,11 @@ glsl_to_tgsi_visitor::get_opcode(ir_instruction *ir, unsigned op,
{
int type = GLSL_TYPE_FLOAT;
+ assert(src0.type != GLSL_TYPE_ARRAY);
+ assert(src0.type != GLSL_TYPE_STRUCT);
+ assert(src1.type != GLSL_TYPE_ARRAY);
+ assert(src1.type != GLSL_TYPE_STRUCT);
+
if (src0.type == GLSL_TYPE_FLOAT || src1.type == GLSL_TYPE_FLOAT)
type = GLSL_TYPE_FLOAT;
else if (native_integers)
@@ -1071,8 +1076,12 @@ glsl_to_tgsi_visitor::visit(ir_variable *ir)
assert(index == storage->index + (int)i);
}
} else {
- st_src_reg src(PROGRAM_STATE_VAR, index,
- native_integers ? ir->type->base_type : GLSL_TYPE_FLOAT);
+ /* We use GLSL_TYPE_FLOAT here regardless of the actual type of
+ * the data being moved since MOV does not care about the type of
+ * data it is moving, and we don't want to declare registers with
+ * array or struct types.
+ */
+ st_src_reg src(PROGRAM_STATE_VAR, index, GLSL_TYPE_FLOAT);
src.swizzle = slots[i].swizzle;
emit(ir, TGSI_OPCODE_MOV, dst, src);
/* even a float takes up a whole vec4 reg in a struct/array. */
@@ -2039,6 +2048,9 @@ glsl_to_tgsi_visitor::visit(ir_dereference_array *ir)
else
src.swizzle = SWIZZLE_NOOP;
+ /* Change the register type to the element type of the array. */
+ src.type = ir->type->base_type;
+
this->result = src;
}
@@ -2064,6 +2076,7 @@ glsl_to_tgsi_visitor::visit(ir_dereference_record *ir)
this->result.swizzle = SWIZZLE_NOOP;
this->result.index += offset;
+ this->result.type = ir->type->base_type;
}
/**
@@ -2283,6 +2296,10 @@ glsl_to_tgsi_visitor::visit(ir_assignment *ir)
inst->dead_mask = inst->dst.writemask;
} else {
for (i = 0; i < type_size(ir->lhs->type); i++) {
+ if (ir->rhs->type->is_array())
+ r.type = ir->rhs->type->element_type()->base_type;
+ else if (ir->rhs->type->is_record())
+ r.type = ir->rhs->type->fields.structure[i].type->base_type;
emit(ir, TGSI_OPCODE_MOV, l, r);
l.index++;
r.index++;