diff options
author | Brian Paul <brian.paul@tungstengraphics.com> | 2008-07-03 14:55:14 -0600 |
---|---|---|
committer | Brian Paul <brian.paul@tungstengraphics.com> | 2008-07-03 17:21:22 -0600 |
commit | 51abbdd227224c596ae2232ff3137dc3f346d563 (patch) | |
tree | 05bb0135c25a3d47922848ea30dbdbad1e3034cc /src/gallium/auxiliary | |
parent | 78388c0e374349810fe3fb38cd4103a9544df4bf (diff) |
gallium: added a4r4g4b4_put_tile_rgba()
Diffstat (limited to 'src/gallium/auxiliary')
-rw-r--r-- | src/gallium/auxiliary/util/p_tile.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/gallium/auxiliary/util/p_tile.c b/src/gallium/auxiliary/util/p_tile.c index ab603ff6e4..93abef9879 100644 --- a/src/gallium/auxiliary/util/p_tile.c +++ b/src/gallium/auxiliary/util/p_tile.c @@ -298,6 +298,33 @@ a4r4g4b4_get_tile_rgba(ushort *src, } +static void +a4r4g4b4_put_tile_rgba(ushort *dst, + unsigned w, unsigned h, + const float *p, + unsigned src_stride) +{ + unsigned i, j; + + for (i = 0; i < h; i++) { + const float *pRow = p; + for (j = 0; j < w; j++, pRow += 4) { + unsigned r, g, b, a; + UNCLAMPED_FLOAT_TO_UBYTE(r, pRow[0]); + UNCLAMPED_FLOAT_TO_UBYTE(g, pRow[1]); + UNCLAMPED_FLOAT_TO_UBYTE(b, pRow[2]); + UNCLAMPED_FLOAT_TO_UBYTE(a, pRow[3]); + r >>= 4; + g >>= 4; + b >>= 4; + a >>= 4; + *dst++ = (a << 12) | (r << 16) | (g << 4) | b; + } + p += src_stride; + } +} + + /*** PIPE_FORMAT_R5G6B5_UNORM ***/ static void @@ -774,6 +801,10 @@ pipe_put_tile_rgba(struct pipe_context *pipe, r5g5b5_put_tile_rgba((ushort *) packed, w, h, p, src_stride); break; case PIPE_FORMAT_R8G8B8A8_UNORM: + assert(0); + break; + case PIPE_FORMAT_A4R4G4B4_UNORM: + a4r4g4b4_put_tile_rgba((ushort *) packed, w, h, p, src_stride); break; case PIPE_FORMAT_L8_UNORM: /*l8_put_tile_rgba((ubyte *) packed, w, h, p, src_stride);*/ |