summaryrefslogtreecommitdiffstats
path: root/src/mesa/state_tracker/st_program.c
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2019-03-12 17:07:16 -0700
committerEric Anholt <[email protected]>2019-03-14 16:18:38 -0700
commite0806c1ea079b1d78735290b0e24b02eb042b2c3 (patch)
treec98f1424fac5f9d79ad869d8d14c45a880a5c1b5 /src/mesa/state_tracker/st_program.c
parent1ea42894c70f271c6ea958a9d3cc7ba8c5948c2e (diff)
mesa/st: Make sure that prog_to_nir NIR gets freed.
GLSL NIR gets freed on relink by _mesa_delete_program(), but for ARB programs we need to free the old NIR when PSN is used to set up new NIR in the same gl_program. Additionally, set the base .nir field so that it will get freed by _mesa_delete_program(). Fixes: 3d7611e9a6c6 ("st/nir: use NIR for asm programs") Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src/mesa/state_tracker/st_program.c')
-rw-r--r--src/mesa/state_tracker/st_program.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c
index 7015e503d12..ebedf4daa21 100644
--- a/src/mesa/state_tracker/st_program.c
+++ b/src/mesa/state_tracker/st_program.c
@@ -579,8 +579,11 @@ st_translate_vertex_program(struct st_context *st,
nir_shader *nir =
st_translate_prog_to_nir(st, &stvp->Base, MESA_SHADER_VERTEX);
+ if (stvp->tgsi.ir.nir)
+ ralloc_free(stvp->tgsi.ir.nir);
stvp->tgsi.type = PIPE_SHADER_IR_NIR;
stvp->tgsi.ir.nir = nir;
+ stvp->Base.nir = nir;
return true;
}
@@ -763,8 +766,11 @@ st_translate_fragment_program(struct st_context *st,
nir_shader *nir =
st_translate_prog_to_nir(st, &stfp->Base, MESA_SHADER_FRAGMENT);
+ if (stfp->tgsi.ir.nir)
+ ralloc_free(stfp->tgsi.ir.nir);
stfp->tgsi.type = PIPE_SHADER_IR_NIR;
stfp->tgsi.ir.nir = nir;
+ stfp->Base.nir = nir;
return true;
}