Mesa (glsl2): ir_to_mesa: Fix the swizzles on record and array dereferences .
Eric Anholt
anholt at kemper.freedesktop.org
Thu Jul 22 23:18:04 UTC 2010
Module: Mesa
Branch: glsl2
Commit: 85e93da18ca2c967ca12870b62ab1aac2f0b880c
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=85e93da18ca2c967ca12870b62ab1aac2f0b880c
Author: Eric Anholt <eric at anholt.net>
Date: Thu Jul 22 16:11:08 2010 -0700
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 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp
index ba45c87..c397838 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;
More information about the mesa-commit
mailing list