[Mesa-dev] [PATCH 2/3] st/mesa: fix sampler view handling with shared textures v3
Christian König
deathsimple at vodafone.de
Mon Mar 24 09:31:50 PDT 2014
From: Christian König <christian.koenig at amd.com>
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
Signed-off-by: Christian König <christian.koenig at amd.com>
Cc: "10.0 10.1" <mesa-stable at lists.freedesktop.org>
---
src/mesa/state_tracker/st_context.c | 16 ++++++++++++++++
src/mesa/state_tracker/st_texture.c | 9 +++++++++
src/mesa/state_tracker/st_texture.h | 4 ++++
3 files changed, 29 insertions(+)
diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c
index 0ffc762..277dc42 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"
@@ -280,6 +281,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_atom_texture_cleanup(st, texObj);
+}
void st_destroy_context( struct st_context *st )
{
@@ -288,6 +302,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);
diff --git a/src/mesa/state_tracker/st_texture.c b/src/mesa/state_tracker/st_texture.c
index b5ccc76..db6b54e 100644
--- a/src/mesa/state_tracker/st_texture.c
+++ b/src/mesa/state_tracker/st_texture.c
@@ -412,3 +412,12 @@ st_create_color_map_texture(struct gl_context *ctx)
return pt;
}
+void
+st_release_texture_sample_view(struct st_context *st,
+ struct gl_texture_object *texObj)
+{
+ struct st_texture_object *stObj = st_texture_object(texObj);
+
+ if (stObj->sampler_view && stObj->sampler_view->context == st->pipe)
+ pipe_sampler_view_reference(&stObj->sampler_view, NULL);
+}
diff --git a/src/mesa/state_tracker/st_texture.h b/src/mesa/state_tracker/st_texture.h
index bce2a09..44327cd 100644
--- a/src/mesa/state_tracker/st_texture.h
+++ b/src/mesa/state_tracker/st_texture.h
@@ -227,4 +227,8 @@ st_texture_image_copy(struct pipe_context *pipe,
extern struct pipe_resource *
st_create_color_map_texture(struct gl_context *ctx);
+extern void
+st_release_texture_sample_view(struct st_context *st,
+ struct gl_texture_object *texObj);
+
#endif
--
1.9.1
More information about the mesa-dev
mailing list