aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRob Clark2016-06-01 14:37:52 -0500
committerRob Clark2016-07-20 18:42:21 -0500
commit8a6a8512d4ac6db5e85911de81f156d325dcc343 (patch)
tree6c3cfb3f88401516a6554e51e7c21226b66c857f /freedreno
parent904f1361ae11d53ee4d0cf297d38f4c243ee8d69 (diff)
downloadexternal-libdrm-8a6a8512d4ac6db5e85911de81f156d325dcc343.tar.gz
external-libdrm-8a6a8512d4ac6db5e85911de81f156d325dcc343.tar.xz
external-libdrm-8a6a8512d4ac6db5e85911de81f156d325dcc343.zip
freedreno: support either coarse or fine-grained bucket sizes
The normal bo cache uses some intermediate steps between power of two jumps to reduce memory wastage. But for a ringbuffer bo cache, we do not need this. Signed-off-by: Rob Clark <robclark@freedesktop.org>
Diffstat (limited to 'freedreno')
-rw-r--r--freedreno/freedreno_bo_cache.c17
-rw-r--r--freedreno/freedreno_device.c2
-rw-r--r--freedreno/freedreno_priv.h2
3 files changed, 14 insertions, 7 deletions
diff --git a/freedreno/freedreno_bo_cache.c b/freedreno/freedreno_bo_cache.c
index 58d171eb..7becb0d6 100644
--- a/freedreno/freedreno_bo_cache.c
+++ b/freedreno/freedreno_bo_cache.c
@@ -49,8 +49,12 @@ add_bucket(struct fd_bo_cache *cache, int size)
49 cache->num_buckets++; 49 cache->num_buckets++;
50} 50}
51 51
52/**
53 * @coarse: if true, only power-of-two bucket sizes, otherwise
54 * fill in for a bit smoother size curve..
55 */
52drm_private void 56drm_private void
53fd_bo_cache_init(struct fd_bo_cache *cache) 57fd_bo_cache_init(struct fd_bo_cache *cache, int course)
54{ 58{
55 unsigned long size, cache_max_size = 64 * 1024 * 1024; 59 unsigned long size, cache_max_size = 64 * 1024 * 1024;
56 60
@@ -64,14 +68,17 @@ fd_bo_cache_init(struct fd_bo_cache *cache)
64 */ 68 */
65 add_bucket(cache, 4096); 69 add_bucket(cache, 4096);
66 add_bucket(cache, 4096 * 2); 70 add_bucket(cache, 4096 * 2);
67 add_bucket(cache, 4096 * 3); 71 if (!course)
72 add_bucket(cache, 4096 * 3);
68 73
69 /* Initialize the linked lists for BO reuse cache. */ 74 /* Initialize the linked lists for BO reuse cache. */
70 for (size = 4 * 4096; size <= cache_max_size; size *= 2) { 75 for (size = 4 * 4096; size <= cache_max_size; size *= 2) {
71 add_bucket(cache, size); 76 add_bucket(cache, size);
72 add_bucket(cache, size + size * 1 / 4); 77 if (!course) {
73 add_bucket(cache, size + size * 2 / 4); 78 add_bucket(cache, size + size * 1 / 4);
74 add_bucket(cache, size + size * 3 / 4); 79 add_bucket(cache, size + size * 2 / 4);
80 add_bucket(cache, size + size * 3 / 4);
81 }
75 } 82 }
76} 83}
77 84
diff --git a/freedreno/freedreno_device.c b/freedreno/freedreno_device.c
index b99bce2f..fcbf1402 100644
--- a/freedreno/freedreno_device.c
+++ b/freedreno/freedreno_device.c
@@ -85,7 +85,7 @@ out:
85 dev->fd = fd; 85 dev->fd = fd;
86 dev->handle_table = drmHashCreate(); 86 dev->handle_table = drmHashCreate();
87 dev->name_table = drmHashCreate(); 87 dev->name_table = drmHashCreate();
88 fd_bo_cache_init(&dev->bo_cache); 88 fd_bo_cache_init(&dev->bo_cache, FALSE);
89 89
90 return dev; 90 return dev;
91} 91}
diff --git a/freedreno/freedreno_priv.h b/freedreno/freedreno_priv.h
index 5e8f03d4..9737b322 100644
--- a/freedreno/freedreno_priv.h
+++ b/freedreno/freedreno_priv.h
@@ -104,7 +104,7 @@ struct fd_device {
104 int closefd; /* call close(fd) upon destruction */ 104 int closefd; /* call close(fd) upon destruction */
105}; 105};
106 106
107drm_private void fd_bo_cache_init(struct fd_bo_cache *cache); 107drm_private void fd_bo_cache_init(struct fd_bo_cache *cache, int coarse);
108drm_private void fd_bo_cache_cleanup(struct fd_bo_cache *cache, time_t time); 108drm_private void fd_bo_cache_cleanup(struct fd_bo_cache *cache, time_t time);
109drm_private struct fd_bo * fd_bo_cache_alloc(struct fd_bo_cache *cache, 109drm_private struct fd_bo * fd_bo_cache_alloc(struct fd_bo_cache *cache,
110 uint32_t *size, uint32_t flags); 110 uint32_t *size, uint32_t flags);