[Mesa-dev] [PATCH 14/17] i965: Grow the batch/state buffers if we need space and can't flush.

Chris Wilson chris at chris-wilson.co.uk
Fri Sep 8 09:29:05 UTC 2017


Quoting Kenneth Graunke (2017-09-08 08:19:03)
> On Wednesday, September 6, 2017 8:44:03 AM PDT Chris Wilson wrote:
> > Quoting Kenneth Graunke (2017-09-06 16:20:00)
> > > On Wednesday, September 6, 2017 3:08:44 AM PDT Chris Wilson wrote:
> > > > Quoting Kenneth Graunke (2017-09-06 01:09:47)
> [snip]
> > > > > +/* Don't exceed this - batchbuffers need to fit in the ring! */
> > > > 
> > > > I don't understand this comment. I probably just have the wrong pov, you
> > > > say ring and I then think of the legacy/lrc ringbuffer in the kernel.
> > > 
> > > My understanding was that the legacy Gen4-7.5 ringbuffer mode allocated a
> > > ringbuffer that was...128kB large?  So if you exceeded that size, the
> > > batch would not fit in the ring at all, and execbuf would fail.
> > 
> > We don't copy the batch into the ring, we just stick a
> > MI_BATCH_BUFFER_START in there (with a flush before/after and a
> > breadcrumb, along with any context switch, change of mm, etc).
> 
> Oh, right...so that doesn't make sense.
> 
> > 64k is indeed a magic limit for the state batch though, but as there's
> 
> What causes this limit?

Surface state is limited to 64k "elements". You would think that
element applies to the 32 byte descriptor, but empirically if you
reference a sampler beyond the 64k byte, it returns all 0.

> > no limit on the batch buffer size (after converting it to a pure command
> > stream, just the prospect of a timeout). Well... There is an implicit
> > assumption that you don't exceed 256KiB for a batch (as a limit for a gen2
> > workaround and a different gen7 workaround).
> > 
> > Elsewhere, I have used 256KiB batches (and then shrunk to fit) simply
> > because of UINT16_MAX dwords. (Which is kind of why the kernel assumes
> > that the upper reasonable maximum size is 256KiB for its w/a.)
> 
> Should I change this to 256kB then?

If you want an upper bound, sure. I don't think you have any plans that
require the kernel to care about your batchbuffer size :)
-Chris


More information about the mesa-dev mailing list