From 20de0359b53311cad322de8286448f2cbb34f475 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 8 Mar 2019 13:39:05 -0700 Subject: st/mesa: stop using pipe_sampler_view_release() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In all instances here we can replace pipe_sampler_view_release(pipe, view) with pipe_sampler_view_reference(view, NULL) because the views in question are private to the state tracker context. So there's no danger of freeing a sampler view with the wrong context. Testing done: google chrome, misc GL demos, games Reviewed-by: Roland Scheidegger Reviewed-by: Neha Bhende Reviewed-by: Mathias Fröhlich Reviewed-By: Jose Fonseca --- src/mesa/state_tracker/st_context.c | 3 +-- src/mesa/state_tracker/st_sampler_view.c | 6 +++--- 2 files changed, 4 insertions(+), 5 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c index de2264da589..f03738452a7 100644 --- a/src/mesa/state_tracker/st_context.c +++ b/src/mesa/state_tracker/st_context.c @@ -434,8 +434,7 @@ st_destroy_context_priv(struct st_context *st, bool destroy_pipe) st_destroy_bound_image_handles(st); for (i = 0; i < ARRAY_SIZE(st->state.frag_sampler_views); i++) { - pipe_sampler_view_release(st->pipe, - &st->state.frag_sampler_views[i]); + pipe_sampler_view_reference(&st->state.frag_sampler_views[i], NULL); } /* free glReadPixels cache data */ diff --git a/src/mesa/state_tracker/st_sampler_view.c b/src/mesa/state_tracker/st_sampler_view.c index b20a00cff7d..eb97f2bb6b7 100644 --- a/src/mesa/state_tracker/st_sampler_view.c +++ b/src/mesa/state_tracker/st_sampler_view.c @@ -74,7 +74,7 @@ st_texture_set_sampler_view(struct st_context *st, if (sv->view) { /* check if the context matches */ if (sv->view->context == st->pipe) { - pipe_sampler_view_release(st->pipe, &sv->view); + pipe_sampler_view_reference(&sv->view, NULL); goto found; } } else { @@ -94,13 +94,13 @@ st_texture_set_sampler_view(struct st_context *st, if (new_max < views->max || new_max > (UINT_MAX - sizeof(*views)) / sizeof(views->views[0])) { - pipe_sampler_view_release(st->pipe, &view); + pipe_sampler_view_reference(&view, NULL); goto out; } struct st_sampler_views *new_views = malloc(new_size); if (!new_views) { - pipe_sampler_view_release(st->pipe, &view); + pipe_sampler_view_reference(&view, NULL); goto out; } -- cgit v1.2.3