i965/vs: Track uniforms as separate vectors once we've done array access.
authorEric Anholt <eric@anholt.net>
Tue, 23 Aug 2011 17:22:50 +0000 (10:22 -0700)
committerEric Anholt <eric@anholt.net>
Tue, 30 Aug 2011 19:09:40 +0000 (12:09 -0700)
This will make it easier to figure out which elements are totally
unused and not upload them.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/mesa/drivers/dri/i965/brw_vec4.cpp
src/mesa/drivers/dri/i965/brw_vec4.h
src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp

index 760bc1f7acdea9adb5c15a051256e65989fe0670..cdbbb5579609c374078580da80033a9ca12ac480 100644 (file)
@@ -158,4 +158,34 @@ vec4_visitor::dead_code_eliminate()
    return progress;
 }
 
+void
+vec4_visitor::split_uniform_registers()
+{
+   /* Prior to this, uniforms have been in an array sized according to
+    * the number of vector uniforms present, sparsely filled (so an
+    * aggregate results in reg indices being skipped over).  Now we're
+    * going to cut those aggregates up so each .reg index is one
+    * vector.  The goal is to make elimination of unused uniform
+    * components easier later.
+    */
+   foreach_list(node, &this->instructions) {
+      vec4_instruction *inst = (vec4_instruction *)node;
+
+      for (int i = 0 ; i < 3; i++) {
+        if (inst->src[i].file != UNIFORM)
+           continue;
+
+        assert(!inst->src[i].reladdr);
+
+        inst->src[i].reg += inst->src[i].reg_offset;
+        inst->src[i].reg_offset = 0;
+      }
+   }
+
+   /* Update that everything is now vector-sized. */
+   for (int i = 0; i < this->uniforms; i++) {
+      this->uniform_size[i] = 1;
+   }
+}
+
 } /* namespace brw */
index 1bb15016b525e00b8921fde1c49dc5e15cb5409a..945eea576b1de9af441c41000665e218371b4b2e 100644 (file)
@@ -388,6 +388,7 @@ public:
    void reg_allocate();
    void move_grf_array_access_to_scratch();
    void move_uniform_array_access_to_pull_constants();
+   void split_uniform_registers();
    void calculate_live_intervals();
    bool dead_code_eliminate();
    bool virtual_grf_interferes(int a, int b);
index c4a3bbadd40fc719246c0ed81a9b9de5ad96fa31..dc11d9883ca30610ae66cd4a4b22190dd13097e8 100644 (file)
@@ -2202,6 +2202,13 @@ vec4_visitor::move_uniform_array_access_to_pull_constants()
         inst->src[i].reladdr = NULL;
       }
    }
+
+   /* Now there are no accesses of the UNIFORM file with a reladdr, so
+    * no need to track them as larger-than-vec4 objects.  This will be
+    * relied on in cutting out unused uniform vectors from push
+    * constants.
+    */
+   split_uniform_registers();
 }
 
 vec4_visitor::vec4_visitor(struct brw_vs_compile *c,