aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/lima/lima_screen.h
diff options
context:
space:
mode:
authorVasily Khoruzhick <[email protected]>2019-09-07 19:33:07 -0700
committerVasily Khoruzhick <[email protected]>2019-09-22 19:20:59 -0700
commitd2147787534de87cd11015266293211b5188442f (patch)
tree823202fabe8f330fc6360a2a02dbc881e2280181 /src/gallium/drivers/lima/lima_screen.h
parent9f897a2b4cf2c0e222487470053a69de843f2084 (diff)
lima: implement BO cache
Allocating BOs is expensive, so we should avoid doing that by caching freed BOs. BO cache is modelled after one in v3d driver and works as follows: - in lima_bo_create() check if we have matching BO in cache and return it if there's one, allocate new BO otherwise. - in lima_bo_unreference() (renamed from lima_bo_free()): put BO in cache instead of freeing it and remove all stale BOs from cache Reviewed-by: Qiang Yu <[email protected]> Signed-off-by: Vasily Khoruzhick <[email protected]>
Diffstat (limited to 'src/gallium/drivers/lima/lima_screen.h')
-rw-r--r--src/gallium/drivers/lima/lima_screen.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/gallium/drivers/lima/lima_screen.h b/src/gallium/drivers/lima/lima_screen.h
index 547d083ecd0..62fa480738c 100644
--- a/src/gallium/drivers/lima/lima_screen.h
+++ b/src/gallium/drivers/lima/lima_screen.h
@@ -37,6 +37,7 @@
#define LIMA_DEBUG_PP (1 << 1)
#define LIMA_DEBUG_DUMP (1 << 2)
#define LIMA_DEBUG_SHADERDB (1 << 3)
+#define LIMA_DEBUG_NO_BO_CACHE (1 << 4)
extern uint32_t lima_debug;
extern FILE *lima_dump_command_stream;
@@ -46,6 +47,11 @@ extern int lima_ppir_force_spilling;
struct ra_regs;
+#define MIN_BO_CACHE_BUCKET (12) /* 2^12 = 4KB */
+#define MAX_BO_CACHE_BUCKET (22) /* 2^22 = 4MB */
+
+#define NR_BO_CACHE_BUCKETS (MAX_BO_CACHE_BUCKET - MIN_BO_CACHE_BUCKET + 1)
+
struct lima_screen {
struct pipe_screen base;
struct renderonly *ro;
@@ -60,8 +66,11 @@ struct lima_screen {
/* bo table */
mtx_t bo_table_lock;
+ mtx_t bo_cache_lock;
struct util_hash_table *bo_handles;
struct util_hash_table *bo_flink_names;
+ struct list_head bo_cache_buckets[NR_BO_CACHE_BUCKETS];
+ struct list_head bo_cache_time;
struct slab_parent_pool transfer_pool;