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
---
 src/mesa/state_tracker/st_context.c      | 3 +--
 src/mesa/state_tracker/st_sampler_view.c | 6 +++---
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/src/mesa/state_tracker/st_context.c 
b/src/mesa/state_tracker/st_context.c
index 1e5742b..de98ddc 100644
--- a/src/mesa/state_tracker/st_context.c
+++ b/src/mesa/state_tracker/st_context.c
@@ -435,8 +435,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 d16d523..23e6c6e 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;
          }
 
-- 
1.8.5.6

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to