summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2010-05-06 09:35:56 -0700
committerEric Anholt <[email protected]>2010-06-24 15:05:19 -0700
commit3d70d1f4d684a943b8b4a65319641415882b72cb (patch)
tree318edfceea527e33ec8887e9edeae1ea267514ae
parentb07cc372c6360d0e59c84bb7586597f028c74b02 (diff)
ir_to_mesa: Emit more reduced writemasks for ops on small types.
This should help prevent Mesa from having to be smart to give channel-wise drivers better information.
-rw-r--r--ir_to_mesa.cpp16
-rw-r--r--ir_to_mesa.h2
2 files changed, 14 insertions, 4 deletions
diff --git a/ir_to_mesa.cpp b/ir_to_mesa.cpp
index 3976f437f93..a01c50cbc2f 100644
--- a/ir_to_mesa.cpp
+++ b/ir_to_mesa.cpp
@@ -177,9 +177,19 @@ ir_to_mesa_visitor::create_tree(int op,
* pass over the Mesa IR later.
*/
void
-ir_to_mesa_visitor::get_temp(struct mbtree *tree)
+ir_to_mesa_visitor::get_temp(struct mbtree *tree, int size)
{
+ int swizzle = 0;
+ int i;
+
ir_to_mesa_set_tree_reg(tree, PROGRAM_TEMPORARY, this->next_temp++);
+
+ for (i = 0; i < size; i++)
+ swizzle |= 1 << i;
+ for (; i < 4; i++)
+ swizzle |= 1 << (size - 1);
+ tree->src_reg.swizzle = swizzle;
+ tree->dst_reg.writemask = (1 << size) - 1;
}
void
@@ -349,7 +359,7 @@ ir_to_mesa_visitor::visit(ir_expression *ir)
}
/* Allocate a temporary for the result. */
- this->get_temp(this->result);
+ this->get_temp(this->result, ir->type->vector_elements);
}
@@ -369,7 +379,7 @@ ir_to_mesa_visitor::visit(ir_swizzle *ir)
assert(this->result);
tree = this->create_tree(MB_TERM_swizzle_vec4, ir, this->result, NULL);
- this->get_temp(tree);
+ this->get_temp(tree, 4);
for (i = 0; i < 4; i++) {
if (i < ir->type->vector_elements) {
diff --git a/ir_to_mesa.h b/ir_to_mesa.h
index 00328e5fab2..fbf10d86bb6 100644
--- a/ir_to_mesa.h
+++ b/ir_to_mesa.h
@@ -100,7 +100,7 @@ public:
int next_temp;
int next_constant;
- void get_temp(struct mbtree *tree);
+ void get_temp(struct mbtree *tree, int size);
void get_temp_for_var(ir_variable *var, struct mbtree *tree);