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 <yuq825@gmail.com>
Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
This commit is contained in:
Vasily Khoruzhick
2019-09-07 19:33:07 -07:00
parent 9f897a2b4c
commit d214778753
8 changed files with 212 additions and 30 deletions

View File

@@ -302,7 +302,7 @@ lima_delete_fs_state(struct pipe_context *pctx, void *hwcso)
struct lima_fs_shader_state *so = hwcso;
if (so->bo)
lima_bo_free(so->bo);
lima_bo_unreference(so->bo);
ralloc_free(so);
}
@@ -396,7 +396,7 @@ lima_delete_vs_state(struct pipe_context *pctx, void *hwcso)
struct lima_vs_shader_state *so = hwcso;
if (so->bo)
lima_bo_free(so->bo);
lima_bo_unreference(so->bo);
ralloc_free(so);
}