[Mesa-dev] [PATCH 10/27] i965: Allocate space on the gather pool for UBO entries

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


If there are UBO constant entries, append them to stage_state->push_const_size.
The gather pool contains the combined entries of both ordinary uniforms
and UBO constants.

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

diff --git a/src/mesa/drivers/dri/i965/gen6_vs_state.c b/src/mesa/drivers/dri/i965/gen6_vs_state.c
index aebaa49..7325c6e 100644
--- a/src/mesa/drivers/dri/i965/gen6_vs_state.c
+++ b/src/mesa/drivers/dri/i965/gen6_vs_state.c
@@ -59,7 +59,9 @@ gen6_upload_push_constants(struct brw_context *brw,
    struct gl_context *ctx = &brw->ctx;
 
    if (prog_data->nr_params == 0) {
-      stage_state->push_const_size = 0;
+      if (prog_data->nr_ubo_params == 0) {
+         stage_state->push_const_size = 0;
+      }
    } else {
       /* Updates the ParamaterValues[i] pointers for all parameters of the
        * basic type of PROGRAM_STATE_VAR.
@@ -122,10 +124,24 @@ gen6_upload_push_constants(struct brw_context *brw,
    }
    /* Allocate gather pool space for uniform and UBO entries in 512-bit chunks*/
    if (brw->gather_pool.bo != NULL) {
+      unsigned gather_pool_next_offset = brw->gather_pool.next_offset;
+
       if (prog_data->nr_params > 0) {
          int num_consts = ALIGN(prog_data->nr_params, 4) / 4;
+         gather_pool_next_offset += (ALIGN(num_consts, 4) / 4) * 64;
+      }
+
+      if (prog_data->nr_ubo_params > 0) {
+         stage_state->push_const_size = ALIGN(prog_data->nr_params + prog_data->nr_ubo_params, 8) / 8;
+         uint32_t num_constants = ALIGN(prog_data->nr_ubo_params, 4) / 4;
+         gather_pool_next_offset += (ALIGN(num_constants, 4) / 4) * 64;
+      }
+
+      if (gather_pool_next_offset > brw->gather_pool.next_offset) {
          stage_state->push_const_offset = brw->gather_pool.next_offset;
-         brw->gather_pool.next_offset += (ALIGN(num_consts, 4) / 4) * 64;
+         brw->gather_pool.next_offset = gather_pool_next_offset;
+         assert(brw->gather_pool.next_offset < brw->gather_pool.bo->size);
+         assert(stage_state->push_const_offset < brw->gather_pool.next_offset);
       }
    }
 }
-- 
1.9.1



More information about the mesa-dev mailing list