From 395a32717df494353703f3581edcd3ba380f16d6 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Thu, 21 Nov 2013 14:07:12 -0800 Subject: i965: Introduce an UNKNOWN_RING state. When we first create a batch buffer, it's empty. We don't actually know what ring it will be targeted at until the first BEGIN_BATCH or BEGIN_BATCH_BLT macro. Previously, one could determine the state of the batch by checking brw->batch.ring (blit vs. render) and brw->batch.used != 0 (known vs. unknown). This should be functionally equivalent, but the tri-state enum is a bit clearer. v2: Catch three explicit require_space callers (thanks to Carl and Eric). v3: Split the boolean -> enum change from the UNKNOWN_RING change. Signed-off-by: Kenneth Graunke Reviewed-by: Eric Anholt --- src/mesa/drivers/dri/i965/intel_batchbuffer.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/mesa/drivers/dri/i965/intel_batchbuffer.c') diff --git a/src/mesa/drivers/dri/i965/intel_batchbuffer.c b/src/mesa/drivers/dri/i965/intel_batchbuffer.c index 672bc021486..d8eb3fc8837 100644 --- a/src/mesa/drivers/dri/i965/intel_batchbuffer.c +++ b/src/mesa/drivers/dri/i965/intel_batchbuffer.c @@ -100,6 +100,11 @@ intel_batchbuffer_reset(struct brw_context *brw) brw->batch.state_batch_offset = brw->batch.bo->size; brw->batch.used = 0; brw->batch.needs_sol_reset = false; + + /* We don't know what ring the new batch will be sent to until we see the + * first BEGIN_BATCH or BEGIN_BATCH_BLT. Mark it as unknown. + */ + brw->batch.ring = UNKNOWN_RING; } void @@ -116,6 +121,8 @@ intel_batchbuffer_reset_to_saved(struct brw_context *brw) drm_intel_gem_bo_clear_relocs(brw->batch.bo, brw->batch.saved.reloc_count); brw->batch.used = brw->batch.saved.used; + if (brw->batch.used == 0) + brw->batch.ring = UNKNOWN_RING; /* Cached batch state is dead, since we just cleared some unknown part of the * batchbuffer. Assume that the caller resets any other state necessary. @@ -429,6 +436,7 @@ intel_batchbuffer_cached_advance(struct brw_context *brw) brw->batch.cached_items = item; } brw->batch.used = brw->batch.emit; + assert(brw->batch.used > 0); return; } -- cgit v1.2.3