pipebuffer, winsys: Add a size match parameter to the cached buffer manager

In some situations it's important to restrict the sizes of buffers that the
cached buffer manager is allowed to return

Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
Cc: "10.1" <mesa-stable@lists.freedesktop.org>
This commit is contained in:
Thomas Hellstrom 2014-02-08 09:51:15 -08:00 committed by Brian Paul
parent 3d1fd6df53
commit c9e9b1862b
3 changed files with 8 additions and 4 deletions

View File

@ -161,7 +161,8 @@ pb_slab_range_manager_create(struct pb_manager *provider,
*/
struct pb_manager *
pb_cache_manager_create(struct pb_manager *provider,
unsigned usecs);
unsigned usecs,
unsigned size_factor);
struct pb_fence_ops;

View File

@ -82,6 +82,7 @@ struct pb_cache_manager
struct list_head delayed;
pb_size numDelayed;
unsigned size_factor;
};
@ -231,7 +232,7 @@ pb_cache_is_buffer_compat(struct pb_cache_buffer *buf,
return 0;
/* be lenient with size */
if(buf->base.size >= 2*size)
if(buf->base.size > buf->mgr->size_factor*size)
return 0;
if(!pb_check_alignment(desc->alignment, buf->base.alignment))
@ -387,7 +388,8 @@ pb_cache_manager_destroy(struct pb_manager *mgr)
struct pb_manager *
pb_cache_manager_create(struct pb_manager *provider,
unsigned usecs)
unsigned usecs,
unsigned size_factor)
{
struct pb_cache_manager *mgr;
@ -403,6 +405,7 @@ pb_cache_manager_create(struct pb_manager *provider,
mgr->base.flush = pb_cache_manager_flush;
mgr->provider = provider;
mgr->usecs = usecs;
mgr->size_factor = size_factor;
LIST_INITHEAD(&mgr->delayed);
mgr->numDelayed = 0;
pipe_mutex_init(mgr->mutex);

View File

@ -645,7 +645,7 @@ PUBLIC struct radeon_winsys *radeon_drm_winsys_create(int fd)
ws->kman = radeon_bomgr_create(ws);
if (!ws->kman)
goto fail;
ws->cman = pb_cache_manager_create(ws->kman, 1000000);
ws->cman = pb_cache_manager_create(ws->kman, 1000000, 2);
if (!ws->cman)
goto fail;