i965: Refactor and expose brw_upload_binding_table()
authorTopi Pohjolainen <topi.pohjolainen@intel.com>
Thu, 19 Mar 2015 08:42:49 +0000 (10:42 +0200)
committerTopi Pohjolainen <topi.pohjolainen@intel.com>
Wed, 29 Apr 2015 21:28:47 +0000 (00:28 +0300)
Read and write parts of the state stage are also split into
explicit arguments allowing future patches to use constant
program data.

v2 (Ken): s/BRW_NEW_WM_PROG_DATA/BRW_NEW_FS_PROG_DATA/

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Matt Turner <mattst88@gmail.com>
Signed-off-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
src/mesa/drivers/dri/i965/brw_binding_tables.c
src/mesa/drivers/dri/i965/brw_state.h

index 459165a5aeb5d371d1cf10faa40cdb1885cce8b3..98ff0ddcd5828aa6f4cc950b0507df2ff4fcc940 100644 (file)
  * This copies brw_stage_state::surf_offset[] into the indirect state section
  * of the batchbuffer (allocated by brw_state_batch()).
  */
-static void
+void
 brw_upload_binding_table(struct brw_context *brw,
                          uint32_t packet_name,
                          GLbitfield brw_new_binding_table,
+                         const struct brw_stage_prog_data *prog_data,
                          struct brw_stage_state *stage_state)
 {
-   /* BRW_NEW_*_PROG_DATA */
-   struct brw_stage_prog_data *prog_data = stage_state->prog_data;
-
    if (prog_data->binding_table.size_bytes == 0) {
       /* There are no surfaces; skip making the binding table altogether. */
       if (stage_state->bind_bo_offset == 0 && brw->gen < 9)
@@ -103,9 +101,12 @@ brw_upload_binding_table(struct brw_context *brw,
 static void
 brw_vs_upload_binding_table(struct brw_context *brw)
 {
+   /* BRW_NEW_VS_PROG_DATA */
+   const struct brw_stage_prog_data *prog_data = brw->vs.base.prog_data;
    brw_upload_binding_table(brw,
                             _3DSTATE_BINDING_TABLE_POINTERS_VS,
-                            BRW_NEW_VS_BINDING_TABLE, &brw->vs.base);
+                            BRW_NEW_VS_BINDING_TABLE, prog_data,
+                            &brw->vs.base);
 }
 
 const struct brw_tracked_state brw_vs_binding_table = {
@@ -124,9 +125,12 @@ const struct brw_tracked_state brw_vs_binding_table = {
 static void
 brw_upload_wm_binding_table(struct brw_context *brw)
 {
+   /* BRW_NEW_FS_PROG_DATA */
+   const struct brw_stage_prog_data *prog_data = brw->wm.base.prog_data;
    brw_upload_binding_table(brw,
                             _3DSTATE_BINDING_TABLE_POINTERS_PS,
-                            BRW_NEW_PS_BINDING_TABLE, &brw->wm.base);
+                            BRW_NEW_PS_BINDING_TABLE, prog_data,
+                            &brw->wm.base);
 }
 
 const struct brw_tracked_state brw_wm_binding_table = {
@@ -147,9 +151,12 @@ brw_gs_upload_binding_table(struct brw_context *brw)
    if (brw->geometry_program == NULL)
       return;
 
+   /* BRW_NEW_GS_PROG_DATA */
+   const struct brw_stage_prog_data *prog_data = brw->gs.base.prog_data;
    brw_upload_binding_table(brw,
                             _3DSTATE_BINDING_TABLE_POINTERS_GS,
-                            BRW_NEW_GS_BINDING_TABLE, &brw->gs.base);
+                            BRW_NEW_GS_BINDING_TABLE, prog_data,
+                            &brw->gs.base);
 }
 
 const struct brw_tracked_state brw_gs_binding_table = {
index 83058b9ba2ad30f402b7ccd54e9f23096ca00f41..8798369bf7be6e1be847304efd6f0a3e3dde2b23 100644 (file)
@@ -159,6 +159,13 @@ brw_state_dirty(struct brw_context *brw, GLuint mesa_flags, uint64_t brw_flags)
            (brw->ctx.NewDriverState & brw_flags)) != 0;
 }
 
+/* brw_binding_tables.c */
+void brw_upload_binding_table(struct brw_context *brw,
+                              uint32_t packet_name,
+                              GLbitfield brw_new_binding_table,
+                              const struct brw_stage_prog_data *prog_data,
+                              struct brw_stage_state *stage_state);
+
 /* brw_misc_state.c */
 void brw_upload_invariant_state(struct brw_context *brw);
 uint32_t