summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2011-08-07 10:59:39 -0700
committerEric Anholt <eric@anholt.net>2011-08-16 13:04:42 -0700
commit1ff4f11dd94711a498cde0330101c58636ef2741 (patch)
treee5decff4e75cd197b69df4d34f44db3d13978e90
parent314c2574ff6e562a6cfc5fb84980f092e495a948 (diff)
i965/vs: Track the variable index of array accesses.
This isn't used currently, as we lower all array accesses.
-rw-r--r--src/mesa/drivers/dri/i965/brw_vec4.h4
-rw-r--r--src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp16
2 files changed, 16 insertions, 4 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_vec4.h b/src/mesa/drivers/dri/i965/brw_vec4.h
index 3e457fc61aa..bb40c71e4c9 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4.h
+++ b/src/mesa/drivers/dri/i965/brw_vec4.h
@@ -169,6 +169,8 @@ public:
GLuint swizzle; /**< SWIZZLE_XYZW swizzles from Mesa. */
bool negate;
bool abs;
+
+ src_reg *reladdr;
};
class dst_reg : public reg
@@ -219,6 +221,8 @@ public:
explicit dst_reg(src_reg reg);
int writemask; /**< Bitfield of WRITEMASK_[XYZW] */
+
+ src_reg *reladdr;
};
class vec4_instruction : public exec_node {
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
index f90025c8e7e..8bd048ff459 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
@@ -37,6 +37,7 @@ src_reg::src_reg(dst_reg reg)
this->reg = reg.reg;
this->reg_offset = reg.reg_offset;
this->type = reg.type;
+ this->reladdr = reg.reladdr;
int swizzles[4];
int next_chan = 0;
@@ -66,6 +67,7 @@ dst_reg::dst_reg(src_reg reg)
this->reg_offset = reg.reg_offset;
this->type = reg.type;
this->writemask = WRITEMASK_XYZW;
+ this->reladdr = reg.reladdr;
}
vec4_instruction *
@@ -1186,7 +1188,6 @@ vec4_visitor::visit(ir_dereference_array *ir)
if (constant_index) {
src.reg_offset += constant_index->value.i[0] * element_size;
} else {
-#if 0 /* Variable array index */
/* Variable index array dereference. It eats the "vec4" of the
* base of the array and an index that offsets the Mesa register
* index.
@@ -1198,15 +1199,22 @@ vec4_visitor::visit(ir_dereference_array *ir)
if (element_size == 1) {
index_reg = this->result;
} else {
- index_reg = src_reg(this, glsl_type::float_type);
+ index_reg = src_reg(this, glsl_type::int_type);
emit(BRW_OPCODE_MUL, dst_reg(index_reg),
- this->result, src_reg_for_float(element_size));
+ this->result, src_reg(element_size));
+ }
+
+ if (src.reladdr) {
+ src_reg temp = src_reg(this, glsl_type::int_type);
+
+ emit(BRW_OPCODE_ADD, dst_reg(temp), *src.reladdr, index_reg);
+
+ index_reg = temp;
}
src.reladdr = ralloc(mem_ctx, src_reg);
memcpy(src.reladdr, &index_reg, sizeof(index_reg));
-#endif
}
/* If the type is smaller than a vec4, replicate the last channel out. */