Mesa (master): i965/vs: Keep track of indices into a per-register array for virtual GRFs.

Eric Anholt anholt at kemper.freedesktop.org
Fri Sep 9 05:34:02 UTC 2011


Module: Mesa
Branch: master
Commit: 87b51fc4a807616eaab0c4b38e41c328c08875e3
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=87b51fc4a807616eaab0c4b38e41c328c08875e3

Author: Eric Anholt <eric at anholt.net>
Date:   Thu Sep  1 08:34:18 2011 -0700

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(+), 0 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_vec4.h b/src/mesa/drivers/dri/i965/brw_vec4.h
index 1597f98..f148ca6 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 c50a722..83f543f 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;
 




More information about the mesa-commit mailing list