From 87b51fc4a807616eaab0c4b38e41c328c08875e3 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 1 Sep 2011 08:34:18 -0700 Subject: [PATCH] i965/vs: Keep track of indices into a per-register array for virtual GRFs. Tracking virtual GRFs has tension between using a packed array per virtual GRF (which is good for register allocation), and sparse arrays where there's an element per actual register (so the first and second column of a mat2 can be distinguished inside of an optimization pass). The FS mostly avoided the need for this second sparse array by doing virtual GRF splitting, but that meant that instances where virtual GRF splitting didn't work, instructions using those registers got much less optimized. --- src/mesa/drivers/dri/i965/brw_vec4.h | 9 +++++++++ src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp | 6 ++++++ 2 files changed, 15 insertions(+) diff --git a/src/mesa/drivers/dri/i965/brw_vec4.h b/src/mesa/drivers/dri/i965/brw_vec4.h index 1597f983f2f..f148ca62cd5 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4.h +++ b/src/mesa/drivers/dri/i965/brw_vec4.h @@ -320,6 +320,15 @@ public: int first_non_payload_grf; int *virtual_grf_def; int *virtual_grf_use; + + /** + * This is the size to be used for an array with an element per + * reg_offset + */ + int virtual_grf_reg_count; + /** Per-virtual-grf indices into an array of size virtual_grf_reg_count */ + int *virtual_grf_reg_map; + bool live_intervals_valid; dst_reg *variable_storage(ir_variable *var); diff --git a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp index c50a722b0f4..83f543f6f41 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp +++ b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp @@ -432,7 +432,11 @@ vec4_visitor::virtual_grf_alloc(int size) 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++; } @@ -2272,6 +2276,8 @@ vec4_visitor::vec4_visitor(struct brw_vs_compile *c, this->virtual_grf_use = NULL; this->virtual_grf_sizes = NULL; this->virtual_grf_count = 0; + this->virtual_grf_reg_map = NULL; + this->virtual_grf_reg_count = 0; this->virtual_grf_array_size = 0; this->live_intervals_valid = false; -- 2.30.2