From 5d4360d10cd39e28ee3b563e95959f3dd22c5242 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Wed, 10 Mar 2010 16:32:34 +0100 Subject: [PATCH] gallium: pipe_get_tile_swizzle() accepts format parameter. Enables casting of texture data. --- src/gallium/auxiliary/util/u_tile.c | 22 +++++++++++++++++++++- src/gallium/auxiliary/util/u_tile.h | 1 + src/gallium/drivers/softpipe/sp_tex_tile_cache.c | 2 ++ src/gallium/drivers/softpipe/sp_tex_tile_cache.h | 1 + 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/gallium/auxiliary/util/u_tile.c b/src/gallium/auxiliary/util/u_tile.c index 024d957..8a36d4d 100644 --- a/src/gallium/auxiliary/util/u_tile.c +++ b/src/gallium/auxiliary/util/u_tile.c @@ -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 && diff --git a/src/gallium/auxiliary/util/u_tile.h b/src/gallium/auxiliary/util/u_tile.h index b470617..d665fdb 100644 --- a/src/gallium/auxiliary/util/u_tile.h +++ b/src/gallium/auxiliary/util/u_tile.h @@ -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 diff --git a/src/gallium/drivers/softpipe/sp_tex_tile_cache.c b/src/gallium/drivers/softpipe/sp_tex_tile_cache.c index b9635be..dfa002a 100644 --- a/src/gallium/drivers/softpipe/sp_tex_tile_cache.c +++ b/src/gallium/drivers/softpipe/sp_tex_tile_cache.c @@ -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; } diff --git a/src/gallium/drivers/softpipe/sp_tex_tile_cache.h b/src/gallium/drivers/softpipe/sp_tex_tile_cache.h index c562f72..f877040 100644 --- a/src/gallium/drivers/softpipe/sp_tex_tile_cache.h +++ b/src/gallium/drivers/softpipe/sp_tex_tile_cache.h @@ -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 */ }; -- 2.7.4