Revert 5 i965 patches: 8e27a4d2, 373143ed, c5bdf9be, 6f56e142, 88e3d404
[mesa.git] / src / mesa / drivers / dri / i965 / brw_binding_tables.c
index 9d15bac270e56662ebdae1eb18e833d64a71b2a8..30a54ef17344e1a6b5d69e9c601133584a3acf21 100644 (file)
  * This copies brw_stage_state::surf_offset[] into the indirect state section
  * of the batchbuffer (allocated by brw_state_batch()).
  */
-void
+static void
 brw_upload_binding_table(struct brw_context *brw,
+                         uint32_t packet_name,
                          GLbitfield brw_new_binding_table,
-                         struct brw_stage_state *stage_state,
-                         unsigned binding_table_entries,
-                         int shader_time_surf_index)
+                         struct brw_stage_state *stage_state)
 {
-   if (INTEL_DEBUG & DEBUG_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. */
-   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;
+   /* CACHE_NEW_*_PROG */
+   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)
+         return;
+
+      stage_state->bind_bo_offset = 0;
+   } else {
+      /* Upload a new binding table. */
+      if (INTEL_DEBUG & DEBUG_SHADER_TIME) {
+         brw->vtbl.create_raw_surface(
+            brw, brw->shader_time.bo, 0, brw->shader_time.bo->size,
+            &stage_state->surf_offset[prog_data->binding_table.shader_time_start], true);
       }
-      return;
-   }
-
-   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,
-                                    &stage_state->bind_bo_offset);
+      uint32_t *bind = brw_state_batch(brw, AUB_TRACE_BINDING_TABLE,
+                                       prog_data->binding_table.size_bytes, 32,
+                                       &stage_state->bind_bo_offset);
 
-   /* BRW_NEW_SURFACES and BRW_NEW_*_CONSTBUF */
-   memcpy(bind, stage_state->surf_offset, table_size_in_bytes);
+      /* BRW_NEW_SURFACES and BRW_NEW_*_CONSTBUF */
+      memcpy(bind, stage_state->surf_offset,
+             prog_data->binding_table.size_bytes);
+   }
 
    brw->state.dirty.brw |= brw_new_binding_table;
+
+   if (brw->gen >= 7) {
+      BEGIN_BATCH(2);
+      OUT_BATCH(packet_name << 16 | (2 - 2));
+      OUT_BATCH(stage_state->bind_bo_offset);
+      ADVANCE_BATCH();
+   }
 }
 
 /**
@@ -91,14 +101,9 @@ brw_upload_binding_table(struct brw_context *brw,
 static void
 brw_vs_upload_binding_table(struct brw_context *brw)
 {
-   struct brw_stage_state *stage_state = &brw->vs.base;
-   /* CACHE_NEW_VS_PROG */
-   const struct brw_vec4_prog_data *prog_data = &brw->vs.prog_data->base;
-
-   /* BRW_NEW_SURFACES and BRW_NEW_VS_CONSTBUF */
-   brw_upload_binding_table(brw, BRW_NEW_VS_BINDING_TABLE, stage_state,
-                            prog_data->binding_table_size,
-                            SURF_INDEX_VEC4_SHADER_TIME);
+   brw_upload_binding_table(brw,
+                            _3DSTATE_BINDING_TABLE_POINTERS_VS,
+                            BRW_NEW_VS_BINDING_TABLE, &brw->vs.base);
 }
 
 const struct brw_tracked_state brw_vs_binding_table = {
@@ -117,12 +122,9 @@ const struct brw_tracked_state brw_vs_binding_table = {
 static void
 brw_upload_wm_binding_table(struct brw_context *brw)
 {
-   struct brw_stage_state *stage_state = &brw->wm.base;
-
-   /* BRW_NEW_SURFACES and CACHE_NEW_WM_PROG */
-   brw_upload_binding_table(brw, BRW_NEW_PS_BINDING_TABLE, stage_state,
-                            brw->wm.prog_data->binding_table_size,
-                            SURF_INDEX_WM_SHADER_TIME);
+   brw_upload_binding_table(brw,
+                            _3DSTATE_BINDING_TABLE_POINTERS_PS,
+                            BRW_NEW_PS_BINDING_TABLE, &brw->wm.base);
 }
 
 const struct brw_tracked_state brw_wm_binding_table = {
@@ -138,19 +140,13 @@ const struct brw_tracked_state brw_wm_binding_table = {
 static void
 brw_gs_upload_binding_table(struct brw_context *brw)
 {
-   struct brw_stage_state *stage_state = &brw->gs.base;
-
    /* If there's no GS, skip changing anything. */
-   if (!brw->gs.prog_data)
+   if (brw->geometry_program == NULL)
       return;
 
-   /* CACHE_NEW_GS_PROG */
-   const struct brw_vec4_prog_data *prog_data = &brw->gs.prog_data->base;
-
-   /* BRW_NEW_SURFACES and BRW_NEW_GS_CONSTBUF */
-   brw_upload_binding_table(brw, BRW_NEW_GS_BINDING_TABLE, stage_state,
-                            prog_data->binding_table_size,
-                            SURF_INDEX_VEC4_SHADER_TIME);
+   brw_upload_binding_table(brw,
+                            _3DSTATE_BINDING_TABLE_POINTERS_GS,
+                            BRW_NEW_GS_BINDING_TABLE, &brw->gs.base);
 }
 
 const struct brw_tracked_state brw_gs_binding_table = {
@@ -237,6 +233,4 @@ const struct brw_tracked_state gen6_binding_table_pointers = {
    .emit = gen6_upload_binding_table_pointers,
 };
 
-/* Gen7+ code lives in gen7_{vs,gs,wm}_state.c. */
-
 /** @} */