[Mesa-dev] [PATCH 41/51] i965: Move all the render preamble together

Chris Wilson chris at chris-wilson.co.uk
Tue Jan 10 21:24:04 UTC 2017


Rather than split the render batch setup between two hooks, coalesce it
into a single callback. To simplify this, move some of the state
dirtying from the start to the finish hook hook.

Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
---
 src/mesa/drivers/dri/i965/brw_context.c       | 15 ++++++++++-----
 src/mesa/drivers/dri/i965/intel_batchbuffer.c | 16 ++++------------
 src/mesa/drivers/dri/i965/intel_batchbuffer.h |  1 -
 3 files changed, 14 insertions(+), 18 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c
index 4ee766e94f..99190f06cd 100644
--- a/src/mesa/drivers/dri/i965/brw_context.c
+++ b/src/mesa/drivers/dri/i965/brw_context.c
@@ -1755,6 +1755,9 @@ void brw_batch_start_hook(brw_batch *batch)
 {
    struct brw_context *brw = container_of(batch, brw, batch);
 
+   if (batch->ring != RENDER_RING)
+      return;
+
    /* If the kernel supports hardware contexts, then most hardware state is
     * preserved between batches; we only need to re-emit state that is required
     * to be in every batch.  Otherwise we need to re-emit all the state that
@@ -1763,13 +1766,8 @@ void brw_batch_start_hook(brw_batch *batch)
     */
    if (!batch->hw_ctx)
       brw->ctx.NewDriverState |= BRW_NEW_CONTEXT;
-
    brw->ctx.NewDriverState |= BRW_NEW_BATCH;
 
-   brw->state_batch_count = 0;
-
-   brw->ib.type = -1;
-
    /* We need to periodically reap the shader time results, because rollover
     * happens every few seconds.  We also want to see results every once in a
     * while, because many programs won't cleanly destroy our context, so the
@@ -1829,6 +1827,13 @@ void brw_batch_finish_hook(brw_batch *batch)
    brw_emit_query_end(brw);
 
    brw->cache.bo_used_by_gpu = true;
+
+   brw->state_batch_count = 0;
+
+   brw->ib.type = -1;
+
+   if (brw->use_resource_streamer)
+      gen7_reset_hw_bt_pool_offsets(brw);
 }
 
 void brw_batch_report_flush_hook(struct brw_batch *batch,
diff --git a/src/mesa/drivers/dri/i965/intel_batchbuffer.c b/src/mesa/drivers/dri/i965/intel_batchbuffer.c
index 4c5a640aff..7b2919f685 100644
--- a/src/mesa/drivers/dri/i965/intel_batchbuffer.c
+++ b/src/mesa/drivers/dri/i965/intel_batchbuffer.c
@@ -152,7 +152,7 @@ intel_batchbuffer_require_space(struct brw_batch *batch, GLuint sz,
    batch->ring = ring;
 
    if (unlikely(prev_ring == UNKNOWN_RING && ring == RENDER_RING))
-      intel_batchbuffer_emit_render_ring_prelude(batch);
+      brw_batch_start_hook(batch);
 }
 
 static void
@@ -195,12 +195,6 @@ do_batch_dump(struct brw_context *brw)
    }
 }
 
-void
-intel_batchbuffer_emit_render_ring_prelude(struct brw_batch *batch)
-{
-   /* Un-used currently */
-}
-
 /**
  * Called when starting a new batch buffer.
  */
@@ -210,8 +204,6 @@ brw_new_batch(struct brw_context *brw)
    /* Create a new batchbuffer and reset the associated state: */
    drm_intel_gem_bo_clear_relocs(brw->batch.bo, 0);
    intel_batchbuffer_reset(&brw->batch, brw->has_llc);
-
-   brw_batch_start_hook(&brw->batch);
 }
 
 static void
@@ -371,9 +363,6 @@ brw_batch_flush(struct brw_batch *batch, struct perf_debug *info)
       drm_intel_bo_wait_rendering(brw->batch.bo);
    }
 
-   if (brw->use_resource_streamer)
-      gen7_reset_hw_bt_pool_offsets(brw);
-
    /* Start a new batch buffer. */
    brw_new_batch(brw);
 
@@ -470,6 +459,9 @@ void brw_batch_end(struct brw_batch *batch)
          batch->no_batch_wrap = true;
 
          batch->ring = ring;
+         if (ring == RENDER_RING)
+            brw_batch_start_hook(batch);
+
          batch->repeat = true;
          longjmp(batch->jmpbuf, 1);
       }
diff --git a/src/mesa/drivers/dri/i965/intel_batchbuffer.h b/src/mesa/drivers/dri/i965/intel_batchbuffer.h
index b7c90df475..fb03c474a6 100644
--- a/src/mesa/drivers/dri/i965/intel_batchbuffer.h
+++ b/src/mesa/drivers/dri/i965/intel_batchbuffer.h
@@ -18,7 +18,6 @@ struct brw_batch;
 struct brw_context;
 enum brw_gpu_ring;
 
-void intel_batchbuffer_emit_render_ring_prelude(struct brw_batch *batch);
 int intel_batchbuffer_init(struct brw_batch *batch, dri_bufmgr *bufmgr,
                             int gen, bool has_llc);
 void intel_batchbuffer_free(struct brw_batch *brw);
-- 
2.11.0



More information about the mesa-dev mailing list