[Mesa-dev] [PATCH 2/6] svga: stop using pipe_sampler_view_release()

Brian Paul brianp at vmware.com
Fri Mar 8 22:52:10 UTC 2019


This function was used in the past to avoid deleting a sampler view
for a context that no longer exists.  But the Mesa state tracker
ensures that cannot happen.  Use the standard refcounting function
instead.

Testing Done: google chrome, variety of GL demos/games
---
 src/gallium/drivers/svga/svga_pipe_sampler.c | 12 ++++--------
 src/gallium/drivers/svga/svga_state_tss.c    |  4 ++--
 2 files changed, 6 insertions(+), 10 deletions(-)

diff --git a/src/gallium/drivers/svga/svga_pipe_sampler.c b/src/gallium/drivers/svga/svga_pipe_sampler.c
index b32bb09..429f072 100644
--- a/src/gallium/drivers/svga/svga_pipe_sampler.c
+++ b/src/gallium/drivers/svga/svga_pipe_sampler.c
@@ -465,7 +465,8 @@ svga_set_sampler_views(struct pipe_context *pipe,
     */
    if (start == 0 && num == 0 && svga->curr.num_sampler_views[shader] > 0) {
       for (i = 0; i < svga->curr.num_sampler_views[shader]; i++) {
-         pipe_sampler_view_release(pipe, &svga->curr.sampler_views[shader][i]);
+         pipe_sampler_view_reference(&svga->curr.sampler_views[shader][i],
+                                     NULL);
       }
       any_change = TRUE;
    }
@@ -474,11 +475,6 @@ svga_set_sampler_views(struct pipe_context *pipe,
       enum pipe_texture_target target;
 
       if (svga->curr.sampler_views[shader][start + i] != views[i]) {
-         /* Note: we're using pipe_sampler_view_release() here to work around
-          * a possible crash when the old view belongs to another context that
-          * was already destroyed.
-          */
-         pipe_sampler_view_release(pipe, &svga->curr.sampler_views[shader][start + i]);
          pipe_sampler_view_reference(&svga->curr.sampler_views[shader][start + i],
                                      views[i]);
          any_change = TRUE;
@@ -552,8 +548,8 @@ svga_cleanup_sampler_state(struct svga_context *svga)
       unsigned i;
 
       for (i = 0; i < svga->state.hw_draw.num_sampler_views[shader]; i++) {
-         pipe_sampler_view_release(&svga->pipe,
-                                   &svga->state.hw_draw.sampler_views[shader][i]);
+         pipe_sampler_view_reference(&svga->state.hw_draw.sampler_views[shader][i],
+                                     NULL);
       }
    }
    
diff --git a/src/gallium/drivers/svga/svga_state_tss.c b/src/gallium/drivers/svga/svga_state_tss.c
index d598d23..95b1a9e 100644
--- a/src/gallium/drivers/svga/svga_state_tss.c
+++ b/src/gallium/drivers/svga/svga_state_tss.c
@@ -50,8 +50,8 @@ svga_cleanup_tss_binding(struct svga_context *svga)
       struct svga_hw_view_state *view = &svga->state.hw_draw.views[i];
       if (view) {
          svga_sampler_view_reference(&view->v, NULL);
-         pipe_sampler_view_release(&svga->pipe,
-                                   &svga->curr.sampler_views[shader][i]);
+         pipe_sampler_view_reference(&svga->curr.sampler_views[shader][i],
+                                     NULL);
          pipe_resource_reference(&view->texture, NULL);
          view->dirty = TRUE;
       }
-- 
1.8.5.6



More information about the mesa-dev mailing list