util: Add pipe_get_tile_swizzle().
authorMichal Krol <michal@vmware.com>
Tue, 2 Mar 2010 11:02:31 +0000 (12:02 +0100)
committerMichal Krol <michal@vmware.com>
Tue, 2 Mar 2010 11:02:31 +0000 (12:02 +0100)
src/gallium/auxiliary/util/u_tile.c
src/gallium/auxiliary/util/u_tile.h

index 0051258e22a6d33831294b4438aaf2714a175118..813ce4eb7dc1d5e97db8073a93dbfe4fe131faab 100644 (file)
@@ -1273,6 +1273,48 @@ pipe_get_tile_rgba(struct pipe_transfer *pt,
 }
 
 
+void
+pipe_get_tile_swizzle(struct pipe_transfer *pt,
+                      uint x,
+                      uint y,
+                      uint w,
+                      uint h,
+                      uint swizzle_r,
+                      uint swizzle_g,
+                      uint swizzle_b,
+                      uint swizzle_a,
+                      float *p)
+{
+   uint i;
+   float rgba01[6];
+
+   pipe_get_tile_rgba(pt, x, y, w, h, p);
+
+   if (swizzle_r == PIPE_SWIZZLE_RED &&
+       swizzle_g == PIPE_SWIZZLE_GREEN &&
+       swizzle_b == PIPE_SWIZZLE_BLUE &&
+       swizzle_a == PIPE_SWIZZLE_ALPHA) {
+      /* no-op, skip */
+      return;
+   }
+
+   rgba01[PIPE_SWIZZLE_ZERO] = 0.0f;
+   rgba01[PIPE_SWIZZLE_ONE] = 1.0f;
+
+   for (i = 0; i < w * h; i++) {
+      rgba01[PIPE_SWIZZLE_RED] = p[0];
+      rgba01[PIPE_SWIZZLE_GREEN] = p[1];
+      rgba01[PIPE_SWIZZLE_BLUE] = p[2];
+      rgba01[PIPE_SWIZZLE_ALPHA] = p[3];
+
+      *p++ = rgba01[swizzle_r];
+      *p++ = rgba01[swizzle_g];
+      *p++ = rgba01[swizzle_b];
+      *p++ = rgba01[swizzle_a];
+   }
+}
+
+
 void
 pipe_put_tile_rgba(struct pipe_transfer *pt,
                    uint x, uint y, uint w, uint h,
index 1453af38b8a2aefc977927c1d3d92fe97d06d6c2..b4706179a555d2149aae59a7df0b1f90587ff992 100644 (file)
@@ -71,6 +71,18 @@ pipe_get_tile_rgba(struct pipe_transfer *pt,
                    uint x, uint y, uint w, uint h,
                    float *p);
 
+void
+pipe_get_tile_swizzle(struct pipe_transfer *pt,
+                      uint x,
+                      uint y,
+                      uint w,
+                      uint h,
+                      uint swizzle_r,
+                      uint swizzle_g,
+                      uint swizzle_b,
+                      uint swizzle_a,
+                      float *p);
+
 void
 pipe_put_tile_rgba(struct pipe_transfer *pt,
                    uint x, uint y, uint w, uint h,