[Mesa-dev] [PATCH 3/5] i965: Generalize brw_vec4_upload_binding_table() beyond vec4 stages.

Kenneth Graunke kenneth at whitecape.org
Mon Sep 16 22:14:08 PDT 2013


Instead of passing in a brw_vec4_prog_data structure, we can simply
pass the one field it needs: the number of entries in the binding table.

We also need to pass in the shader time surface index rather than
hardcoding SURF_INDEX_VEC4_SHADER_TIME.

Since the resulting function is stage-agnostic, this patch removes
"vec4_" from the name.

Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
---
 src/mesa/drivers/dri/i965/brw_gs_surface_state.c |  5 +++--
 src/mesa/drivers/dri/i965/brw_state.h            |  9 +++++----
 src/mesa/drivers/dri/i965/brw_vs_surface_state.c | 21 +++++++++++----------
 3 files changed, 19 insertions(+), 16 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_gs_surface_state.c b/src/mesa/drivers/dri/i965/brw_gs_surface_state.c
index bae6015..ad4c003 100644
--- a/src/mesa/drivers/dri/i965/brw_gs_surface_state.c
+++ b/src/mesa/drivers/dri/i965/brw_gs_surface_state.c
@@ -106,8 +106,9 @@ brw_gs_upload_binding_table(struct brw_context *brw)
    const struct brw_vec4_prog_data *prog_data = &brw->gs.prog_data->base;
 
    /* BRW_NEW_SURFACES and BRW_NEW_GS_CONSTBUF */
-   brw_vec4_upload_binding_table(brw, BRW_NEW_GS_BINDING_TABLE, stage_state,
-                                 prog_data);
+   brw_upload_binding_table(brw, BRW_NEW_GS_BINDING_TABLE, stage_state,
+                            prog_data->binding_table_size,
+                            SURF_INDEX_VEC4_SHADER_TIME);
 }
 
 const struct brw_tracked_state brw_gs_binding_table = {
diff --git a/src/mesa/drivers/dri/i965/brw_state.h b/src/mesa/drivers/dri/i965/brw_state.h
index 14f5feb..ec64328 100644
--- a/src/mesa/drivers/dri/i965/brw_state.h
+++ b/src/mesa/drivers/dri/i965/brw_state.h
@@ -240,10 +240,11 @@ brw_upload_vec4_pull_constants(struct brw_context *brw,
                                struct brw_stage_state *stage_state,
                                const struct brw_vec4_prog_data *prog_data);
 void
-brw_vec4_upload_binding_table(struct brw_context *brw,
-                              GLbitfield brw_new_binding_table,
-                              struct brw_stage_state *stage_state,
-                              const struct brw_vec4_prog_data *prog_data);
+brw_upload_binding_table(struct brw_context *brw,
+                         GLbitfield brw_new_binding_table,
+                         struct brw_stage_state *stage_state,
+                         unsigned binding_table_entries,
+                         int shader_time_surf_index);
 
 /* gen7_vs_state.c */
 void
diff --git a/src/mesa/drivers/dri/i965/brw_vs_surface_state.c b/src/mesa/drivers/dri/i965/brw_vs_surface_state.c
index 216ff47..6fbe8eb 100644
--- a/src/mesa/drivers/dri/i965/brw_vs_surface_state.c
+++ b/src/mesa/drivers/dri/i965/brw_vs_surface_state.c
@@ -151,18 +151,18 @@ const struct brw_tracked_state brw_vs_ubo_surfaces = {
 
 
 void
-brw_vec4_upload_binding_table(struct brw_context *brw,
-                              GLbitfield brw_new_binding_table,
-                              struct brw_stage_state *stage_state,
-                              const struct brw_vec4_prog_data *prog_data)
+brw_upload_binding_table(struct brw_context *brw,
+                         GLbitfield brw_new_binding_table,
+                         struct brw_stage_state *stage_state,
+                         unsigned binding_table_entries,
+                         int shader_time_surf_index)
 {
    if (INTEL_DEBUG & DEBUG_SHADER_TIME) {
-      gen7_create_shader_time_surface(brw, &stage_state->surf_offset[SURF_INDEX_VEC4_SHADER_TIME]);
+      gen7_create_shader_time_surface(brw, &stage_state->surf_offset[shader_time_surf_index]);
    }
 
    /* If there are no surfaces, skip making the binding table altogether. */
-   const unsigned entries = prog_data->binding_table_size;
-   if (entries == 0) {
+   if (binding_table_entries == 0) {
       if (stage_state->bind_bo_offset != 0) {
 	 brw->state.dirty.brw |= brw_new_binding_table;
 	 stage_state->bind_bo_offset = 0;
@@ -170,7 +170,7 @@ brw_vec4_upload_binding_table(struct brw_context *brw,
       return;
    }
 
-   size_t table_size_in_bytes = entries * sizeof(uint32_t);
+   size_t table_size_in_bytes = binding_table_entries * sizeof(uint32_t);
 
    uint32_t *bind = brw_state_batch(brw, AUB_TRACE_BINDING_TABLE,
                                     table_size_in_bytes, 32,
@@ -195,8 +195,9 @@ brw_vs_upload_binding_table(struct brw_context *brw)
    const struct brw_vec4_prog_data *prog_data = &brw->vs.prog_data->base;
 
    /* BRW_NEW_SURFACES and BRW_NEW_VS_CONSTBUF */
-   brw_vec4_upload_binding_table(brw, BRW_NEW_VS_BINDING_TABLE, stage_state,
-                                 prog_data);
+   brw_upload_binding_table(brw, BRW_NEW_VS_BINDING_TABLE, stage_state,
+                            prog_data->binding_table_size,
+                            SURF_INDEX_VEC4_SHADER_TIME);
 }
 
 const struct brw_tracked_state brw_vs_binding_table = {
-- 
1.8.3.4



More information about the mesa-dev mailing list