mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-08 02:38:04 +02:00
asahi: Do not use memctx for pools / meta cache
ralloc is not thread-safe, so we can't use dev->memctx for allocating context-specific things without locking. On top of that, we always need to explicitly clean up pools anyway since we need to unref the BOs, so there is no point to using a memctx. And since pools need to be explicitly cleaned up, the meta cache code needs explicit cleanup, so add that and drop memctx from there too. Signed-off-by: Asahi Lina <lina@asahilina.net> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21348>
This commit is contained in:
parent
9daaa9e44e
commit
6ad64387dd
4 changed files with 16 additions and 7 deletions
|
|
@ -166,9 +166,16 @@ key_compare(const void *a, const void *b)
|
|||
}
|
||||
|
||||
void
|
||||
agx_meta_init(struct agx_meta_cache *cache, struct agx_device *dev,
|
||||
void *memctx)
|
||||
agx_meta_init(struct agx_meta_cache *cache, struct agx_device *dev)
|
||||
{
|
||||
agx_pool_init(&cache->pool, dev, AGX_BO_EXEC | AGX_BO_LOW_VA, true);
|
||||
cache->ht = _mesa_hash_table_create(memctx, key_hash, key_compare);
|
||||
cache->ht = _mesa_hash_table_create(NULL, key_hash, key_compare);
|
||||
}
|
||||
|
||||
void
|
||||
agx_meta_cleanup(struct agx_meta_cache *cache)
|
||||
{
|
||||
agx_pool_cleanup(&cache->pool);
|
||||
_mesa_hash_table_destroy(cache->ht, NULL);
|
||||
cache->ht = NULL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ struct agx_meta_shader {
|
|||
struct agx_meta_shader *agx_get_meta_shader(struct agx_meta_cache *cache,
|
||||
struct agx_meta_key *key);
|
||||
|
||||
void agx_meta_init(struct agx_meta_cache *cache, struct agx_device *dev,
|
||||
void *memctx);
|
||||
void agx_meta_init(struct agx_meta_cache *cache, struct agx_device *dev);
|
||||
void agx_meta_cleanup(struct agx_meta_cache *cache);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ agx_pool_init(struct agx_pool *pool, struct agx_device *dev,
|
|||
memset(pool, 0, sizeof(*pool));
|
||||
pool->dev = dev;
|
||||
pool->create_flags = create_flags;
|
||||
util_dynarray_init(&pool->bos, dev->memctx);
|
||||
util_dynarray_init(&pool->bos, NULL);
|
||||
|
||||
if (prealloc)
|
||||
agx_pool_alloc_backing(pool, POOL_SLAB_SIZE);
|
||||
|
|
|
|||
|
|
@ -1103,6 +1103,8 @@ agx_destroy_context(struct pipe_context *pctx)
|
|||
|
||||
util_unreference_framebuffer_state(&ctx->framebuffer);
|
||||
|
||||
agx_meta_cleanup(&ctx->meta);
|
||||
|
||||
ralloc_free(ctx);
|
||||
}
|
||||
|
||||
|
|
@ -1167,7 +1169,7 @@ agx_create_context(struct pipe_screen *screen, void *priv, unsigned flags)
|
|||
agx_init_state_functions(pctx);
|
||||
agx_init_query_functions(pctx);
|
||||
|
||||
agx_meta_init(&ctx->meta, agx_device(screen), ctx);
|
||||
agx_meta_init(&ctx->meta, agx_device(screen));
|
||||
|
||||
ctx->blitter = util_blitter_create(pctx);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue