From: Eric Anholt Date: Thu, 6 May 2010 16:35:56 +0000 (-0700) Subject: ir_to_mesa: Emit more reduced writemasks for ops on small types. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=3d70d1f4d684a943b8b4a65319641415882b72cb;p=mesa.git 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. --- 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);