summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/glsl/linker.cpp15
-rw-r--r--src/glsl/main.cpp6
-rw-r--r--src/glsl/program.h2
-rw-r--r--src/mesa/program/ir_to_mesa.cpp2
4 files changed, 17 insertions, 8 deletions
diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
index 4172e41910..b256574446 100644
--- a/src/glsl/linker.cpp
+++ b/src/glsl/linker.cpp
@@ -674,7 +674,8 @@ get_main_function_signature(gl_shader *sh)
* shader is returned.
*/
static struct gl_shader *
-link_intrastage_shaders(struct gl_shader_program *prog,
+link_intrastage_shaders(GLcontext *ctx,
+ struct gl_shader_program *prog,
struct gl_shader **shader_list,
unsigned num_shaders)
{
@@ -747,7 +748,7 @@ link_intrastage_shaders(struct gl_shader_program *prog,
return NULL;
}
- gl_shader *const linked = _mesa_new_shader(NULL, 0, main->Type);
+ gl_shader *const linked = ctx->Driver.NewShader(NULL, 0, main->Type);
linked->ir = new(linked) exec_list;
clone_ir_list(linked, linked->ir, main->ir);
@@ -1212,7 +1213,7 @@ assign_varying_locations(struct gl_shader_program *prog,
void
-link_shaders(struct gl_shader_program *prog)
+link_shaders(GLcontext *ctx, struct gl_shader_program *prog)
{
prog->LinkStatus = false;
prog->Validated = false;
@@ -1270,12 +1271,16 @@ link_shaders(struct gl_shader_program *prog)
prog->Version = max_version;
+ for (unsigned int i = 0; i < prog->_NumLinkedShaders; i++) {
+ ctx->Driver.DeleteShader(ctx, prog->_LinkedShaders[i]);
+ }
+
/* Link all shaders for a particular stage and validate the result.
*/
prog->_NumLinkedShaders = 0;
if (num_vert_shaders > 0) {
gl_shader *const sh =
- link_intrastage_shaders(prog, vert_shader_list, num_vert_shaders);
+ link_intrastage_shaders(ctx, prog, vert_shader_list, num_vert_shaders);
if (sh == NULL)
goto done;
@@ -1289,7 +1294,7 @@ link_shaders(struct gl_shader_program *prog)
if (num_frag_shaders > 0) {
gl_shader *const sh =
- link_intrastage_shaders(prog, frag_shader_list, num_frag_shaders);
+ link_intrastage_shaders(ctx, prog, frag_shader_list, num_frag_shaders);
if (sh == NULL)
goto done;
diff --git a/src/glsl/main.cpp b/src/glsl/main.cpp
index 24d6076d07..cb9f8a5277 100644
--- a/src/glsl/main.cpp
+++ b/src/glsl/main.cpp
@@ -209,6 +209,10 @@ int
main(int argc, char **argv)
{
int status = EXIT_SUCCESS;
+ GLcontext local_ctx;
+ GLcontext *ctx = &local_ctx;
+
+ ctx->Driver.NewShader = _mesa_new_shader;
int c;
int idx = 0;
@@ -265,7 +269,7 @@ main(int argc, char **argv)
}
if ((status == EXIT_SUCCESS) && do_link) {
- link_shaders(whole_program);
+ link_shaders(ctx, whole_program);
status = (whole_program->LinkStatus) ? EXIT_SUCCESS : EXIT_FAILURE;
if (strlen(whole_program->InfoLog) > 0)
diff --git a/src/glsl/program.h b/src/glsl/program.h
index 0a49203d4b..ea2c4ab0dd 100644
--- a/src/glsl/program.h
+++ b/src/glsl/program.h
@@ -30,4 +30,4 @@ extern "C" {
}
extern void
-link_shaders(struct gl_shader_program *prog);
+link_shaders(GLcontext *ctx, struct gl_shader_program *prog);
diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp
index 4f4994392d..394370d46d 100644
--- a/src/mesa/program/ir_to_mesa.cpp
+++ b/src/mesa/program/ir_to_mesa.cpp
@@ -2740,7 +2740,7 @@ _mesa_glsl_link_shader(GLcontext *ctx, struct gl_shader_program *prog)
_mesa_reference_fragprog(ctx, &prog->FragmentProgram, NULL);
if (prog->LinkStatus) {
- link_shaders(prog);
+ link_shaders(ctx, prog);
/* We don't use the linker's uniforms list, and cook up our own at
* generate time.