diff options
author | Michal Krol <[email protected]> | 2010-03-02 12:02:31 +0100 |
---|---|---|
committer | Michal Krol <[email protected]> | 2010-03-02 12:02:31 +0100 |
commit | 5587097b53afbce52f7e26568d2dde11de96e1ec (patch) | |
tree | 180db82c1bc4b78f50179875cf56ef7b7bda507b /src/gallium/auxiliary | |
parent | a69fdb84df17dd91cbfd41fc90a54558cb334297 (diff) |
util: Add pipe_get_tile_swizzle().
Diffstat (limited to 'src/gallium/auxiliary')
-rw-r--r-- | src/gallium/auxiliary/util/u_tile.c | 42 | ||||
-rw-r--r-- | src/gallium/auxiliary/util/u_tile.h | 12 |
2 files changed, 54 insertions, 0 deletions
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 @@ -1274,6 +1274,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, const float *p) 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 @@ -72,6 +72,18 @@ pipe_get_tile_rgba(struct pipe_transfer *pt, 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, const float *p); |