[Mesa-dev] [PATCH 03/13] i965 vs: Return last_scratch from move_grf_array_access_to_scratch()

Paul Berry stereotype441 at gmail.com
Wed Nov 16 11:07:10 PST 2011


Previously, vec4_visitor::move_grf_array_access_to_scratch() stored
the value of last_scratch in the brw_vs_compile structure directly.
Now it returns it to vec4_visitor::run(), which stores it.

This helps pave the way for sharing vec4 code between the GS and the
VS, by making move_grf_array_access_to_scratch() more independent of
the kind of shader it is compiling for.
---
 src/mesa/drivers/dri/i965/brw_vec4.h           |    2 +-
 src/mesa/drivers/dri/i965/brw_vec4_emit.cpp    |    2 +-
 src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp |   13 ++++++++-----
 3 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_vec4.h b/src/mesa/drivers/dri/i965/brw_vec4.h
index b942284..9c4495a 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4.h
+++ b/src/mesa/drivers/dri/i965/brw_vec4.h
@@ -392,7 +392,7 @@ public:
    void setup_payload();
    int reg_allocate_trivial();
    int reg_allocate();
-   void move_grf_array_access_to_scratch();
+   unsigned move_grf_array_access_to_scratch();
    void move_uniform_array_access_to_pull_constants();
    void move_push_constants_to_pull_constants();
    void split_uniform_registers();
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_emit.cpp b/src/mesa/drivers/dri/i965/brw_vec4_emit.cpp
index f2a100b..061d487 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_emit.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_emit.cpp
@@ -638,7 +638,7 @@ vec4_visitor::run()
     * that we have reladdr computations available for CSE, since we'll
     * often do repeated subexpressions for those.
     */
-   move_grf_array_access_to_scratch();
+   c->last_scratch = move_grf_array_access_to_scratch();
    move_uniform_array_access_to_pull_constants();
    pack_uniform_registers();
    move_push_constants_to_pull_constants();
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
index 3327eef..42214d4 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
@@ -2181,10 +2181,11 @@ vec4_visitor::emit_scratch_write(vec4_instruction *inst,
  * registers.  So, we send all GRF arrays that get variable index
  * access to scratch space.
  */
-void
+unsigned
 vec4_visitor::move_grf_array_access_to_scratch()
 {
    int scratch_loc[this->virtual_grf_count];
+   unsigned last_scratch = 0;
 
    for (int i = 0; i < this->virtual_grf_count; i++) {
       scratch_loc[i] = -1;
@@ -2199,8 +2200,8 @@ vec4_visitor::move_grf_array_access_to_scratch()
 
       if (inst->dst.file == GRF && inst->dst.reladdr &&
 	  scratch_loc[inst->dst.reg] == -1) {
-	 scratch_loc[inst->dst.reg] = c->last_scratch;
-	 c->last_scratch += this->virtual_grf_sizes[inst->dst.reg] * 8 * 4;
+	 scratch_loc[inst->dst.reg] = last_scratch;
+	 last_scratch += this->virtual_grf_sizes[inst->dst.reg] * 8 * 4;
       }
 
       for (int i = 0 ; i < 3; i++) {
@@ -2208,8 +2209,8 @@ vec4_visitor::move_grf_array_access_to_scratch()
 
 	 if (src->file == GRF && src->reladdr &&
 	     scratch_loc[src->reg] == -1) {
-	    scratch_loc[src->reg] = c->last_scratch;
-	    c->last_scratch += this->virtual_grf_sizes[src->reg] * 8 * 4;
+	    scratch_loc[src->reg] = last_scratch;
+	    last_scratch += this->virtual_grf_sizes[src->reg] * 8 * 4;
 	 }
       }
    }
@@ -2252,6 +2253,8 @@ vec4_visitor::move_grf_array_access_to_scratch()
 	 inst->src[i].reladdr = NULL;
       }
    }
+
+   return last_scratch;
 }
 
 /**
-- 
1.7.6.4



More information about the mesa-dev mailing list