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 0481187..09d0b49 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 f16a830..ee6ee5b 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 0b4b888..80c4290 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 657f693..1be5feb 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);