diff options
author | Vasily Khoruzhick <[email protected]> | 2019-09-07 19:33:07 -0700 |
---|---|---|
committer | Vasily Khoruzhick <[email protected]> | 2019-09-22 19:20:59 -0700 |
commit | d2147787534de87cd11015266293211b5188442f (patch) | |
tree | 823202fabe8f330fc6360a2a02dbc881e2280181 /src/gallium/drivers/lima/lima_bo.h | |
parent | 9f897a2b4cf2c0e222487470053a69de843f2084 (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_bo.h')
-rw-r--r-- | src/gallium/drivers/lima/lima_bo.h | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/gallium/drivers/lima/lima_bo.h b/src/gallium/drivers/lima/lima_bo.h index 3f440b3b014..7bbd0063602 100644 --- a/src/gallium/drivers/lima/lima_bo.h +++ b/src/gallium/drivers/lima/lima_bo.h @@ -28,12 +28,18 @@ #include <stdint.h> #include "util/u_atomic.h" +#include "util/list.h" struct lima_bo { struct lima_screen *screen; + struct list_head time_list; + struct list_head size_list; int refcnt; + bool cacheable; + time_t free_time; uint32_t size; + uint32_t flags; uint32_t handle; uint64_t offset; uint32_t flink_name; @@ -44,10 +50,12 @@ struct lima_bo { bool lima_bo_table_init(struct lima_screen *screen); void lima_bo_table_fini(struct lima_screen *screen); +bool lima_bo_cache_init(struct lima_screen *screen); +void lima_bo_cache_fini(struct lima_screen *screen); struct lima_bo *lima_bo_create(struct lima_screen *screen, uint32_t size, uint32_t flags); -void lima_bo_free(struct lima_bo *bo); +void lima_bo_unreference(struct lima_bo *bo); static inline void lima_bo_reference(struct lima_bo *bo) { |