svga: no-op sampler view referencing if no change
authorBrian Paul <brianp@vmware.com>
Fri, 17 Feb 2012 17:18:55 +0000 (10:18 -0700)
committerBrian Paul <brianp@vmware.com>
Thu, 23 Feb 2012 14:49:09 +0000 (07:49 -0700)
Just to be safe with ref counting and avoid atomic operations.

src/gallium/drivers/svga/svga_pipe_sampler.c

index c1ea4f8a92364c6ea9f58257c3f731f54beaa769..7675daac5abecab4354e98fb914e8834a87b2b0e 100644 (file)
@@ -225,12 +225,14 @@ svga_set_fragment_sampler_views(struct pipe_context *pipe,
    }
 
    for (i = 0; i < num; 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[i]);
-      pipe_sampler_view_reference(&svga->curr.sampler_views[i], views[i]);
+      if (svga->curr.sampler_views[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[i]);
+         pipe_sampler_view_reference(&svga->curr.sampler_views[i], views[i]);
+      }
 
       if (!views[i])
          continue;