summaryrefslogtreecommitdiff
path: root/src/gallium/auxiliary/util/u_tile.c
diff options
context:
space:
mode:
authorAlan Hourihane <alanh@vmware.com>2010-03-18 18:01:05 +0000
committerAlan Hourihane <alanh@vmware.com>2010-03-18 18:01:41 +0000
commit94abc4b51e134bee1ace2b57400e35c295bda6f8 (patch)
tree3472bafbb67ecbfbdaebd20a540c649d1975a561 /src/gallium/auxiliary/util/u_tile.c
parent521c61ff017ab15b829abbe9a98b179136a36009 (diff)
Add format B5G5R5X1
Diffstat (limited to 'src/gallium/auxiliary/util/u_tile.c')
-rw-r--r--src/gallium/auxiliary/util/u_tile.c55
1 files changed, 55 insertions, 0 deletions
diff --git a/src/gallium/auxiliary/util/u_tile.c b/src/gallium/auxiliary/util/u_tile.c
index 82e44192aa..09b2382733 100644
--- a/src/gallium/auxiliary/util/u_tile.c
+++ b/src/gallium/auxiliary/util/u_tile.c
@@ -295,6 +295,55 @@ r8g8b8a8_put_tile_rgba(unsigned *dst,
}
+/*** PIPE_FORMAT_B5G5R5X1_UNORM ***/
+
+static void
+x1r5g5b5_get_tile_rgba(const ushort *src,
+ unsigned w, unsigned h,
+ float *p,
+ unsigned dst_stride)
+{
+ unsigned i, j;
+
+ for (i = 0; i < h; i++) {
+ float *pRow = p;
+ for (j = 0; j < w; j++, pRow += 4) {
+ const ushort pixel = *src++;
+ pRow[0] = ((pixel >> 10) & 0x1f) * (1.0f / 31.0f);
+ pRow[1] = ((pixel >> 5) & 0x1f) * (1.0f / 31.0f);
+ pRow[2] = ((pixel ) & 0x1f) * (1.0f / 31.0f);
+ pRow[3] = 1.0f;
+ }
+ p += dst_stride;
+ }
+}
+
+
+static void
+x1r5g5b5_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;
+ r = float_to_ubyte(pRow[0]);
+ g = float_to_ubyte(pRow[1]);
+ b = float_to_ubyte(pRow[2]);
+ r = r >> 3; /* 5 bits */
+ g = g >> 3; /* 5 bits */
+ b = b >> 3; /* 5 bits */
+ *dst++ = (1 << 15) | (r << 10) | (g << 5) | b;
+ }
+ p += src_stride;
+ }
+}
+
+
/*** PIPE_FORMAT_B5G5R5A1_UNORM ***/
static void
@@ -1174,6 +1223,9 @@ pipe_tile_raw_to_rgba(enum pipe_format format,
case PIPE_FORMAT_A8B8G8R8_UNORM:
r8g8b8a8_get_tile_rgba((unsigned *) src, w, h, dst, dst_stride);
break;
+ case PIPE_FORMAT_B5G5R5X1_UNORM:
+ x1r5g5b5_get_tile_rgba((ushort *) src, w, h, dst, dst_stride);
+ break;
case PIPE_FORMAT_B5G5R5A1_UNORM:
a1r5g5b5_get_tile_rgba((ushort *) src, w, h, dst, dst_stride);
break;
@@ -1368,6 +1420,9 @@ pipe_put_tile_rgba(struct pipe_context *pipe,
case PIPE_FORMAT_A8B8G8R8_UNORM:
r8g8b8a8_put_tile_rgba((unsigned *) packed, w, h, p, src_stride);
break;
+ case PIPE_FORMAT_B5G5R5X1_UNORM:
+ x1r5g5b5_put_tile_rgba((ushort *) packed, w, h, p, src_stride);
+ break;
case PIPE_FORMAT_B5G5R5A1_UNORM:
a1r5g5b5_put_tile_rgba((ushort *) packed, w, h, p, src_stride);
break;