[Mesa-dev] [PATCH] st/mesa: use pipe_sampler_view_release for releasing sampler views

Alex Deucher alexdeucher at gmail.com
Thu Oct 2 13:37:40 PDT 2014


On Thu, Oct 2, 2014 at 1:51 PM, Christian König <deathsimple at vodafone.de> wrote:
> Am 02.10.2014 um 19:34 schrieb Marek Olšák:
>>
>> From: Marek Olšák <marek.olsak at amd.com>
>>
>> This fixes a crash when exiting Firefox. I have really no idea how Firefox
>> does it. It seems to involve multiple contexts and multithreading.
>
>
> That looks to me like we now release all sampler views with the current
> context and not with the context they where originally created with.
>
> If I remember correctly I changed exactly this because it caused a crash
> with XBMC.
>
> I think we need to find the root cause here instead of trying to work around
> it. To me it sounds like we still have a sampler view around while the
> context used to create it is already destroyed.

Maybe related to this old thread?
http://lists.freedesktop.org/archives/mesa-dev/2011-September/011578.html



>
> Regards,
> Christian.
>
>
>>
>> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=81680
>>
>> Cc: 10.2 10.3 <mesa-stable at lists.freedesktop.org>
>> Tested-by: Benjamin Bellec <b.bellec at gmail.com>
>> ---
>>   src/mesa/state_tracker/st_cb_eglimage.c |  3 ++-
>>   src/mesa/state_tracker/st_cb_texture.c  | 13 +++++++------
>>   src/mesa/state_tracker/st_gen_mipmap.c  |  2 +-
>>   src/mesa/state_tracker/st_texture.c     |  5 +++--
>>   src/mesa/state_tracker/st_texture.h     |  3 ++-
>>   src/mesa/state_tracker/st_vdpau.c       |  4 ++--
>>   6 files changed, 17 insertions(+), 13 deletions(-)
>>
>> diff --git a/src/mesa/state_tracker/st_cb_eglimage.c
>> b/src/mesa/state_tracker/st_cb_eglimage.c
>> index 34eb809..8531afb 100644
>> --- a/src/mesa/state_tracker/st_cb_eglimage.c
>> +++ b/src/mesa/state_tracker/st_cb_eglimage.c
>> @@ -96,6 +96,7 @@ st_bind_surface(struct gl_context *ctx, GLenum target,
>>                   struct gl_texture_image *texImage,
>>                   struct pipe_surface *ps)
>>   {
>> +   struct st_context *st = st_context(ctx);
>>      struct st_texture_object *stObj;
>>      struct st_texture_image *stImage;
>>      GLenum internalFormat;
>> @@ -124,7 +125,7 @@ st_bind_surface(struct gl_context *ctx, GLenum target,
>>        /* FIXME create a non-default sampler view from the pipe_surface?
>> */
>>      pipe_resource_reference(&stObj->pt, ps->texture);
>> -   st_texture_release_all_sampler_views(stObj);
>> +   st_texture_release_all_sampler_views(st, stObj);
>>      pipe_resource_reference(&stImage->pt, stObj->pt);
>>        stObj->width0 = ps->width;
>> diff --git a/src/mesa/state_tracker/st_cb_texture.c
>> b/src/mesa/state_tracker/st_cb_texture.c
>> index dfa188a..a8dbb78 100644
>> --- a/src/mesa/state_tracker/st_cb_texture.c
>> +++ b/src/mesa/state_tracker/st_cb_texture.c
>> @@ -152,10 +152,11 @@ static void
>>   st_DeleteTextureObject(struct gl_context *ctx,
>>                          struct gl_texture_object *texObj)
>>   {
>> +   struct st_context *st = st_context(ctx);
>>      struct st_texture_object *stObj = st_texture_object(texObj);
>>        pipe_resource_reference(&stObj->pt, NULL);
>> -   st_texture_release_all_sampler_views(stObj);
>> +   st_texture_release_all_sampler_views(st, stObj);
>>      st_texture_free_sampler_views(stObj);
>>      _mesa_delete_texture_object(ctx, texObj);
>>   }
>> @@ -512,7 +513,7 @@ st_AllocTextureImageBuffer(struct gl_context *ctx,
>>      /* The parent texture object does not have space for this image */
>>        pipe_resource_reference(&stObj->pt, NULL);
>> -   st_texture_release_all_sampler_views(stObj);
>> +   st_texture_release_all_sampler_views(st, stObj);
>>        if (!guess_and_alloc_texture(st, stObj, stImage)) {
>>         /* Probably out of memory.
>> @@ -1571,13 +1572,13 @@ st_finalize_texture(struct gl_context *ctx,
>>           if (!st_obj) {
>>            pipe_resource_reference(&stObj->pt, NULL);
>> -         st_texture_release_all_sampler_views(stObj);
>> +         st_texture_release_all_sampler_views(st, stObj);
>>            return GL_TRUE;
>>         }
>>           if (st_obj->buffer != stObj->pt) {
>>            pipe_resource_reference(&stObj->pt, st_obj->buffer);
>> -         st_texture_release_all_sampler_views(stObj);
>> +         st_texture_release_all_sampler_views(st, stObj);
>>            stObj->width0 = stObj->pt->width0 /
>> _mesa_get_format_bytes(tObj->_BufferObjectFormat);
>>            stObj->height0 = 1;
>>            stObj->depth0 = 1;
>> @@ -1598,7 +1599,7 @@ st_finalize_texture(struct gl_context *ctx,
>>          firstImage->pt != stObj->pt &&
>>          (!stObj->pt || firstImage->pt->last_level >=
>> stObj->pt->last_level)) {
>>         pipe_resource_reference(&stObj->pt, firstImage->pt);
>> -      st_texture_release_all_sampler_views(stObj);
>> +      st_texture_release_all_sampler_views(st, stObj);
>>      }
>>        /* If this texture comes from a window system, there is nothing
>> else to do. */
>> @@ -1646,7 +1647,7 @@ st_finalize_texture(struct gl_context *ctx,
>>             * gallium texture now.  We'll make a new one below.
>>             */
>>            pipe_resource_reference(&stObj->pt, NULL);
>> -         st_texture_release_all_sampler_views(stObj);
>> +         st_texture_release_all_sampler_views(st, stObj);
>>            st->dirty.st |= ST_NEW_FRAMEBUFFER;
>>         }
>>      }
>> diff --git a/src/mesa/state_tracker/st_gen_mipmap.c
>> b/src/mesa/state_tracker/st_gen_mipmap.c
>> index 18cf504..26e1c21 100644
>> --- a/src/mesa/state_tracker/st_gen_mipmap.c
>> +++ b/src/mesa/state_tracker/st_gen_mipmap.c
>> @@ -124,7 +124,7 @@ st_generate_mipmap(struct gl_context *ctx, GLenum
>> target,
>>           /* release the old tex (will likely be freed too) */
>>         pipe_resource_reference(&oldTex, NULL);
>> -      st_texture_release_all_sampler_views(stObj);
>> +      st_texture_release_all_sampler_views(st, stObj);
>>      }
>>      else {
>>         /* Make sure that the base texture image data is present in the
>> diff --git a/src/mesa/state_tracker/st_texture.c
>> b/src/mesa/state_tracker/st_texture.c
>> index 5996b7d..9334d54 100644
>> --- a/src/mesa/state_tracker/st_texture.c
>> +++ b/src/mesa/state_tracker/st_texture.c
>> @@ -519,12 +519,13 @@ st_texture_release_sampler_view(struct st_context
>> *st,
>>   }
>>     void
>> -st_texture_release_all_sampler_views(struct st_texture_object *stObj)
>> +st_texture_release_all_sampler_views(struct st_context *st,
>> +                                     struct st_texture_object *stObj)
>>   {
>>      GLuint i;
>>        for (i = 0; i < stObj->num_sampler_views; ++i)
>> -      pipe_sampler_view_reference(&stObj->sampler_views[i], NULL);
>> +      pipe_sampler_view_release(st->pipe, &stObj->sampler_views[i]);
>>   }
>>     diff --git a/src/mesa/state_tracker/st_texture.h
>> b/src/mesa/state_tracker/st_texture.h
>> index ce1cf8b..d66afcb 100644
>> --- a/src/mesa/state_tracker/st_texture.h
>> +++ b/src/mesa/state_tracker/st_texture.h
>> @@ -255,7 +255,8 @@ st_texture_release_sampler_view(struct st_context *st,
>>                                   struct st_texture_object *stObj);
>>     extern void
>> -st_texture_release_all_sampler_views(struct st_texture_object *stObj);
>> +st_texture_release_all_sampler_views(struct st_context *st,
>> +                                     struct st_texture_object *stObj);
>>     void
>>   st_texture_free_sampler_views(struct st_texture_object *stObj);
>> diff --git a/src/mesa/state_tracker/st_vdpau.c
>> b/src/mesa/state_tracker/st_vdpau.c
>> index 8c10cda..6ccaf3e 100644
>> --- a/src/mesa/state_tracker/st_vdpau.c
>> +++ b/src/mesa/state_tracker/st_vdpau.c
>> @@ -139,7 +139,7 @@ st_vdpau_map_surface(struct gl_context *ctx, GLenum
>> target, GLenum access,
>>                                 texFormat);
>>        pipe_resource_reference(&stObj->pt, res);
>> -   st_texture_release_all_sampler_views(stObj);
>> +   st_texture_release_all_sampler_views(st, stObj);
>>      pipe_resource_reference(&stImage->pt, res);
>>        u_sampler_view_default_template(&templ, res, res->format);
>> @@ -172,7 +172,7 @@ st_vdpau_unmap_surface(struct gl_context *ctx, GLenum
>> target, GLenum access,
>>      struct st_texture_image *stImage = st_texture_image(texImage);
>>        pipe_resource_reference(&stObj->pt, NULL);
>> -   st_texture_release_all_sampler_views(stObj);
>> +   st_texture_release_all_sampler_views(st, stObj);
>>      pipe_resource_reference(&stImage->pt, NULL);
>>        _mesa_dirty_texobj(ctx, texObj);
>
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list