summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenneth Graunke <[email protected]>2014-06-18 22:25:33 -0700
committerKenneth Graunke <[email protected]>2014-06-21 10:47:47 -0700
commita20994d61677adea7f15facbc6bb025f32b37c93 (patch)
tree0df674e08581a6167e693f8272bf813c5d3752ea /src
parentdfaf6116c9d29b01633601b09c6846c21383aaa9 (diff)
i965: Save meta stencil blit programs in the context.
When the last context in a share group is destroyed, the hash table containing all of the shader programs (ctx->Shared->ShaderObjects) is destroyed, throwing away all of the shader programs. Using a static variable to store program IDs ends up holding on to them after this, so we think we still have a compiled program, when it actually got destroyed. _mesa_UseProgram then hits GL errors, since no program by that ID exists. Instead, store the program IDs in the context, so we know to recompile if our context gets destroyed and the application creates another one. Fixes es3conform tests when run without -minfmt (where it creates separate contexts for testing each visual). Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=77865 Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Cc: "10.2" <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/mesa/drivers/dri/i965/brw_context.h3
-rw-r--r--src/mesa/drivers/dri/i965/brw_meta_stencil_blit.c18
2 files changed, 13 insertions, 8 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h
index 283c5767211..72cf39b17d4 100644
--- a/src/mesa/drivers/dri/i965/brw_context.h
+++ b/src/mesa/drivers/dri/i965/brw_context.h
@@ -1115,6 +1115,9 @@ struct brw_context
struct brw_cache cache;
+ /** IDs for meta stencil blit shader programs. */
+ unsigned meta_stencil_blit_programs[2];
+
/* Whether a meta-operation is in progress. */
bool meta_in_progress;
diff --git a/src/mesa/drivers/dri/i965/brw_meta_stencil_blit.c b/src/mesa/drivers/dri/i965/brw_meta_stencil_blit.c
index 5d132b7acbd..bdd642bf9c5 100644
--- a/src/mesa/drivers/dri/i965/brw_meta_stencil_blit.c
+++ b/src/mesa/drivers/dri/i965/brw_meta_stencil_blit.c
@@ -272,28 +272,30 @@ setup_coord_transform(GLuint prog, const struct blit_dims *dims)
}
static GLuint
-setup_program(struct gl_context *ctx, bool msaa_tex)
+setup_program(struct brw_context *brw, bool msaa_tex)
{
+ struct gl_context *ctx = &brw->ctx;
struct blit_state *blit = &ctx->Meta->Blit;
- static GLuint prog_cache[] = { 0, 0 };
char *fs_source;
const struct sampler_and_fetch *sampler = &samplers[msaa_tex];
_mesa_meta_setup_vertex_objects(&blit->VAO, &blit->VBO, true, 2, 2, 0);
- if (prog_cache[msaa_tex]) {
- _mesa_UseProgram(prog_cache[msaa_tex]);
- return prog_cache[msaa_tex];
+ GLuint *prog_id = &brw->meta_stencil_blit_programs[msaa_tex];
+
+ if (*prog_id) {
+ _mesa_UseProgram(*prog_id);
+ return *prog_id;
}
fs_source = ralloc_asprintf(NULL, fs_tmpl, sampler->sampler,
sampler->fetch);
_mesa_meta_compile_and_link_program(ctx, vs_source, fs_source,
"i965 stencil blit",
- &prog_cache[msaa_tex]);
+ prog_id);
ralloc_free(fs_source);
- return prog_cache[msaa_tex];
+ return *prog_id;
}
/**
@@ -427,7 +429,7 @@ brw_meta_stencil_blit(struct brw_context *brw,
_mesa_TexParameteri(target, GL_DEPTH_STENCIL_TEXTURE_MODE,
GL_STENCIL_INDEX);
- prog = setup_program(ctx, target != GL_TEXTURE_2D);
+ prog = setup_program(brw, target != GL_TEXTURE_2D);
setup_bounding_rect(prog, orig_dims);
setup_drawing_rect(prog, &dims);
setup_coord_transform(prog, orig_dims);