summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorThomas Hellstrom <[email protected]>2014-02-08 09:51:15 -0800
committerBrian Paul <[email protected]>2014-02-26 13:35:59 -0700
commit19740e30852d18c8d864cb26f0865ed22bac2ed3 (patch)
tree36115012d1e72de8612a05647a1663241d9049ed /src
parenta44639d826a3db7f4fd6ceef836fc4e62bdf0373 (diff)
gallium/pipebuffer: Add a cache buffer manager bypass mask
In some situations, it may be desirable to bypass the cache at buffer creation but to insert the buffer in the cache at buffer destruction. One such situation is where we already have a kernel representation of a buffer that we want to use, but we also want to insert it in the cache when it's freed up. Signed-off-by: Thomas Hellstrom <[email protected]> Reviewed-by: José Fonseca <[email protected]> Reviewed-by: Brian Paul <[email protected]> Cc: "10.1" <[email protected]> (cherry picked from commit 8af358d8bc9f7563cd76313b16d7b149197a4b2c)
Diffstat (limited to 'src')
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_bufmgr.h3
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c23
-rw-r--r--src/gallium/winsys/radeon/drm/radeon_drm_winsys.c2
3 files changed, 23 insertions, 5 deletions
diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr.h b/src/gallium/auxiliary/pipebuffer/pb_bufmgr.h
index fe4c8c20071..3044ec881fd 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr.h
+++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr.h
@@ -162,7 +162,8 @@ pb_slab_range_manager_create(struct pb_manager *provider,
struct pb_manager *
pb_cache_manager_create(struct pb_manager *provider,
unsigned usecs,
- unsigned size_factor);
+ unsigned size_factor,
+ unsigned bypass_usage);
struct pb_fence_ops;
diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c
index 6de5de04fe9..0469146d15b 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c
@@ -83,6 +83,7 @@ struct pb_cache_manager
struct list_head delayed;
pb_size numDelayed;
unsigned size_factor;
+ unsigned bypass_usage;
};
@@ -228,6 +229,9 @@ pb_cache_is_buffer_compat(struct pb_cache_buffer *buf,
pb_size size,
const struct pb_desc *desc)
{
+ if (desc->usage & buf->mgr->bypass_usage)
+ return 0;
+
if(buf->base.size < size)
return 0;
@@ -339,7 +343,7 @@ pb_cache_manager_create_buffer(struct pb_manager *_mgr,
assert(pipe_is_referenced(&buf->buffer->reference));
assert(pb_check_alignment(desc->alignment, buf->buffer->alignment));
- assert(pb_check_usage(desc->usage, buf->buffer->usage));
+ assert(pb_check_usage(desc->usage & ~mgr->bypass_usage, buf->buffer->usage));
assert(buf->buffer->size >= size);
pipe_reference_init(&buf->base.reference, 1);
@@ -385,11 +389,23 @@ pb_cache_manager_destroy(struct pb_manager *mgr)
FREE(mgr);
}
-
+/**
+ * Create a caching buffer manager
+ *
+ * @param provider The buffer manager to which cache miss buffer requests
+ * should be redirected.
+ * @param usecs Unused buffers may be released from the cache after this
+ * time
+ * @param size_factor Declare buffers that are size_factor times bigger than
+ * the requested size as cache hits.
+ * @param bypass_usage Bitmask. If (requested usage & bypass_usage) != 0,
+ * buffer allocation requests are redirected to the provider.
+ */
struct pb_manager *
pb_cache_manager_create(struct pb_manager *provider,
unsigned usecs,
- unsigned size_factor)
+ unsigned size_factor,
+ unsigned bypass_usage)
{
struct pb_cache_manager *mgr;
@@ -406,6 +422,7 @@ pb_cache_manager_create(struct pb_manager *provider,
mgr->provider = provider;
mgr->usecs = usecs;
mgr->size_factor = size_factor;
+ mgr->bypass_usage = bypass_usage;
LIST_INITHEAD(&mgr->delayed);
mgr->numDelayed = 0;
pipe_mutex_init(mgr->mutex);
diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c b/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c
index 7b931587bd7..af94a4cf769 100644
--- a/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c
+++ b/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c
@@ -627,7 +627,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, 2);
+ ws->cman = pb_cache_manager_create(ws->kman, 1000000, 2, 0);
if (!ws->cman)
goto fail;