In case the IR is NIR, the driver takes reference to the nir_shader. Also, because there are no variants, we need to clone the shader, instead of sharing the reference with gl_program, which would result in a double free in _mesa_delete_program().
Signed-off-by: Rob Clark <robdcl...@gmail.com> --- src/mesa/state_tracker/st_program.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c index 335d45ba282..382dd49f980 100644 --- a/src/mesa/state_tracker/st_program.c +++ b/src/mesa/state_tracker/st_program.c @@ -360,7 +360,18 @@ st_release_cp_variants(struct st_context *st, struct st_compute_program *stcp) *variants = NULL; if (stcp->tgsi.prog) { - ureg_free_tokens(stcp->tgsi.prog); + switch (stcp->tgsi.ir_type) { + case PIPE_SHADER_IR_TGSI: + ureg_free_tokens(stcp->tgsi.prog); + break; + case PIPE_SHADER_IR_NIR: + /* pipe driver took ownership of prog */ + break; + case PIPE_SHADER_IR_LLVM: + case PIPE_SHADER_IR_NATIVE: + /* ??? */ + break; + } stcp->tgsi.prog = NULL; } } @@ -1775,7 +1786,7 @@ st_translate_compute_program(struct st_context *st, st_finalize_nir(st, &stcp->Base, nir); stcp->tgsi.ir_type = PIPE_SHADER_IR_NIR; - stcp->tgsi.prog = nir; + stcp->tgsi.prog = nir_shader_clone(NULL, nir); return true; } -- 2.13.6 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev