sna: Search the inactive bo cache for a mappable upload buffer

See if we have a bo that we can cheaply map to an inplace upload, rather
than rely on an existing GTT map.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
This commit is contained in:
Chris Wilson 2012-05-27 16:54:29 +01:00
parent 36d53ff52b
commit 35291d2db8
1 changed files with 19 additions and 6 deletions

View File

@ -153,21 +153,25 @@ static int gem_set_tiling(int fd, uint32_t handle, int tiling, int stride)
static bool __kgem_throttle_retire(struct kgem *kgem, unsigned flags)
{
if (flags & CREATE_NO_RETIRE)
if (flags & CREATE_NO_RETIRE) {
DBG(("%s: not retiring per-request\n", __FUNCTION__));
return false;
}
if (!kgem->need_retire)
if (!kgem->need_retire) {
DBG(("%s: nothing to retire\n", __FUNCTION__));
return false;
}
if (kgem_retire(kgem))
return true;
if (!kgem->need_throttle)
if (flags & CREATE_NO_THROTTLE || !kgem->need_throttle) {
DBG(("%s: not throttling\n", __FUNCTION__));
return false;
}
if ((flags & CREATE_NO_THROTTLE) == 0)
kgem_throttle(kgem);
kgem_throttle(kgem);
return kgem_retire(kgem);
}
@ -3707,6 +3711,8 @@ struct kgem_bo *kgem_create_buffer(struct kgem *kgem,
* XXX This is especially noticeable on memory constrained
* devices like gen2 or with relatively slow gpu like i3.
*/
DBG(("%s: searching for an inactive GTT map for upload\n",
__FUNCTION__));
old = search_linear_cache(kgem, alloc,
CREATE_EXACT | CREATE_INACTIVE | CREATE_GTT_MAP);
#if HAVE_I915_GEM_BUFFER_INFO
@ -3731,6 +3737,13 @@ struct kgem_bo *kgem_create_buffer(struct kgem *kgem,
if (old == NULL)
old = search_linear_cache(kgem, NUM_PAGES(size),
CREATE_EXACT | CREATE_INACTIVE | CREATE_GTT_MAP);
if (old == NULL) {
old = search_linear_cache(kgem, alloc, CREATE_INACTIVE);
if (old && !kgem_bo_is_mappable(kgem, old)) {
_kgem_bo_destroy(kgem, old);
old = NULL;
}
}
if (old) {
DBG(("%s: reusing handle=%d for buffer\n",
__FUNCTION__, old->handle));