Mesa (gallium-sampler-view): softpipe: Implement sampler view swizzling.

Michał Król michal at kemper.freedesktop.org
Tue Mar 2 11:03:55 UTC 2010


Module: Mesa
Branch: gallium-sampler-view
Commit: f59f28093ea827bd234d8e1a36bdd56a9fce5f09
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=f59f28093ea827bd234d8e1a36bdd56a9fce5f09

Author: Michal Krol <michal at vmware.com>
Date:   Tue Mar  2 12:03:24 2010 +0100

softpipe: Implement sampler view swizzling.

---

 src/gallium/drivers/softpipe/sp_state_sampler.c  |    6 +---
 src/gallium/drivers/softpipe/sp_tex_tile_cache.c |   29 ++++++++++++++++------
 src/gallium/drivers/softpipe/sp_tex_tile_cache.h |    9 +++++-
 3 files changed, 30 insertions(+), 14 deletions(-)

diff --git a/src/gallium/drivers/softpipe/sp_state_sampler.c b/src/gallium/drivers/softpipe/sp_state_sampler.c
index 8922941..68ea13f 100644
--- a/src/gallium/drivers/softpipe/sp_state_sampler.c
+++ b/src/gallium/drivers/softpipe/sp_state_sampler.c
@@ -166,10 +166,9 @@ softpipe_set_sampler_views(struct pipe_context *pipe,
 
    for (i = 0; i < PIPE_MAX_SAMPLERS; i++) {
       struct pipe_sampler_view *view = i < num ? views[i] : NULL;
-      struct pipe_texture *texture = view ? view->texture : NULL;
 
       pipe_sampler_view_reference(&softpipe->sampler_views[i], view);
-      sp_tex_tile_cache_set_texture(softpipe->tex_cache[i], texture);
+      sp_tex_tile_cache_set_sampler_view(softpipe->tex_cache[i], view);
    }
 
    softpipe->num_sampler_views = num;
@@ -198,10 +197,9 @@ softpipe_set_vertex_sampler_views(struct pipe_context *pipe,
 
    for (i = 0; i < PIPE_MAX_VERTEX_SAMPLERS; i++) {
       struct pipe_sampler_view *view = i < num ? views[i] : NULL;
-      struct pipe_texture *texture = view ? view->texture : NULL;
 
       pipe_sampler_view_reference(&softpipe->vertex_sampler_views[i], view);
-      sp_tex_tile_cache_set_texture(softpipe->vertex_tex_cache[i], texture);
+      sp_tex_tile_cache_set_sampler_view(softpipe->vertex_tex_cache[i], view);
    }
 
    softpipe->num_vertex_sampler_views = num;
diff --git a/src/gallium/drivers/softpipe/sp_tex_tile_cache.c b/src/gallium/drivers/softpipe/sp_tex_tile_cache.c
index a0b95c8..b9635be 100644
--- a/src/gallium/drivers/softpipe/sp_tex_tile_cache.c
+++ b/src/gallium/drivers/softpipe/sp_tex_tile_cache.c
@@ -119,12 +119,13 @@ sp_tex_tile_cache_validate_texture(struct softpipe_tex_tile_cache *tc)
 }
 
 /**
- * Specify the texture to cache.
+ * Specify the sampler view to cache.
  */
 void
-sp_tex_tile_cache_set_texture(struct softpipe_tex_tile_cache *tc,
-                          struct pipe_texture *texture)
+sp_tex_tile_cache_set_sampler_view(struct softpipe_tex_tile_cache *tc,
+                                   struct pipe_sampler_view *view)
 {
+   struct pipe_texture *texture = view ? view->texture : NULL;
    uint i;
 
    assert(!tc->transfer);
@@ -144,6 +145,13 @@ sp_tex_tile_cache_set_texture(struct softpipe_tex_tile_cache *tc,
          tc->tex_trans = NULL;
       }
 
+      if (view) {
+         tc->swizzle_r = view->swizzle_r;
+         tc->swizzle_g = view->swizzle_g;
+         tc->swizzle_b = view->swizzle_b;
+         tc->swizzle_a = view->swizzle_a;
+      }
+
       /* mark as entries as invalid/empty */
       /* XXX we should try to avoid this when the teximage hasn't changed */
       for (i = 0; i < NUM_ENTRIES; i++) {
@@ -257,11 +265,16 @@ sp_find_cached_tile_tex(struct softpipe_tex_tile_cache *tc,
       }
 
       /* get tile from the transfer (view into texture) */
-      pipe_get_tile_rgba(tc->tex_trans,
-                         addr.bits.x * TILE_SIZE, 
-                         addr.bits.y * TILE_SIZE,
-                         TILE_SIZE, TILE_SIZE,
-                         (float *) tile->data.color);
+      pipe_get_tile_swizzle(tc->tex_trans,
+                            addr.bits.x * TILE_SIZE, 
+                            addr.bits.y * TILE_SIZE,
+                            TILE_SIZE,
+                            TILE_SIZE,
+                            tc->swizzle_r,
+                            tc->swizzle_g,
+                            tc->swizzle_b,
+                            tc->swizzle_a,
+                            (float *) tile->data.color);
       tile->addr = addr;
    }
 
diff --git a/src/gallium/drivers/softpipe/sp_tex_tile_cache.h b/src/gallium/drivers/softpipe/sp_tex_tile_cache.h
index ac6886a..c562f72 100644
--- a/src/gallium/drivers/softpipe/sp_tex_tile_cache.h
+++ b/src/gallium/drivers/softpipe/sp_tex_tile_cache.h
@@ -83,6 +83,11 @@ struct softpipe_tex_tile_cache
    void *tex_trans_map;
    int tex_face, tex_level, tex_z;
 
+   unsigned swizzle_r;
+   unsigned swizzle_g;
+   unsigned swizzle_b;
+   unsigned swizzle_a;
+
    struct softpipe_tex_cached_tile *last_tile;  /**< most recently retrieved tile */
 };
 
@@ -101,8 +106,8 @@ extern void
 sp_tex_tile_cache_unmap_transfers(struct softpipe_tex_tile_cache *tc);
 
 extern void
-sp_tex_tile_cache_set_texture(struct softpipe_tex_tile_cache *tc,
-                          struct pipe_texture *texture);
+sp_tex_tile_cache_set_sampler_view(struct softpipe_tex_tile_cache *tc,
+                                   struct pipe_sampler_view *view);
 
 void
 sp_tex_tile_cache_validate_texture(struct softpipe_tex_tile_cache *tc);




More information about the mesa-commit mailing list