diff options
author | Kenneth Graunke <kenneth@whitecape.org> | 2013-11-21 14:07:12 -0800 |
---|---|---|
committer | Kenneth Graunke <kenneth@whitecape.org> | 2013-11-21 15:01:13 -0800 |
commit | 395a32717df494353703f3581edcd3ba380f16d6 (patch) | |
tree | 5d106133114ec2051f16f80484e81ab8b7fc02e4 /src/mesa/drivers/dri/i965/intel_batchbuffer.h | |
parent | 6bc40f9af5b35724caff9fa7ced47b2ca6183f22 (diff) | |
download | external_mesa3d-395a32717df494353703f3581edcd3ba380f16d6.zip external_mesa3d-395a32717df494353703f3581edcd3ba380f16d6.tar.gz external_mesa3d-395a32717df494353703f3581edcd3ba380f16d6.tar.bz2 |
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 <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
Diffstat (limited to 'src/mesa/drivers/dri/i965/intel_batchbuffer.h')
-rw-r--r-- | src/mesa/drivers/dri/i965/intel_batchbuffer.h | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/mesa/drivers/dri/i965/intel_batchbuffer.h b/src/mesa/drivers/dri/i965/intel_batchbuffer.h index 40b0a29..f7638bc 100644 --- a/src/mesa/drivers/dri/i965/intel_batchbuffer.h +++ b/src/mesa/drivers/dri/i965/intel_batchbuffer.h @@ -93,6 +93,7 @@ intel_batchbuffer_emit_dword(struct brw_context *brw, GLuint dword) assert(intel_batchbuffer_space(brw) >= 4); #endif brw->batch.map[brw->batch.used++] = dword; + assert(brw->batch.ring != UNKNOWN_RING); } static INLINE void @@ -106,17 +107,21 @@ intel_batchbuffer_require_space(struct brw_context *brw, GLuint sz, enum brw_gpu_ring ring) { /* If we're switching rings, implicitly flush the batch. */ - if (unlikely(ring != brw->batch.ring) && brw->batch.used && brw->gen >= 6) { + if (unlikely(ring != brw->batch.ring) && brw->batch.ring != UNKNOWN_RING && + brw->gen >= 6) { intel_batchbuffer_flush(brw); } - brw->batch.ring = ring; - #ifdef DEBUG assert(sz < BATCH_SZ - BATCH_RESERVED); #endif if (intel_batchbuffer_space(brw) < sz) intel_batchbuffer_flush(brw); + + /* 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; } static INLINE void |