freedreno/ir3: add ir3_compiler_destroy()
authorRob Clark <robdclark@chromium.org>
Thu, 4 Jun 2020 19:55:41 +0000 (12:55 -0700)
committerRob Clark <robdclark@chromium.org>
Fri, 26 Jun 2020 15:43:23 +0000 (08:43 -0700)
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 <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5372>

src/freedreno/ir3/ir3_compiler.c
src/freedreno/ir3/ir3_compiler.h
src/freedreno/vulkan/tu_device.c
src/gallium/drivers/freedreno/freedreno_screen.c

index 0481187b8675a4340e09dcfef2b426c63529ff4e..09d0b49dcea9a9474da01c74c198162251a6b439 100644 (file)
@@ -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);
 
index f16a8301e1681c06aba716cf1d8250c5b8f73ed4..ee6ee5ba83ce524eb80842b728201ca41252951a 100644 (file)
@@ -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,
index 0b4b888bb1b5e2ac53fb8317936206176df28e18..80c42902a8e8427b2d848a14e2cac27836d8c1dc 100644 (file)
@@ -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);
index 657f693a1f83ec55a72f621e1a81aeb56fffbf22..1be5feb2e8f67c312286f9dd5157d46b349eb987 100644 (file)
@@ -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);