svga: stop using pipe_sampler_view_release()
authorBrian Paul <brianp@vmware.com>
Fri, 8 Mar 2019 21:02:53 +0000 (14:02 -0700)
committerBrian Paul <brianp@vmware.com>
Mon, 18 Mar 2019 02:07:22 +0000 (20:07 -0600)
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.

Also, remove the code which checked for context mis-matches in
svga_sampler_view_destroy().  It's no longer needed since implementing
the zombie sampler view code in the state tracker.

Testing Done: google chrome, variety of 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/gallium/drivers/svga/svga_pipe_sampler.c
src/gallium/drivers/svga/svga_state_tss.c

index b32bb098f7f24ae099257c3917caafc4714a2932..f1e68dd726a3e6ba509e2428b749e300899d45b4 100644 (file)
@@ -405,28 +405,18 @@ svga_sampler_view_destroy(struct pipe_context *pipe,
    struct svga_pipe_sampler_view *sv = svga_pipe_sampler_view(view);
 
    if (svga_have_vgpu10(svga) && sv->id != SVGA3D_INVALID_ID) {
-      if (view->context != pipe) {
-         /* The SVGA3D device will generate an error (and on Linux, cause
-          * us to abort) if we try to destroy a shader resource view from
-          * a context other than the one it was created with.  Skip the
-          * SVGA3D_vgpu10_DestroyShaderResourceView() and leak the sampler
-          * view for now.  This should only sometimes happen when a shared
-          * texture is deleted.
-          */
-         _debug_printf("context mismatch in %s\n", __func__);
-      }
-      else {
-         enum pipe_error ret;
+      enum pipe_error ret;
+
+      assert(view->context == pipe);
 
-         svga_hwtnl_flush_retry(svga); /* XXX is this needed? */
+      svga_hwtnl_flush_retry(svga);
 
+      ret = SVGA3D_vgpu10_DestroyShaderResourceView(svga->swc, sv->id);
+      if (ret != PIPE_OK) {
+         svga_context_flush(svga, NULL);
          ret = SVGA3D_vgpu10_DestroyShaderResourceView(svga->swc, sv->id);
-         if (ret != PIPE_OK) {
-            svga_context_flush(svga, NULL);
-            ret = SVGA3D_vgpu10_DestroyShaderResourceView(svga->swc, sv->id);
-         }
-         util_bitmask_clear(svga->sampler_view_id_bm, sv->id);
       }
+      util_bitmask_clear(svga->sampler_view_id_bm, sv->id);
    }
 
    pipe_resource_reference(&sv->base.texture, NULL);
@@ -465,7 +455,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 +465,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 +538,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);
       }
    }
    
index d598d23c4eaed9da5484776f33fa50cff48ab50b..95b1a9e952dc5fcb00649b3eeed9445fbcd7b119 100644 (file)
@@ -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;
       }