From fb0a422be2e935aaabb8b60f3552c0499e4e85ed Mon Sep 17 00:00:00 2001 From: Erik Faye-Lund Date: Wed, 4 Jun 2025 11:47:06 +0200 Subject: [PATCH] panfrost: plug leak of modifier conversion shaders We were allocating these, but never freeing the actual CSOs here. Let's wire things up so we delete the data when we destroy the hash-table. Because we don't have access to the context in that callback, we can't call the pipe-level function to delete a CSO, but luckily we don't actually need the context for the driver-logic. So let's add an internal helper for that. Fixes: ae3fb3089f5 ("panfrost: Add infrastructure for internal AFBC compute shaders") Fixes: f39194cdd32 ("panfrost: support MTK 16L32S detiling") Reviewed-by: Boris Brezillon Reviewed-by: Mary Guillemard Part-of: --- src/gallium/drivers/panfrost/pan_mod_conv_cso.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/gallium/drivers/panfrost/pan_mod_conv_cso.c b/src/gallium/drivers/panfrost/pan_mod_conv_cso.c index ddd62250fb3..121da18a3a9 100644 --- a/src/gallium/drivers/panfrost/pan_mod_conv_cso.c +++ b/src/gallium/drivers/panfrost/pan_mod_conv_cso.c @@ -504,6 +504,14 @@ panfrost_afbc_context_init(struct panfrost_context *ctx) void panfrost_afbc_context_destroy(struct panfrost_context *ctx) { + hash_table_foreach(ctx->mod_convert_shaders.shaders, he) { + assert(he->data); + struct pan_mod_convert_shader_data *shader = he->data; + ctx->base.delete_compute_state(&ctx->base, shader->afbc_size_cso); + ctx->base.delete_compute_state(&ctx->base, shader->afbc_pack_cso); + ctx->base.delete_compute_state(&ctx->base, shader->mtk_detile_cso); + } + _mesa_hash_table_destroy(ctx->mod_convert_shaders.shaders, NULL); pthread_mutex_destroy(&ctx->mod_convert_shaders.lock); }