i965: Introduce a "render ring prelude" hook.
authorKenneth Graunke <kenneth@whitecape.org>
Tue, 29 Oct 2013 03:10:40 +0000 (20:10 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Thu, 21 Nov 2013 23:01:13 +0000 (15:01 -0800)
The new intel_batchbuffer_emit_render_ring_prelude() hook will be called
when switching from BLT or UNKNOWN_RING to RENDER_RING.  This provides a
place to emit state that should go at the start of each render ring
batch, with minimal overhead.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
src/mesa/drivers/dri/i965/intel_batchbuffer.c
src/mesa/drivers/dri/i965/intel_batchbuffer.h

index d8eb3fc883797921123397f9896929e94d4ee2f6..d054e444d9fb4cfc9f426cef9571498c4a6342b2 100644 (file)
@@ -179,6 +179,11 @@ do_batch_dump(struct brw_context *brw)
    }
 }
 
+void
+intel_batchbuffer_emit_render_ring_prelude(struct brw_context *brw)
+{
+}
+
 /**
  * Called when starting a new batch buffer.
  */
index f7638bcb3d823d75f2b8270a7a11306ecb50f84f..861aed418bf0553d21227310dec5be20991e468f 100644 (file)
@@ -24,6 +24,7 @@ extern "C" {
 
 struct intel_batchbuffer;
 
+void intel_batchbuffer_emit_render_ring_prelude(struct brw_context *brw);
 void intel_batchbuffer_init(struct brw_context *brw);
 void intel_batchbuffer_free(struct brw_context *brw);
 void intel_batchbuffer_save_state(struct brw_context *brw);
@@ -118,10 +119,14 @@ intel_batchbuffer_require_space(struct brw_context *brw, GLuint sz,
    if (intel_batchbuffer_space(brw) < sz)
       intel_batchbuffer_flush(brw);
 
+   enum brw_gpu_ring prev_ring = brw->batch.ring;
    /* The intel_batchbuffer_flush() calls above might have changed
     * brw->batch.ring to UNKNOWN_RING, so we need to set it here at the end.
     */
    brw->batch.ring = ring;
+
+   if (unlikely(prev_ring == UNKNOWN_RING && ring == RENDER_RING))
+      intel_batchbuffer_emit_render_ring_prelude(brw);
 }
 
 static INLINE void