From: Rob Clark Date: Thu, 4 Jun 2020 19:55:41 +0000 (-0700) Subject: freedreno/ir3: add ir3_compiler_destroy() X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c0f22c3d9406ef354142e974783f6c6c066a5c68;p=mesa.git freedreno/ir3: add ir3_compiler_destroy() Use ir3_compiler_destroy() rather than open-coding ralloc_free(). This will give us a place to add more compiler related cleanup code in the following patches. Signed-off-by: Rob Clark Part-of: --- diff --git a/src/freedreno/ir3/ir3_compiler.c b/src/freedreno/ir3/ir3_compiler.c index 0481187b867..09d0b49dcea 100644 --- a/src/freedreno/ir3/ir3_compiler.c +++ b/src/freedreno/ir3/ir3_compiler.c @@ -52,7 +52,14 @@ DEBUG_GET_ONCE_FLAGS_OPTION(ir3_shader_debug, "IR3_SHADER_DEBUG", shader_debug_o enum ir3_shader_debug ir3_shader_debug = 0; -struct ir3_compiler * ir3_compiler_create(struct fd_device *dev, uint32_t gpu_id) +void +ir3_compiler_destroy(struct ir3_compiler *compiler) +{ + ralloc_free(compiler); +} + +struct ir3_compiler * +ir3_compiler_create(struct fd_device *dev, uint32_t gpu_id) { struct ir3_compiler *compiler = rzalloc(NULL, struct ir3_compiler); diff --git a/src/freedreno/ir3/ir3_compiler.h b/src/freedreno/ir3/ir3_compiler.h index f16a8301e16..ee6ee5ba83c 100644 --- a/src/freedreno/ir3/ir3_compiler.h +++ b/src/freedreno/ir3/ir3_compiler.h @@ -95,6 +95,7 @@ struct ir3_compiler { uint32_t const_upload_unit; }; +void ir3_compiler_destroy(struct ir3_compiler *compiler); struct ir3_compiler * ir3_compiler_create(struct fd_device *dev, uint32_t gpu_id); int ir3_compile_shader_nir(struct ir3_compiler *compiler, diff --git a/src/freedreno/vulkan/tu_device.c b/src/freedreno/vulkan/tu_device.c index 0b4b888bb1b..80c42902a8e 100644 --- a/src/freedreno/vulkan/tu_device.c +++ b/src/freedreno/vulkan/tu_device.c @@ -1346,8 +1346,7 @@ tu_DestroyDevice(VkDevice _device, const VkAllocationCallbacks *pAllocator) tu_bo_finish(device, &device->scratch_bos[i].bo); } - /* the compiler does not use pAllocator */ - ralloc_free(device->compiler); + ir3_compiler_destroy(device->compiler); VkPipelineCache pc = tu_pipeline_cache_to_handle(device->mem_cache); tu_DestroyPipelineCache(tu_device_to_handle(device), pc, NULL); diff --git a/src/gallium/drivers/freedreno/freedreno_screen.c b/src/gallium/drivers/freedreno/freedreno_screen.c index 657f693a1f8..1be5feb2e8f 100644 --- a/src/gallium/drivers/freedreno/freedreno_screen.c +++ b/src/gallium/drivers/freedreno/freedreno_screen.c @@ -59,6 +59,7 @@ #include "ir3/ir3_nir.h" +#include "ir3/ir3_compiler.h" #include "a2xx/ir2.h" static const struct debug_named_value debug_options[] = { @@ -159,7 +160,9 @@ fd_screen_destroy(struct pipe_screen *pscreen) simple_mtx_destroy(&screen->lock); - ralloc_free(screen->compiler); + if (screen->compiler) + ir3_compiler_destroy(screen->compiler); + ralloc_free(screen->live_batches); free(screen->perfcntr_queries);