From 5587097b53afbce52f7e26568d2dde11de96e1ec Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Tue, 2 Mar 2010 12:02:31 +0100 Subject: [PATCH] util: Add pipe_get_tile_swizzle(). --- src/gallium/auxiliary/util/u_tile.c | 42 +++++++++++++++++++++++++++++ src/gallium/auxiliary/util/u_tile.h | 12 +++++++++ 2 files changed, 54 insertions(+) diff --git a/src/gallium/auxiliary/util/u_tile.c b/src/gallium/auxiliary/util/u_tile.c index 0051258e22a..813ce4eb7dc 100644 --- a/src/gallium/auxiliary/util/u_tile.c +++ b/src/gallium/auxiliary/util/u_tile.c @@ -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, diff --git a/src/gallium/auxiliary/util/u_tile.h b/src/gallium/auxiliary/util/u_tile.h index 1453af38b8a..b4706179a55 100644 --- a/src/gallium/auxiliary/util/u_tile.h +++ b/src/gallium/auxiliary/util/u_tile.h @@ -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, -- 2.30.2