i965: Generalize brw_vec4_upload_binding_table() beyond vec4 stages.
authorKenneth Graunke <kenneth@whitecape.org>
Fri, 13 Sep 2013 22:13:49 +0000 (15:13 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Thu, 19 Sep 2013 17:52:57 +0000 (10:52 -0700)
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@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
src/mesa/drivers/dri/i965/brw_gs_surface_state.c
src/mesa/drivers/dri/i965/brw_state.h
src/mesa/drivers/dri/i965/brw_vs_surface_state.c

index bae60154d45c892b17c8f08bdb4eabfebaffc6d0..ad4c0035e8fb8d8dec6f8e12ae862a0e1dec660c 100644 (file)
@@ -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 = {
index 14f5feb0c61813cc7e3fce1baca5098a6ed37c6f..ec64328f38be6b73362ea0e879b09935587e29ae 100644 (file)
@@ -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
index 216ff4734bc75b143f0346f53d8f9daf92d4ffd1..6fbe8ebad25617b3dd16fff680bad550139dfa85 100644 (file)
@@ -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 = {