[Mesa-dev] [PATCH 08/14] i965: Refactor virtual register allocation between fs and vec4
Topi Pohjolainen
topi.pohjolainen at intel.com
Wed May 28 05:36:04 PDT 2014
Signed-off-by: Topi Pohjolainen <topi.pohjolainen at intel.com>
---
src/mesa/drivers/dri/i965/brw_fs.cpp | 15 -------------
src/mesa/drivers/dri/i965/brw_fs.h | 4 ----
src/mesa/drivers/dri/i965/brw_fs_visitor.cpp | 3 ---
src/mesa/drivers/dri/i965/brw_shader.cpp | 25 +++++++++++++++++++++
src/mesa/drivers/dri/i965/brw_shader.h | 6 +++++
src/mesa/drivers/dri/i965/brw_vec4.cpp | 4 ++--
src/mesa/drivers/dri/i965/brw_vec4.h | 4 ----
.../drivers/dri/i965/brw_vec4_reg_allocate.cpp | 2 +-
src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp | 26 ++--------------------
9 files changed, 36 insertions(+), 53 deletions(-)
diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp
index 5de6b95..f073e12 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
@@ -841,21 +841,6 @@ fs_visitor::implied_mrf_writes(fs_inst *inst)
}
}
-int
-fs_visitor::virtual_grf_alloc(int size)
-{
- if (virtual_grf_array_size <= virtual_grf_count) {
- if (virtual_grf_array_size == 0)
- virtual_grf_array_size = 16;
- else
- virtual_grf_array_size *= 2;
- virtual_grf_sizes = reralloc(mem_ctx, virtual_grf_sizes, int,
- virtual_grf_array_size);
- }
- virtual_grf_sizes[virtual_grf_count] = size;
- return virtual_grf_count++;
-}
-
/** Fixed HW reg constructor. */
fs_reg::fs_reg(enum register_file file, int reg)
{
diff --git a/src/mesa/drivers/dri/i965/brw_fs.h b/src/mesa/drivers/dri/i965/brw_fs.h
index f430862..d1d2018 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.h
+++ b/src/mesa/drivers/dri/i965/brw_fs.h
@@ -252,7 +252,6 @@ public:
unsigned dispatch_width);
fs_reg *variable_storage(ir_variable *var);
- int virtual_grf_alloc(int size);
void import_uniforms(fs_visitor *v);
void visit(ir_variable *ir);
@@ -492,9 +491,6 @@ public:
int *param_size;
- int *virtual_grf_sizes;
- int virtual_grf_count;
- int virtual_grf_array_size;
int *virtual_grf_start;
int *virtual_grf_end;
brw::fs_live_variables *live_intervals;
diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
index e74b28e..b78a8d2 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
@@ -2983,9 +2983,6 @@ fs_visitor::fs_visitor(struct brw_context *brw,
this->current_annotation = NULL;
this->base_ir = NULL;
- this->virtual_grf_sizes = NULL;
- this->virtual_grf_count = 0;
- this->virtual_grf_array_size = 0;
this->virtual_grf_start = NULL;
this->virtual_grf_end = NULL;
this->live_intervals = NULL;
diff --git a/src/mesa/drivers/dri/i965/brw_shader.cpp b/src/mesa/drivers/dri/i965/brw_shader.cpp
index fba347a..e55e998 100644
--- a/src/mesa/drivers/dri/i965/brw_shader.cpp
+++ b/src/mesa/drivers/dri/i965/brw_shader.cpp
@@ -561,6 +561,9 @@ backend_emitter::backend_emitter(struct brw_context *brw, void *mem_ctx,
failed(false),
stage_name(stage_name),
debug_flag(debug_flag),
+ virtual_grf_sizes(0),
+ virtual_grf_count(0),
+ virtual_grf_array_size(0),
virtual_grf_reg_count(0),
virtual_grf_reg_map(NULL)
{
@@ -601,6 +604,28 @@ backend_emitter::fail(const char *format, ...)
va_end(va);
}
+int
+backend_emitter::virtual_grf_alloc(int size, bool use_map)
+{
+ if (virtual_grf_array_size <= virtual_grf_count) {
+ if (virtual_grf_array_size == 0)
+ virtual_grf_array_size = 16;
+ else
+ virtual_grf_array_size *= 2;
+ virtual_grf_sizes = reralloc(mem_ctx, virtual_grf_sizes, int,
+ virtual_grf_array_size);
+ if (use_map)
+ virtual_grf_reg_map = reralloc(mem_ctx, virtual_grf_reg_map, int,
+ virtual_grf_array_size);
+ }
+ if (use_map) {
+ virtual_grf_reg_map[virtual_grf_count] = virtual_grf_reg_count;
+ virtual_grf_reg_count += size;
+ }
+ virtual_grf_sizes[virtual_grf_count] = size;
+ return virtual_grf_count++;
+}
+
bool
backend_instruction::is_tex() const
{
diff --git a/src/mesa/drivers/dri/i965/brw_shader.h b/src/mesa/drivers/dri/i965/brw_shader.h
index 8c9b646..54157fd 100644
--- a/src/mesa/drivers/dri/i965/brw_shader.h
+++ b/src/mesa/drivers/dri/i965/brw_shader.h
@@ -112,6 +112,8 @@ protected:
public:
+ int virtual_grf_alloc(int size, bool use_map = false);
+
struct brw_context * const brw;
struct gl_context * const ctx;
@@ -134,6 +136,10 @@ public:
const char * const stage_name;
const bool debug_flag;
+ int *virtual_grf_sizes;
+ int virtual_grf_count;
+ int virtual_grf_array_size;
+
/**
* This is the size to be used for an array with an element per
* reg_offset
diff --git a/src/mesa/drivers/dri/i965/brw_vec4.cpp b/src/mesa/drivers/dri/i965/brw_vec4.cpp
index 041f9e6..cba499a 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4.cpp
@@ -1228,9 +1228,9 @@ vec4_visitor::split_virtual_grfs()
if (!split_grf[i])
continue;
- new_virtual_grf[i] = virtual_grf_alloc(1);
+ new_virtual_grf[i] = virtual_grf_alloc(1, true);
for (int j = 2; j < this->virtual_grf_sizes[i]; j++) {
- int reg = virtual_grf_alloc(1);
+ int reg = virtual_grf_alloc(1, true);
assert(reg == new_virtual_grf[i] + j - 1);
(void) reg;
}
diff --git a/src/mesa/drivers/dri/i965/brw_vec4.h b/src/mesa/drivers/dri/i965/brw_vec4.h
index db5f417..dbf445f 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4.h
+++ b/src/mesa/drivers/dri/i965/brw_vec4.h
@@ -327,9 +327,6 @@ public:
const void *base_ir;
const char *current_annotation;
- int *virtual_grf_sizes;
- int virtual_grf_count;
- int virtual_grf_array_size;
int first_non_payload_grf;
int *virtual_grf_start;
int *virtual_grf_end;
@@ -388,7 +385,6 @@ public:
bool run(void);
- int virtual_grf_alloc(int size);
void setup_uniform_clipplane_values();
void setup_uniform_values(ir_variable *ir);
void setup_builtin_uniform_values(ir_variable *ir);
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_reg_allocate.cpp b/src/mesa/drivers/dri/i965/brw_vec4_reg_allocate.cpp
index 349c031..b939c8d 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_reg_allocate.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_reg_allocate.cpp
@@ -341,7 +341,7 @@ vec4_visitor::spill_reg(int spill_reg_nr)
for (unsigned int i = 0; i < 3; i++) {
if (inst->src[i].file == GRF && inst->src[i].reg == spill_reg_nr) {
src_reg spill_reg = inst->src[i];
- inst->src[i].reg = virtual_grf_alloc(1);
+ inst->src[i].reg = virtual_grf_alloc(1, true);
dst_reg temp = dst_reg(inst->src[i]);
/* Only read the necessary channels, to avoid overwriting the rest
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
index f7355b8..e324d76 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
@@ -597,31 +597,12 @@ type_size(const struct glsl_type *type)
return 0;
}
-int
-vec4_visitor::virtual_grf_alloc(int size)
-{
- if (virtual_grf_array_size <= virtual_grf_count) {
- if (virtual_grf_array_size == 0)
- virtual_grf_array_size = 16;
- else
- virtual_grf_array_size *= 2;
- virtual_grf_sizes = reralloc(mem_ctx, virtual_grf_sizes, int,
- virtual_grf_array_size);
- virtual_grf_reg_map = reralloc(mem_ctx, virtual_grf_reg_map, int,
- virtual_grf_array_size);
- }
- virtual_grf_reg_map[virtual_grf_count] = virtual_grf_reg_count;
- virtual_grf_reg_count += size;
- virtual_grf_sizes[virtual_grf_count] = size;
- return virtual_grf_count++;
-}
-
src_reg::src_reg(class vec4_visitor *v, const struct glsl_type *type)
{
init();
this->file = GRF;
- this->reg = v->virtual_grf_alloc(type_size(type));
+ this->reg = v->virtual_grf_alloc(type_size(type), true);
if (type->is_array() || type->is_record()) {
this->swizzle = BRW_SWIZZLE_NOOP;
@@ -637,7 +618,7 @@ dst_reg::dst_reg(class vec4_visitor *v, const struct glsl_type *type)
init();
this->file = GRF;
- this->reg = v->virtual_grf_alloc(type_size(type));
+ this->reg = v->virtual_grf_alloc(type_size(type), true);
if (type->is_array() || type->is_record()) {
this->writemask = WRITEMASK_XYZW;
@@ -3382,9 +3363,6 @@ vec4_visitor::vec4_visitor(struct brw_context *brw,
this->virtual_grf_start = NULL;
this->virtual_grf_end = NULL;
- this->virtual_grf_sizes = NULL;
- this->virtual_grf_count = 0;
- this->virtual_grf_array_size = 0;
this->live_intervals_valid = false;
this->uniforms = 0;
--
1.8.3.1
More information about the mesa-dev
mailing list