st/mesa: stop using pipe_sampler_view_release()
authorBrian Paul <brianp@vmware.com>
Fri, 8 Mar 2019 20:39:05 +0000 (13:39 -0700)
committerBrian Paul <brianp@vmware.com>
Mon, 18 Mar 2019 02:07:22 +0000 (20:07 -0600)
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 <sroland@vmware.com>
Reviewed-by: Neha Bhende <bhenden@vmware.com>
Reviewed-by: Mathias Fröhlich <Mathias.Froehlich@web.de>
Reviewed-By: Jose Fonseca <jfonseca@vmware.com>
src/mesa/state_tracker/st_context.c
src/mesa/state_tracker/st_sampler_view.c

index de2264da5898afd5ca44666f4a2731d7d1b5022e..f03738452a72e3e76fa9a4bbdbc1acc527e878d6 100644 (file)
@@ -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 */
index b20a00cff7ddd079c16d451306c834964592b786..eb97f2bb6b7d0e600c88cb48a7b5ab48ad0de9fe 100644 (file)
@@ -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;
          }