[Mesa-dev] [RFC PATCH 27/40] i965: Build a dynamic gather table for UBO push constant entries

Abdiel Janulgue abdiel.janulgue at linux.intel.com
Sun Jan 4 06:04:41 PST 2015


The resource streamer is able to gather and pack sparsely-located
constant data from any buffer object representing a UBO block.
This patch adds support for keeping track of these constant data
fetches into a gather table.

We only allocate a maximum of 128 entries. This limitation is taken
from a comment in assign_constant_locations() that we allow 16
registers (128 uniform components) as push constants.

Signed-off-by: Abdiel Janulgue <abdiel.janulgue at linux.intel.com>
---
 src/mesa/drivers/dri/i965/brw_context.h | 5 +++++
 src/mesa/drivers/dri/i965/brw_program.c | 3 +++
 src/mesa/drivers/dri/i965/brw_wm.c      | 3 +++
 3 files changed, 11 insertions(+)

diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h
index 0337bfd..8eddc54 100644
--- a/src/mesa/drivers/dri/i965/brw_context.h
+++ b/src/mesa/drivers/dri/i965/brw_context.h
@@ -347,6 +347,7 @@ struct brw_stage_prog_data {
 
    GLuint nr_params;       /**< number of float params/constants */
    GLuint nr_pull_params;
+   GLuint nr_gather_table;
 
    unsigned curb_read_length;
    unsigned total_scratch;
@@ -367,6 +368,10 @@ struct brw_stage_prog_data {
     */
    const gl_constant_value **param;
    const gl_constant_value **pull_param;
+   struct {
+      int reg;
+      unsigned channel_mask;
+   } gather_table[128]; /** equal to max_push_components */
 };
 
 /* Data about a particular attempt to compile a program.  Note that
diff --git a/src/mesa/drivers/dri/i965/brw_program.c b/src/mesa/drivers/dri/i965/brw_program.c
index c1eec8a..2c3d374 100644
--- a/src/mesa/drivers/dri/i965/brw_program.c
+++ b/src/mesa/drivers/dri/i965/brw_program.c
@@ -558,6 +558,9 @@ brw_stage_prog_data_compare(const struct brw_stage_prog_data *a,
    if (memcmp(a->pull_param, b->pull_param, a->nr_pull_params * sizeof(void *)))
       return false;
 
+   if (memcmp(a->gather_table, b->gather_table, sizeof(a->gather_table)))
+      return false;
+
    return true;
 }
 
diff --git a/src/mesa/drivers/dri/i965/brw_wm.c b/src/mesa/drivers/dri/i965/brw_wm.c
index e7939f0..1be93c3 100644
--- a/src/mesa/drivers/dri/i965/brw_wm.c
+++ b/src/mesa/drivers/dri/i965/brw_wm.c
@@ -204,6 +204,9 @@ bool do_wm_prog(struct brw_context *brw,
       rzalloc_array(NULL, const gl_constant_value *, param_count);
    prog_data.base.nr_params = param_count;
 
+   prog_data.base.nr_gather_table = 0;
+   memset(prog_data.base.gather_table, 0, sizeof(prog_data.base.gather_table));
+
    prog_data.barycentric_interp_modes =
       brw_compute_barycentric_interp_modes(brw, key->flat_shade,
                                            key->persample_shading,
-- 
1.9.1



More information about the mesa-dev mailing list