gallium: pipe_get_tile_swizzle() accepts format parameter.
authorMichal Krol <michal@vmware.com>
Wed, 10 Mar 2010 15:32:34 +0000 (16:32 +0100)
committerMichal Krol <michal@vmware.com>
Wed, 10 Mar 2010 15:32:34 +0000 (16:32 +0100)
Enables casting of texture data.

src/gallium/auxiliary/util/u_tile.c
src/gallium/auxiliary/util/u_tile.h
src/gallium/drivers/softpipe/sp_tex_tile_cache.c
src/gallium/drivers/softpipe/sp_tex_tile_cache.h

index 024d9577bc9703a26da5443064c3dd0f3af6796b..8a36d4d9d187b95d1fea0e9d371aa5a4e4b5d292 100644 (file)
@@ -1283,12 +1283,32 @@ pipe_get_tile_swizzle(struct pipe_transfer *pt,
                       uint swizzle_g,
                       uint swizzle_b,
                       uint swizzle_a,
+                      enum pipe_format format,
                       float *p)
 {
+   unsigned dst_stride = w * 4;
+   void *packed;
    uint i;
    float rgba01[6];
 
-   pipe_get_tile_rgba(pt, x, y, w, h, p);
+   if (pipe_clip_tile(x, y, &w, &h, pt)) {
+      return;
+   }
+
+   packed = MALLOC(util_format_get_nblocks(format, w, h) * util_format_get_blocksize(format));
+   if (!packed) {
+      return;
+   }
+
+   if (format == PIPE_FORMAT_UYVY || format == PIPE_FORMAT_YUYV) {
+      assert((x & 1) == 0);
+   }
+
+   pipe_get_tile_raw(pt, x, y, w, h, packed, 0);
+
+   pipe_tile_raw_to_rgba(format, packed, w, h, p, dst_stride);
+
+   FREE(packed);
 
    if (swizzle_r == PIPE_SWIZZLE_RED &&
        swizzle_g == PIPE_SWIZZLE_GREEN &&
index b4706179a555d2149aae59a7df0b1f90587ff992..d665fdb1bb14aece2f78e644efcb2543ae951a17 100644 (file)
@@ -81,6 +81,7 @@ pipe_get_tile_swizzle(struct pipe_transfer *pt,
                       uint swizzle_g,
                       uint swizzle_b,
                       uint swizzle_a,
+                      enum pipe_format format,
                       float *p);
 
 void
index b9635bee78bb7e6e238c7afb88b376472f045f79..dfa002a79b408dd6bf3372604ec5d847666de121 100644 (file)
@@ -150,6 +150,7 @@ sp_tex_tile_cache_set_sampler_view(struct softpipe_tex_tile_cache *tc,
          tc->swizzle_g = view->swizzle_g;
          tc->swizzle_b = view->swizzle_b;
          tc->swizzle_a = view->swizzle_a;
+         tc->format = view->format;
       }
 
       /* mark as entries as invalid/empty */
@@ -274,6 +275,7 @@ sp_find_cached_tile_tex(struct softpipe_tex_tile_cache *tc,
                             tc->swizzle_g,
                             tc->swizzle_b,
                             tc->swizzle_a,
+                            tc->format,
                             (float *) tile->data.color);
       tile->addr = addr;
    }
index c562f721be7ad5d012d3b71e86f3322876939af6..f8770409d87f8a8e166e2764e0fb2839cc83381e 100644 (file)
@@ -87,6 +87,7 @@ struct softpipe_tex_tile_cache
    unsigned swizzle_g;
    unsigned swizzle_b;
    unsigned swizzle_a;
+   unsigned format;
 
    struct softpipe_tex_cached_tile *last_tile;  /**< most recently retrieved tile */
 };