diff --git a/.pick_status.json b/.pick_status.json index c3353131e90..c132d2e05e6 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -10294,7 +10294,7 @@ "description": "aux/draw: fix memory leak related to ureg_get_tokens()", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "b5e782f5f43185076acbbea1e42000fd1fb48aa0", "notes": null diff --git a/src/gallium/auxiliary/draw/draw_vs.c b/src/gallium/auxiliary/draw/draw_vs.c index bdd886f485c..e5d88c6e8c0 100644 --- a/src/gallium/auxiliary/draw/draw_vs.c +++ b/src/gallium/auxiliary/draw/draw_vs.c @@ -47,6 +47,7 @@ #include "tgsi/tgsi_dump.h" #include "tgsi/tgsi_exec.h" +#include "tgsi/tgsi_ureg.h" #include "nir/nir_to_tgsi.h" @@ -65,6 +66,7 @@ draw_create_vertex_shader(struct draw_context *draw, } #ifdef DRAW_LLVM_AVAILABLE + bool is_allocated = false; if (draw->pt.middle.llvm) { struct pipe_screen *screen = draw->pipe->screen; if (shader->type == PIPE_SHADER_IR_NIR && @@ -75,6 +77,7 @@ draw_create_vertex_shader(struct draw_context *draw, PIPE_SHADER_IR_TGSI))) { state.type = PIPE_SHADER_IR_TGSI; state.tokens = nir_to_tgsi(shader->ir.nir, screen); + is_allocated = true; } vs = draw_create_vs_llvm(draw, &state); } @@ -84,6 +87,12 @@ draw_create_vertex_shader(struct draw_context *draw, vs = draw_create_vs_exec(draw, &state); } +#ifdef DRAW_LLVM_AVAILABLE + if (is_allocated) { + ureg_free_tokens(state.tokens); + } +#endif + if (vs) { bool found_clipvertex = FALSE; vs->position_output = -1;