intel: Add an interface for removing relocs after they're added.
authorEric Anholt <eric@anholt.net>
Sat, 22 Oct 2011 01:48:20 +0000 (18:48 -0700)
committerEric Anholt <eric@anholt.net>
Fri, 28 Oct 2011 19:53:59 +0000 (12:53 -0700)
commit515cea6ac67eb458c59fececc3c67411ee6fd3c3
tree368a33f6d8187ac96bf54443bd4d6bd9cd848cbf
parent2c2bdb36c5b6bd7f8eac07cf163975b361114fb1
intel: Add an interface for removing relocs after they're added.

This lets us replace the current inner drawing loop of mesa:

for each prim {
compute bo list
if (check_aperture_space(bo list)) {
batch_flush()
compute bo list
if (check_aperture_space(bo list)) {
whine_about_batch_size()
fall back;
}
}
upload state to BOs
}

with this inner loop:

for each prim {
 retry:
upload state to BOs
if (check_aperture_space(batch)) {
if (!retried) {
reset_to_last_prim()
batch_flush()
} else {
if (batch_flush())
whine_about_batch_size()
goto retry;
}
}
}

This avoids having to implement code to walk over certain sets of GL
state twice (the "compute bo list" step).  While it's not a
performance improvement, it's a significant win in code complexity:
about -200 lines, and one place to make mistakes related to aperture
space instead of N places to forget some BO we should have included.

Note how if we do a reset in the new loop , we immediately flush.  We
don't need to check aperture space -- the kernel will tell us if we
actually ran out of aperture or not.  And if we did run out of
aperture, it's because either the single prim was too big, or because
check_aperture was wrong at the point of setting up the last
primitive.

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
intel/intel_bufmgr.h
intel/intel_bufmgr_gem.c