i965: Fix brw_finish_batch to grow the batchbuffer.
authorKenneth Graunke <kenneth@whitecape.org>
Mon, 18 Sep 2017 16:55:57 +0000 (09:55 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Thu, 21 Sep 2017 16:33:50 +0000 (09:33 -0700)
commit3bec992e367656bf8f043750dd0ab1cb643d34bc
treecf5bd5b2c15e2705dac46e41164c116903f3173b
parent5a746021ce786cc9ad450ddfce587ae24060eec0
i965: Fix brw_finish_batch to grow the batchbuffer.

brw_finish_batch emits commands needed at the end of every batch buffer,
including any workarounds.  In the past, we freed up some "reserved"
batch space before calling it, so we would never have to flush during
it.  This was error prone and easy to screw up, so I deleted it a while
back in favor of growing the batch.

There were two problems:

1. We're in the middle of flushing, so brw->no_batch_wrap is guaranteed
   not to be set.  Using BEGIN_BATCH() to emit commands would cause a
   recursive flush rather than growing the buffer as intended.

2. We already recorded the throttling batch before growing, which
   replaces brw->batch.bo with a different (larger) buffer.  So growing
   would break throttling.

These are easily remedied by shuffling some code around and whacking
brw->no_batch_wrap in brw_finish_batch().  This also now includes the
final workarounds in the batch usage statistics.  Found by inspection.

Fixes: 2c46a67b4138631217141f (i965: Delete BATCH_RESERVED handling.)
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
src/mesa/drivers/dri/i965/intel_batchbuffer.c