intel: fix leaking memory on shader creation

ralloc_adopt takes care of all the shader's children, but shader itsel ends up
orphaned and never gets free'd.

Fixes: ef5bce9253 ("intel: Drop the last uses of a mem_ctx in nir_builder_init_simple_shader().")
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/4951

Signed-off-by: Yevhenii Kolesnikov <yevhenii.kolesnikov@globallogic.com>
Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11651>
This commit is contained in:
Yevhenii Kolesnikov
2021-06-29 18:49:42 +03:00
parent f5876dfdb9
commit 974c58b317
2 changed files with 2 additions and 2 deletions

View File

@@ -30,7 +30,7 @@ blorp_nir_init_shader(nir_builder *b,
const char *name) const char *name)
{ {
*b = nir_builder_init_simple_shader(stage, NULL, "%s", name ? name : ""); *b = nir_builder_init_simple_shader(stage, NULL, "%s", name ? name : "");
ralloc_adopt(mem_ctx, b->shader); ralloc_steal(mem_ctx, b->shader);
if (stage == MESA_SHADER_FRAGMENT) if (stage == MESA_SHADER_FRAGMENT)
b->shader->info.fs.origin_upper_left = true; b->shader->info.fs.origin_upper_left = true;
} }

View File

@@ -1523,7 +1523,7 @@ brw_nir_create_passthrough_tcs(void *mem_ctx, const struct brw_compiler *compile
{ {
nir_builder b = nir_builder_init_simple_shader(MESA_SHADER_TESS_CTRL, nir_builder b = nir_builder_init_simple_shader(MESA_SHADER_TESS_CTRL,
options, "passthrough TCS"); options, "passthrough TCS");
ralloc_adopt(mem_ctx, b.shader); ralloc_steal(mem_ctx, b.shader);
nir_shader *nir = b.shader; nir_shader *nir = b.shader;
nir_variable *var; nir_variable *var;
nir_ssa_def *load; nir_ssa_def *load;