[Mesa-dev] [PATCH 2/3] st/mesa: fix sampler view handling with shared textures v2
Christian König
deathsimple at vodafone.de
Mon Mar 24 07:06:32 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
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_atom.h | 2 ++
src/mesa/state_tracker/st_atom_texture.c | 8 ++++++++
src/mesa/state_tracker/st_context.c | 10 ++++++++++
3 files changed, 20 insertions(+)
diff --git a/src/mesa/state_tracker/st_atom.h b/src/mesa/state_tracker/st_atom.h
index 60d89d7..394c6ad 100644
--- a/src/mesa/state_tracker/st_atom.h
+++ b/src/mesa/state_tracker/st_atom.h
@@ -45,6 +45,8 @@ void st_destroy_atoms( struct st_context *st );
void st_validate_state( struct st_context *st );
+void st_atom_texture_cleanup( struct st_context *st,
+ struct gl_texture_object *texObj );
extern const struct st_tracked_state st_update_array;
extern const struct st_tracked_state st_update_framebuffer;
diff --git a/src/mesa/state_tracker/st_atom_texture.c b/src/mesa/state_tracker/st_atom_texture.c
index dc7f635..2826d12 100644
--- a/src/mesa/state_tracker/st_atom_texture.c
+++ b/src/mesa/state_tracker/st_atom_texture.c
@@ -373,6 +373,14 @@ update_geometry_textures(struct st_context *st)
}
}
+void st_atom_texture_cleanup(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);
+}
const struct st_tracked_state st_update_fragment_texture = {
"st_update_texture", /* name */
diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c
index 0ffc762..816a095 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,13 @@ static void st_destroy_context_priv( struct st_context *st )
free( st );
}
+static void st_destroy_tex_sampler( 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 +296,8 @@ void st_destroy_context( struct st_context *st )
struct gl_context *ctx = st->ctx;
GLuint i;
+ _mesa_HashWalk(ctx->Shared->TexObjects, st_destroy_tex_sampler, st);
+
/* need to unbind and destroy CSO objects before anything else */
cso_release_all(st->cso_context);
--
1.9.1
More information about the mesa-dev
mailing list