[Mesa-dev] [PATCH 2/3] st/mesa: fix sampler view handling with shared textures v2
Brian Paul
brianp at vmware.com
Mon Mar 24 08:36:28 PDT 2014
On 03/24/2014 08:06 AM, Christian König wrote:
> 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 );
Let's call this st_release_texture_sample_view() and put it in
st_texture.h. The function doesn't really pertain to state atoms and
seems to go along with the other texture / sampler view functions in
st_texture.h.
>
> 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);
> +}
Move to st_texture.c
>
> 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 )
I know we're not consistent about this in the state tracker, but we can
drop the st_ prefix on static functions. And I'd probably put a "_cb"
suffix (for callback) on the function as we do in shared.c. And put a
comment on it:
/**
* 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 +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);
>
>
Looks good otherwise.
-Brian
More information about the mesa-dev
mailing list