summaryrefslogtreecommitdiffstats
path: root/src/mesa/state_tracker/st_context.c
diff options
context:
space:
mode:
authorChristian König <[email protected]>2014-03-23 17:01:38 +0100
committerChristian König <[email protected]>2014-03-26 12:06:43 +0100
commitd117ddbe31fdbe79c871343358e2551593a1b18c (patch)
tree4faaedc8f9f2b69cd6dd183d1e3ded084339fd17 /src/mesa/state_tracker/st_context.c
parent3b421daf32e5941801e0efb162037de4d8ca1f1d (diff)
st/mesa: fix sampler view handling with shared textures v4
Release the references to the sampler views before destroying the pipe context. v2: remove TODO and unrelated change v3: move to st_texture.[ch], rename callback, add comment v4: fix rebase mess up and add further cleanups Signed-off-by: Christian König <[email protected]> Reviewed-by: Brian Paul <[email protected]> Cc: "10.0 10.1" <[email protected]>
Diffstat (limited to 'src/mesa/state_tracker/st_context.c')
-rw-r--r--src/mesa/state_tracker/st_context.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c
index 0ffc7626388..807a86fdf93 100644
--- a/src/mesa/state_tracker/st_context.c
+++ b/src/mesa/state_tracker/st_context.c
@@ -33,6 +33,7 @@
#include "main/shaderobj.h"
#include "main/version.h"
#include "main/vtxfmt.h"
+#include "main/hash.h"
#include "program/prog_cache.h"
#include "vbo/vbo.h"
#include "glapi/glapi.h"
@@ -66,6 +67,7 @@
#include "st_gen_mipmap.h"
#include "st_program.h"
#include "st_vdpau.h"
+#include "st_texture.h"
#include "pipe/p_context.h"
#include "util/u_inlines.h"
#include "util/u_upload_mgr.h"
@@ -280,6 +282,19 @@ static void st_destroy_context_priv( struct st_context *st )
free( st );
}
+
+/**
+ * Callback to release the sampler view attached to a texture object.
+ * Called by _mesa_HashWalk().
+ */
+static void
+destroy_tex_sampler_cb(GLuint id, void *data, void *userData)
+{
+ struct gl_texture_object *texObj = (struct gl_texture_object *) data;
+ struct st_context *st = (struct st_context *) userData;
+
+ st_texture_release_sampler_view(st, st_texture_object(texObj));
+}
void st_destroy_context( struct st_context *st )
{
@@ -288,6 +303,8 @@ void st_destroy_context( struct st_context *st )
struct gl_context *ctx = st->ctx;
GLuint i;
+ _mesa_HashWalk(ctx->Shared->TexObjects, destroy_tex_sampler_cb, st);
+
/* need to unbind and destroy CSO objects before anything else */
cso_release_all(st->cso_context);