i965/blorp: Add a helper for emitting surface states
authorJason Ekstrand <jason.ekstrand@intel.com>
Thu, 11 Aug 2016 00:11:45 +0000 (17:11 -0700)
committerJason Ekstrand <jason.ekstrand@intel.com>
Fri, 19 Aug 2016 10:11:29 +0000 (03:11 -0700)
The new helper emits surface states and the binding table in one go.  It's
nice to have it pulled out of the main blorp_exec function.

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
src/mesa/drivers/dri/i965/genX_blorp_exec.c

index faa0bfc83d47580a2b4e9f96b636d0e3077091d3..283b1525067b0c49293bccd8d360603b4819da81 100644 (file)
@@ -331,6 +331,32 @@ blorp_emit_depth_stencil_state(struct brw_context *brw,
    return offset;
 }
 
+static void
+blorp_emit_surface_states(struct brw_context *brw,
+                          const struct brw_blorp_params *params)
+{
+   uint32_t bind_offset;
+   uint32_t *bind =
+      brw_state_batch(brw, AUB_TRACE_BINDING_TABLE,
+                      sizeof(uint32_t) * BRW_BLORP_NUM_BINDING_TABLE_ENTRIES,
+                      32, /* alignment */ &bind_offset);
+
+   bind[BRW_BLORP_RENDERBUFFER_BINDING_TABLE_INDEX] =
+      brw_blorp_emit_surface_state(brw, &params->dst,
+                                   I915_GEM_DOMAIN_RENDER,
+                                   I915_GEM_DOMAIN_RENDER, true);
+   if (params->src.bo) {
+      bind[BRW_BLORP_TEXTURE_BINDING_TABLE_INDEX] =
+         brw_blorp_emit_surface_state(brw, &params->src,
+                                      I915_GEM_DOMAIN_SAMPLER, 0, false);
+   }
+
+   blorp_emit(brw, GENX(3DSTATE_BINDING_TABLE_POINTERS), bt) {
+      bt.PSBindingTableChange = true;
+      bt.PointertoPSBindingTable = bind_offset;
+   }
+}
+
 static void
 blorp_emit_sampler_state(struct brw_context *brw,
                          const struct brw_blorp_params *params)
@@ -407,7 +433,6 @@ genX(blorp_exec)(struct brw_context *brw,
    uint32_t blend_state_offset = 0;
    uint32_t color_calc_state_offset = 0;
    uint32_t depth_stencil_state_offset;
-   uint32_t wm_bind_bo_offset = 0;
 
    /* Emit workaround flushes when we switch from drawing to blorping. */
    brw_emit_post_sync_nonzero_flush(brw);
@@ -462,29 +487,8 @@ genX(blorp_exec)(struct brw_context *brw,
    blorp_emit(brw, GENX(3DSTATE_CONSTANT_GS), gs);
    blorp_emit(brw, GENX(3DSTATE_CONSTANT_PS), ps);
 
-   if (params->wm_prog_data) {
-      uint32_t wm_surf_offset_renderbuffer;
-      uint32_t wm_surf_offset_texture = 0;
-
-      wm_surf_offset_renderbuffer =
-         brw_blorp_emit_surface_state(brw, &params->dst,
-                                      I915_GEM_DOMAIN_RENDER,
-                                      I915_GEM_DOMAIN_RENDER, true);
-      if (params->src.bo) {
-         wm_surf_offset_texture =
-            brw_blorp_emit_surface_state(brw, &params->src,
-                                         I915_GEM_DOMAIN_SAMPLER, 0, false);
-      }
-      wm_bind_bo_offset =
-         gen6_blorp_emit_binding_table(brw,
-                                       wm_surf_offset_renderbuffer,
-                                       wm_surf_offset_texture);
-
-      blorp_emit(brw, GENX(3DSTATE_BINDING_TABLE_POINTERS), bt) {
-         bt.PSBindingTableChange = true;
-         bt.PointertoPSBindingTable = wm_bind_bo_offset;
-      }
-   }
+   if (params->wm_prog_data)
+      blorp_emit_surface_states(brw, params);
 
    if (params->src.bo)
       blorp_emit_sampler_state(brw, params);