i965/fs: Save push constant location information.
authorKenneth Graunke <kenneth@whitecape.org>
Fri, 7 Mar 2014 10:10:14 +0000 (02:10 -0800)
committerKenneth Graunke <kenneth@whitecape.org>
Tue, 18 Mar 2014 17:11:21 +0000 (10:11 -0700)
Previously, both move_uniform_array_access_to_pull_constants() and
setup_pull_constants() maintained stack-local arrays with this
information.  Storing this information will allow it to be used from
multiple functions, allowing us to split and move code around.

We'll also eventually want to pass pull constant location information
to the SIMD16 compile.  Saving this information will help us do that.

Unfortunately, the two functions *cannot* share the contents of the
array just yet.  remove_dead_constants() renumbers all the UNIFORM
registers to be contiguous starting at zero, so the two functions
talk about uniforms using different names.  We can't even remap them,
since move_uniform_array_access_to_pull_constants() deletes UNIFORM
registers that are only accessed with reladdr, so remove_dead_constants
can't even see them.

This situation will improve in the next few patches.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
src/mesa/drivers/dri/i965/brw_fs.cpp
src/mesa/drivers/dri/i965/brw_fs.h
src/mesa/drivers/dri/i965/brw_fs_visitor.cpp

index c24d2f8dd79c70078179986057087fa369922735..8faf40167314a22071b611f68b16c9d50a8e3a52 100644 (file)
@@ -1827,7 +1827,7 @@ fs_visitor::remove_dead_constants()
 void
 fs_visitor::move_uniform_array_access_to_pull_constants()
 {
-   int pull_constant_loc[uniforms];
+   pull_constant_loc = ralloc_array(mem_ctx, int, uniforms);
 
    for (unsigned int i = 0; i < uniforms; i++) {
       pull_constant_loc[i] = -1;
@@ -1884,6 +1884,9 @@ fs_visitor::move_uniform_array_access_to_pull_constants()
       }
    }
    invalidate_live_intervals();
+
+   ralloc_free(pull_constant_loc);
+   pull_constant_loc = NULL;
 }
 
 /**
@@ -1909,7 +1912,7 @@ fs_visitor::setup_pull_constants()
     */
    unsigned int pull_uniform_base = max_uniform_components;
 
-   int pull_constant_loc[uniforms];
+   pull_constant_loc = ralloc_array(mem_ctx, int, uniforms);
    for (unsigned int i = 0; i < uniforms; i++) {
       if (i < pull_uniform_base) {
          pull_constant_loc[i] = -1;
index 86c95dfb124358397bc5f3f8073dd104aba74ecf..abfdb1041691213ca544249bbe4843c299b5f3c9 100644 (file)
@@ -509,6 +509,12 @@ public:
    /** Number of uniform variable components visited. */
    unsigned uniforms;
 
+   /**
+    * Array mapping UNIFORM register numbers to the pull parameter index,
+    * or -1 if this uniform register isn't being uploaded as a pull constant.
+    */
+   int *pull_constant_loc;
+
    /* This is the map from UNIFORM hw_reg + reg_offset as generated by
     * the visitor to the packed uniform number after
     * remove_dead_constants() that represents the actual uploaded
index 90272eb68f5a13cbd647c095aa26e93f7b17c888..404af306bb5a5f3cc4d4a3144854a48b5423d5d6 100644 (file)
@@ -2971,6 +2971,7 @@ fs_visitor::fs_visitor(struct brw_context *brw,
    this->regs_live_at_ip = NULL;
 
    this->uniforms = 0;
+   this->pull_constant_loc = NULL;
    this->params_remap = NULL;
    this->nr_params_remap = 0;