Module: Mesa Branch: staging/20.3 Commit: 3261d99b9c0a5def8815b14480d03d6485ba918b URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=3261d99b9c0a5def8815b14480d03d6485ba918b
Author: Eric Anholt <e...@anholt.net> Date: Mon Jan 11 11:09:12 2021 -0800 mesa/st: Free the NIR builtins TGSI tokens after passing to the driver. The driver interface doesn't take ownership of the TGSI tokens, so free our temporary. Fixes: 57effa342b75 ("st/mesa: Drop the TGSI paths for PBOs and use nir-to-tgsi if needed.") Reviewed-by: Adam Jackson <a...@redhat.com> Reviewed-by: Marek Olšák <marek.ol...@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8422> (cherry picked from commit 4ddcd9cf165deba2605f5729a0af2f7ded0baad9) --- .pick_status.json | 2 +- src/mesa/state_tracker/st_nir_builtins.c | 22 +++++++++++++++++----- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 5659aa5a64c..2ca59aa8dff 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -139,7 +139,7 @@ "description": "mesa/st: Free the NIR builtins TGSI tokens after passing to the driver.", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "master_sha": null, "because_sha": "57effa342b75a2ae681f2a7665925022dd6e4aa9" }, diff --git a/src/mesa/state_tracker/st_nir_builtins.c b/src/mesa/state_tracker/st_nir_builtins.c index b71edc6629a..029302308b5 100644 --- a/src/mesa/state_tracker/st_nir_builtins.c +++ b/src/mesa/state_tracker/st_nir_builtins.c @@ -26,6 +26,7 @@ #include "compiler/nir/nir_builder.h" #include "compiler/glsl/gl_nir.h" #include "nir/nir_to_tgsi.h" +#include "tgsi/tgsi_parse.h" struct pipe_shader_state * st_nir_finish_builtin_shader(struct st_context *st, @@ -83,21 +84,32 @@ st_nir_finish_builtin_shader(struct st_context *st, ralloc_free(nir); } + struct pipe_shader_state *shader; switch (stage) { case MESA_SHADER_VERTEX: - return pipe->create_vs_state(pipe, &state); + shader = pipe->create_vs_state(pipe, &state); + break; case MESA_SHADER_TESS_CTRL: - return pipe->create_tcs_state(pipe, &state); + shader = pipe->create_tcs_state(pipe, &state); + break; case MESA_SHADER_TESS_EVAL: - return pipe->create_tes_state(pipe, &state); + shader = pipe->create_tes_state(pipe, &state); + break; case MESA_SHADER_GEOMETRY: - return pipe->create_gs_state(pipe, &state); + shader = pipe->create_gs_state(pipe, &state); + break; case MESA_SHADER_FRAGMENT: - return pipe->create_fs_state(pipe, &state); + shader = pipe->create_fs_state(pipe, &state); + break; default: unreachable("unsupported shader stage"); return NULL; } + + if (state.type == PIPE_SHADER_IR_TGSI) + tgsi_free_tokens(state.tokens); + + return shader; } /** _______________________________________________ mesa-commit mailing list mesa-commit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-commit