[Mesa-dev] [RFC PATCH 39/40] i965: Generate separate gather entries for UBOs

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


Now that we are able to use a gather table for fetching UBOs,
make a gather entry based on the table generated by the ir_binop_ubo_load
and uniform loads combined. At the moment, we separate this entry from
the previous uniform-only gather table because the current approach
to pack the uniform and ubo gather entries doesn't work if the
uniform entry size is greater than a vec4.

Ideally, we should only generate a single gather table for the uniforms
and the UBOs combined. But this will do for now.

Signed-off-by: Abdiel Janulgue <abdiel.janulgue at linux.intel.com>
---
 src/mesa/drivers/dri/i965/gen7_vs_state.c | 61 +++++++++++++++++++++----------
 1 file changed, 42 insertions(+), 19 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/gen7_vs_state.c b/src/mesa/drivers/dri/i965/gen7_vs_state.c
index 30ebec8..78dfc13 100644
--- a/src/mesa/drivers/dri/i965/gen7_vs_state.c
+++ b/src/mesa/drivers/dri/i965/gen7_vs_state.c
@@ -36,26 +36,49 @@ gen7_submit_gather_table(struct brw_context* brw,
                          unsigned gather_opcode)
 {
    uint32_t gather_dwords = 0;
-   /* Generate gather entry only for uniforms */
-   int num_consts = ALIGN(prog_data->nr_params, 4) / 4;
-   gather_dwords = 3 + num_consts;
-
-   /* Fetch the entries in 128-bit units. If the offset in the constant
-    * buffer pointing to the entry is > 4096 bytes, round it to the next
-    * gather bank slot. gen7_upload_constant_buffer_data() should have
-    * made sure that the entries are uploaded in the correct slots.
-    */
-   unsigned bo_offset = (stage_state->const_bo_offset / 16) % 256;
-   unsigned bti = stage_state->const_bo_offset / 4096;
-
-   BEGIN_BATCH(gather_dwords);
-   OUT_BATCH(gather_opcode << 16 | (gather_dwords - 2));
-   OUT_BATCH(0xffff << 16 | 1 << 12);
-   OUT_BATCH(stage_state->push_const_offset);
-   for (int i = 0; i < num_consts; i++) {
-      OUT_BATCH((bo_offset + i) << 8 | 0xF << 4 | bti);
+   if (!prog_data->nr_ubo_params) {
+      /* Generate gather entry only for uniforms */
+      int num_consts = ALIGN(prog_data->nr_params, 4) / 4;
+      gather_dwords = 3 + num_consts;
+
+      /* Fetch the entries in 128-bit units. If the offset in the constant
+       * buffer pointing to the entry is > 4096 bytes, round it to the next
+       * gather bank slot. gen7_upload_constant_buffer_data() should have
+       * made sure that the entries are uploaded in the correct slots.
+       */
+      unsigned bo_offset = (stage_state->const_bo_offset / 16) % 256;
+      unsigned bti = stage_state->const_bo_offset / 4096;
+
+      BEGIN_BATCH(gather_dwords);
+      OUT_BATCH(gather_opcode << 16 | (gather_dwords - 2));
+      OUT_BATCH(0xffff << 16 | 1 << 12);
+      OUT_BATCH(stage_state->push_const_offset);
+      for (int i = 0; i < num_consts; i++) {
+         OUT_BATCH((bo_offset + i) << 8 | 0xF << 4 | bti);
+      }
+      ADVANCE_BATCH();
+   } else {
+      /* Generate gather entry for UBOs + uniforms combined */
+      gather_dwords = 3 + prog_data->nr_gather_table;
+
+      BEGIN_BATCH(gather_dwords);
+      OUT_BATCH(gather_opcode << 16 | (gather_dwords - 2));
+      OUT_BATCH(0xffff << 16 | 1 << 12);
+      OUT_BATCH(stage_state->push_const_offset);
+      for (int i = 0; i < prog_data->nr_gather_table; i++) {
+         /* Which bo are we referring to? The uniform constant buffer or
+          * the UBO block?
+          */
+         bool is_uniform = prog_data->gather_table[i].reg < prog_data->nr_params;
+         int cb_offset = (is_uniform ?
+                          stage_state->const_bo_offset :
+                          prog_data->gather_table[i].const_offset) / 16;
+         int bt_offset = is_uniform ? 0 : prog_data->gather_table[i].const_block + 8;
+
+         OUT_BATCH(cb_offset << 8 | prog_data->gather_table[i].channel_mask << 4 | bt_offset);
+      }
+      ADVANCE_BATCH();
    }
-   ADVANCE_BATCH();
 }
 
 void
-- 
1.9.1



More information about the mesa-dev mailing list