[Mesa-dev] [PATCH 12/27] i965: Assign hw-binding table index for each UBO constant buffer.

Abdiel Janulgue abdiel.janulgue at linux.intel.com
Tue Apr 28 13:08:09 PDT 2015


To be able to refer to a constant buffer, the resource streamer needs
to index it with a hardware binding table entry. This blankets the ubo
buffers with hardware binding table indices.

Gather constants hardware fetches in 16-entry binding table blocks.
So we need to use a block that is unused.

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

diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h
index e25c64d..276c359 100644
--- a/src/mesa/drivers/dri/i965/brw_context.h
+++ b/src/mesa/drivers/dri/i965/brw_context.h
@@ -678,6 +678,17 @@ struct brw_vs_prog_data {
 
 #define SURF_INDEX_GEN6_SOL_BINDING(t) (t)
 
+/** Start of hardware binding table index for uniform gather constant entries.
+ *  This must be aligned to the start of a hardware binding table block (a block
+ *  is a group 16 binding table entries).
+ */
+#define BRW_UNIFORM_GATHER_INDEX_START 32
+
+/** Appended to the end of the binding table index for uniform constant buffers to indicate
+ *  start of the UBO gather constant binding table.
+ */
+#define BRW_UBO_GATHER_INDEX_APPEND 2
+
 /* Note: brw_gs_prog_data_compare() must be updated when adding fields to
  * this struct!
  */
diff --git a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
index 161d140..ce61554 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
@@ -884,6 +884,7 @@ brw_upload_ubo_surfaces(struct brw_context *brw,
 
    uint32_t *surf_offsets =
       &stage_state->surf_offset[prog_data->binding_table.ubo_start];
+   bool use_gather = (brw->gather_pool.bo != NULL);
 
    for (int i = 0; i < shader->NumUniformBlocks; i++) {
       struct gl_uniform_buffer_binding *binding;
@@ -904,6 +905,11 @@ brw_upload_ubo_surfaces(struct brw_context *brw,
                                   bo->size - binding->Offset,
                                   &surf_offsets[i],
                                   dword_pitch);
+      if (use_gather) {
+         int bt_idx = BRW_UNIFORM_GATHER_INDEX_START + BRW_UBO_GATHER_INDEX_APPEND + i;
+         gen7_update_binding_table(brw, stage_state->stage,
+                                   bt_idx, surf_offsets[i]);
+      }
    }
 
    if (shader->NumUniformBlocks)
-- 
1.9.1



More information about the mesa-dev mailing list