[Mesa-dev] [PATCH 11/15] i965/vec4: Remove swizzle_for_size() in favour of brw_swizzle_for_size().
Francisco Jerez
currojerez at riseup.net
Fri Mar 20 07:11:47 PDT 2015
It could be objected that swizzle_for_size() is "faster" than
brw_swizzle_for_size(). It's not measurably different in any
reasonable CPU-bound benchmark on VLV according to the Finnish
benchmarking system.
---
src/mesa/drivers/dri/i965/brw_ir_vec4.h | 3 ---
src/mesa/drivers/dri/i965/brw_vec4.cpp | 22 +---------------------
src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp | 14 +++++++-------
3 files changed, 8 insertions(+), 31 deletions(-)
diff --git a/src/mesa/drivers/dri/i965/brw_ir_vec4.h b/src/mesa/drivers/dri/i965/brw_ir_vec4.h
index 47f4e85..0181961 100644
--- a/src/mesa/drivers/dri/i965/brw_ir_vec4.h
+++ b/src/mesa/drivers/dri/i965/brw_ir_vec4.h
@@ -32,9 +32,6 @@ namespace brw {
class dst_reg;
-unsigned
-swizzle_for_size(int size);
-
class src_reg : public backend_reg
{
public:
diff --git a/src/mesa/drivers/dri/i965/brw_vec4.cpp b/src/mesa/drivers/dri/i965/brw_vec4.cpp
index 8757cba..69e80f2 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4.cpp
@@ -40,26 +40,6 @@ using namespace brw;
namespace brw {
-/**
- * Common helper for constructing swizzles. When only a subset of
- * channels of a vec4 are used, we don't want to reference the other
- * channels, as that will tell optimization passes that those other
- * channels are used.
- */
-unsigned
-swizzle_for_size(int size)
-{
- static const unsigned size_swizzles[4] = {
- BRW_SWIZZLE4(SWIZZLE_X, SWIZZLE_X, SWIZZLE_X, SWIZZLE_X),
- BRW_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Y, SWIZZLE_Y),
- BRW_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_Z),
- BRW_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_W),
- };
-
- assert((size >= 1) && (size <= 4));
- return size_swizzles[size - 1];
-}
-
void
src_reg::init()
{
@@ -75,7 +55,7 @@ src_reg::src_reg(register_file file, int reg, const glsl_type *type)
this->file = file;
this->reg = reg;
if (type && (type->is_scalar() || type->is_vector() || type->is_matrix()))
- this->swizzle = swizzle_for_size(type->vector_elements);
+ this->swizzle = brw_swizzle_for_size(type->vector_elements);
else
this->swizzle = BRW_SWIZZLE_XYZW;
}
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
index 7b58e12..8ae1abc 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
@@ -631,7 +631,7 @@ src_reg::src_reg(class vec4_visitor *v, const struct glsl_type *type)
if (type->is_array() || type->is_record()) {
this->swizzle = BRW_SWIZZLE_NOOP;
} else {
- this->swizzle = swizzle_for_size(type->vector_elements);
+ this->swizzle = brw_swizzle_for_size(type->vector_elements);
}
this->type = brw_type_for_base_type(type);
@@ -1819,7 +1819,7 @@ vec4_visitor::visit(ir_expression *ir)
pull->mlen = 1;
}
- packed_consts.swizzle = swizzle_for_size(ir->type->vector_elements);
+ packed_consts.swizzle = brw_swizzle_for_size(ir->type->vector_elements);
packed_consts.swizzle += BRW_SWIZZLE4(const_offset % 16 / 4,
const_offset % 16 / 4,
const_offset % 16 / 4,
@@ -1967,7 +1967,7 @@ vec4_visitor::visit(ir_dereference_variable *ir)
return;
if (type->is_scalar() || type->is_vector() || type->is_matrix())
- this->result.swizzle = swizzle_for_size(type->vector_elements);
+ this->result.swizzle = brw_swizzle_for_size(type->vector_elements);
}
@@ -2026,7 +2026,7 @@ vec4_visitor::visit(ir_dereference_array *ir)
/* If the type is smaller than a vec4, replicate the last channel out. */
if (ir->type->is_scalar() || ir->type->is_vector() || ir->type->is_matrix())
- src.swizzle = swizzle_for_size(ir->type->vector_elements);
+ src.swizzle = brw_swizzle_for_size(ir->type->vector_elements);
else
src.swizzle = BRW_SWIZZLE_NOOP;
src.type = brw_type_for_base_type(ir->type);
@@ -2051,7 +2051,7 @@ vec4_visitor::visit(ir_dereference_record *ir)
/* If the type is smaller than a vec4, replicate the last channel out. */
if (ir->type->is_scalar() || ir->type->is_vector() || ir->type->is_matrix())
- this->result.swizzle = swizzle_for_size(ir->type->vector_elements);
+ this->result.swizzle = brw_swizzle_for_size(ir->type->vector_elements);
else
this->result.swizzle = BRW_SWIZZLE_NOOP;
this->result.type = brw_type_for_base_type(ir->type);
@@ -2122,7 +2122,7 @@ vec4_visitor::emit_block_move(dst_reg *dst, src_reg *src,
dst->writemask = (1 << type->vector_elements) - 1;
- src->swizzle = swizzle_for_size(type->vector_elements);
+ src->swizzle = brw_swizzle_for_size(type->vector_elements);
vec4_instruction *inst = emit(MOV(*dst, *src));
inst->predicate = predicate;
@@ -2210,7 +2210,7 @@ vec4_visitor::visit(ir_assignment *ir)
*/
assert(src.swizzle ==
(ir->rhs->type->is_matrix()
- ? swizzle_for_size(ir->rhs->type->vector_elements)
+ ? brw_swizzle_for_size(ir->rhs->type->vector_elements)
: BRW_SWIZZLE_NOOP));
emit_block_move(&dst, &src, ir->rhs->type, predicate);
--
2.1.3
More information about the mesa-dev
mailing list