summaryrefslogtreecommitdiff
path: root/ir_to_mesa.cpp
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2010-06-01 16:23:57 -0700
committerEric Anholt <eric@anholt.net>2010-06-24 15:05:21 -0700
commitab386f18b045fe260112bd9a239cb503e737c1db (patch)
tree061b0f32e0577ed0f09ff560ad5e3e874dcc1c9f /ir_to_mesa.cpp
parentc23c6c773a5c79b458e52ff42bd9f431c87d4036 (diff)
ir_to_mesa: Try to fix up the dereference handling for the visitor rework.
One of the gstreamer shaders I play with now compiles, but input mappings are wrong.
Diffstat (limited to 'ir_to_mesa.cpp')
-rw-r--r--ir_to_mesa.cpp39
1 files changed, 15 insertions, 24 deletions
diff --git a/ir_to_mesa.cpp b/ir_to_mesa.cpp
index 59ee3b29f0..8d3f65ffb2 100644
--- a/ir_to_mesa.cpp
+++ b/ir_to_mesa.cpp
@@ -659,27 +659,26 @@ ir_to_mesa_visitor::visit(ir_dereference_variable *ir)
MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_Z),
MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_W),
};
- ir_variable *var = ir->var;
/* By the time we make it to this stage, matrices should be broken down
* to vectors.
*/
- assert(!var->type->is_matrix());
+ assert(!ir->var->type->is_matrix());
tree = this->create_tree(MB_TERM_reference_vec4, ir, NULL, NULL);
- if (strncmp(var->name, "gl_", 3) == 0) {
+ if (strncmp(ir->var->name, "gl_", 3) == 0) {
unsigned int i;
for (i = 0; i < ARRAY_SIZE(builtin_var_to_mesa_reg); i++) {
- if (strcmp(var->name, builtin_var_to_mesa_reg[i].name) == 0)
+ if (strcmp(ir->var->name, builtin_var_to_mesa_reg[i].name) == 0)
break;
}
assert(i != ARRAY_SIZE(builtin_var_to_mesa_reg));
ir_to_mesa_set_tree_reg(tree, builtin_var_to_mesa_reg[i].file,
builtin_var_to_mesa_reg[i].index);
} else {
- this->get_temp_for_var(var, tree);
+ this->get_temp_for_var(ir->var, tree);
}
/* If the type is smaller than a vec4, replicate the last channel out. */
@@ -698,33 +697,25 @@ ir_to_mesa_visitor::visit(ir_dereference_array *ir)
MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Y, SWIZZLE_Y),
MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_X, SWIZZLE_X, SWIZZLE_X),
};
- ir_variable *var = ir->variable_referenced();
- ir_constant *index = ir->array_index->constant_expression_value();
+ ir_constant *index;
+
+ index = ir->array_index->constant_expression_value();
/* By the time we make it to this stage, matrices should be broken down
* to vectors.
*/
- assert(!var->type->is_matrix());
-
- if (strncmp(var->name, "gl_", 3) == 0) {
- unsigned int i;
- unsigned int offset = 0;
+ assert(!ir->type->is_matrix());
- tree = this->create_tree(MB_TERM_reference_vec4, ir, NULL, NULL);
+ ir->array->accept(this);
+ tree = this->result;
- offset = index->value.i[0];
+ if (tree->src_reg.file == PROGRAM_INPUT ||
+ tree->src_reg.file == PROGRAM_OUTPUT) {
+ assert(index); /* FINISHME: Handle variable indexing of builtins. */
- for (i = 0; i < ARRAY_SIZE(builtin_var_to_mesa_reg); i++) {
- if (strcmp(var->name, builtin_var_to_mesa_reg[i].name) == 0)
- break;
- }
- assert(i != ARRAY_SIZE(builtin_var_to_mesa_reg));
- ir_to_mesa_set_tree_reg(tree, builtin_var_to_mesa_reg[i].file,
- builtin_var_to_mesa_reg[i].index + offset);
+ tree->src_reg.index += index->value.i[0];
+ tree->dst_reg.index += index->value.i[0];
} else {
- tree = this->create_tree(MB_TERM_reference_vec4, ir, NULL, NULL);
- this->get_temp_for_var(var, tree);
-
if (index) {
tree->src_reg.index += index->value.i[0];
tree->dst_reg.index += index->value.i[0];