* shader is returned.
*/
static struct gl_shader *
-link_intrastage_shaders(struct gl_context *ctx,
+link_intrastage_shaders(void *mem_ctx,
+ struct gl_context *ctx,
struct gl_shader_program *prog,
struct gl_shader **shader_list,
unsigned num_shaders)
gl_shader *linked = ctx->Driver.NewShader(NULL, 0, main->Type);
linked->ir = new(linked) exec_list;
- clone_ir_list(linked, linked->ir, main->ir);
+ clone_ir_list(mem_ctx, linked->ir, main->ir);
populate_symbol_table(linked);
void
link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
{
+ void *mem_ctx = talloc_init("temporary linker context");
+
prog->LinkStatus = false;
prog->Validated = false;
prog->_Used = false;
*/
if (num_vert_shaders > 0) {
gl_shader *const sh =
- link_intrastage_shaders(ctx, prog, vert_shader_list, num_vert_shaders);
+ link_intrastage_shaders(mem_ctx, ctx, prog, vert_shader_list,
+ num_vert_shaders);
if (sh == NULL)
goto done;
if (num_frag_shaders > 0) {
gl_shader *const sh =
- link_intrastage_shaders(ctx, prog, frag_shader_list, num_frag_shaders);
+ link_intrastage_shaders(mem_ctx, ctx, prog, frag_shader_list,
+ num_frag_shaders);
if (sh == NULL)
goto done;
done:
free(vert_shader_list);
+
+ for (unsigned i = 0; i < MESA_SHADER_TYPES; i++) {
+ if (prog->_LinkedShaders[i] == NULL)
+ continue;
+
+ /* Retain any live IR, but trash the rest. */
+ reparent_ir(prog->_LinkedShaders[i]->ir, prog->_LinkedShaders[i]->ir);
+ }
+
+ talloc_free(mem_ctx);
}