draw: free the NIR IR.
authorDave Airlie <airlied@redhat.com>
Wed, 15 Apr 2020 00:43:52 +0000 (10:43 +1000)
committerDave Airlie <airlied@redhat.com>
Wed, 15 Apr 2020 20:25:39 +0000 (06:25 +1000)
Not sure how I missed this, the ownership was a bit blurry,
free the NIR.

Fixes: bf12bc2dd7a2 (draw: add nir info gathering and building support)
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4563>

src/gallium/auxiliary/draw/draw_gs.c
src/gallium/auxiliary/draw/draw_vs_llvm.c

index 0cbead3f9acd6e2bd12889c1e2ea28d4721970d9..0c07d38e8b2438e4da37e916a8232f552cfa6305 100644 (file)
@@ -41,7 +41,7 @@
 #include "util/u_math.h"
 #include "util/u_memory.h"
 #include "util/u_prim.h"
-
+#include "util/ralloc.h"
 /* fixme: move it from here */
 #define MAX_PRIMITIVES 64
 
@@ -962,6 +962,9 @@ void draw_delete_geometry_shader(struct draw_context *draw,
 
    for (i = 0; i < TGSI_MAX_VERTEX_STREAMS; i++)
       FREE(dgs->stream[i].primitive_lengths);
+
+   if (dgs->state.ir.nir)
+      ralloc_free(dgs->state.ir.nir);
    FREE((void*) dgs->state.tokens);
    FREE(dgs);
 }
index e45fa68d5d69f45e4ee33c07aa5587b99a49fd1e..ec3c5b00fbcf5debd21202af53ed291c9eaaa91a 100644 (file)
@@ -38,6 +38,8 @@
 #include "tgsi/tgsi_parse.h"
 #include "tgsi/tgsi_scan.h"
 #include "nir/nir_to_tgsi_info.h"
+#include "nir.h"
+
 static void
 vs_llvm_prepare(struct draw_vertex_shader *shader,
                 struct draw_context *draw)
@@ -76,6 +78,8 @@ vs_llvm_delete( struct draw_vertex_shader *dvs )
    }
 
    assert(shader->variants_cached == 0);
+   if (dvs->state.ir.nir)
+      ralloc_free(dvs->state.ir.nir);
    FREE((void*) dvs->state.tokens);
    FREE( dvs );
 }
@@ -92,9 +96,10 @@ draw_create_vs_llvm(struct draw_context *draw,
 
    /* due to some bugs in the feedback state tracker we have to check
       for ir.nir & PIPE_SHADER_IR_NIR here. */
-   if (state->ir.nir && state->type == PIPE_SHADER_IR_NIR)
+   if (state->ir.nir && state->type == PIPE_SHADER_IR_NIR) {
+      vs->base.state.ir.nir = state->ir.nir;
       nir_tgsi_scan_shader(state->ir.nir, &vs->base.info, true);
-   else {
+   else {
       /* we make a private copy of the tokens */
       vs->base.state.tokens = tgsi_dup_tokens(state->tokens);
       if (!vs->base.state.tokens) {
@@ -113,7 +118,6 @@ draw_create_vs_llvm(struct draw_context *draw,
          vs->base.info.file_max[TGSI_FILE_IMAGE]+1);
 
    vs->base.state.type = state->type;
-   vs->base.state.ir.nir = state->ir.nir;
    vs->base.state.stream_output = state->stream_output;
    vs->base.draw = draw;
    vs->base.prepare = vs_llvm_prepare;