softpipe: invalidate cache view when swizzles are different.
authorDave Airlie <airlied@redhat.com>
Sun, 2 May 2010 07:37:18 +0000 (17:37 +1000)
committerDave Airlie <airlied@redhat.com>
Mon, 3 May 2010 06:27:42 +0000 (16:27 +1000)
Current code only invalidated if the texture was different, however we
store swizzled values in the cache, so we need to invalidate in that case
also.

Signed-off-by: Dave Airlie <airlied@redhat.com>
src/gallium/drivers/softpipe/sp_tex_tile_cache.c

index fbce9e042ba3522e669a8059d921290181a86387..b3e1c49406971ddb6ac3188968d0e4a542aede4f 100644 (file)
@@ -115,6 +115,20 @@ sp_tex_tile_cache_validate_texture(struct softpipe_tex_tile_cache *tc)
    }
 }
 
+static boolean
+sp_tex_tile_is_compat_view(struct softpipe_tex_tile_cache *tc,
+                           struct pipe_sampler_view *view)
+{
+   if (!view)
+      return FALSE;
+   return (tc->texture == view->texture &&
+           tc->format == view->format &&
+           tc->swizzle_r == view->swizzle_r &&
+           tc->swizzle_g == view->swizzle_g &&
+           tc->swizzle_b == view->swizzle_b &&
+           tc->swizzle_a == view->swizzle_a);
+}
+
 /**
  * Specify the sampler view to cache.
  */
@@ -127,7 +141,7 @@ sp_tex_tile_cache_set_sampler_view(struct softpipe_tex_tile_cache *tc,
 
    assert(!tc->transfer);
 
-   if (tc->texture != texture) {
+   if (!sp_tex_tile_is_compat_view(tc, view)) {
       pipe_resource_reference(&tc->texture, texture);
 
       if (tc->tex_trans) {