summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary/util/p_tile.c
diff options
context:
space:
mode:
authorMichel Dänzer <[email protected]>2008-04-24 10:12:07 +0100
committerMichel Dänzer <[email protected]>2008-04-24 10:18:34 +0100
commit7333578d2a5fa18f7f0101fc3fd3b03cf2f356bc (patch)
treea2e2376f26eee722fb9de3717da92ae8d72d3e15 /src/gallium/auxiliary/util/p_tile.c
parentbb4f8ae1f93d17c57fd8f62bea24b48131e02037 (diff)
gallium: Initial support for pixel formats with unused storage components.
Also clarify that RGB formats with no (used) alpha component are treated as having alpha = 1.0.
Diffstat (limited to 'src/gallium/auxiliary/util/p_tile.c')
-rw-r--r--src/gallium/auxiliary/util/p_tile.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/gallium/auxiliary/util/p_tile.c b/src/gallium/auxiliary/util/p_tile.c
index 520da5cecd5..91283a9ab08 100644
--- a/src/gallium/auxiliary/util/p_tile.c
+++ b/src/gallium/auxiliary/util/p_tile.c
@@ -169,6 +169,52 @@ a8r8g8b8_put_tile_rgba(unsigned *dst,
}
+/*** PIPE_FORMAT_A8R8G8B8_UNORM ***/
+
+static void
+x8r8g8b8_get_tile_rgba(unsigned *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 unsigned pixel = *src++;
+ pRow[0] = UBYTE_TO_FLOAT((pixel >> 16) & 0xff);
+ pRow[1] = UBYTE_TO_FLOAT((pixel >> 8) & 0xff);
+ pRow[2] = UBYTE_TO_FLOAT((pixel >> 0) & 0xff);
+ pRow[3] = UBYTE_TO_FLOAT(0xff);
+ }
+ p += dst_stride;
+ }
+}
+
+
+static void
+x8r8g8b8_put_tile_rgba(unsigned *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;
+ UNCLAMPED_FLOAT_TO_UBYTE(r, pRow[0]);
+ UNCLAMPED_FLOAT_TO_UBYTE(g, pRow[1]);
+ UNCLAMPED_FLOAT_TO_UBYTE(b, pRow[2]);
+ *dst++ = (0xff << 24) | (r << 16) | (g << 8) | b;
+ }
+ p += src_stride;
+ }
+}
+
+
/*** PIPE_FORMAT_B8G8R8A8_UNORM ***/
static void
@@ -647,6 +693,9 @@ pipe_get_tile_rgba(struct pipe_context *pipe,
case PIPE_FORMAT_A8R8G8B8_UNORM:
a8r8g8b8_get_tile_rgba((unsigned *) packed, w, h, p, dst_stride);
break;
+ case PIPE_FORMAT_X8R8G8B8_UNORM:
+ x8r8g8b8_get_tile_rgba((unsigned *) packed, w, h, p, dst_stride);
+ break;
case PIPE_FORMAT_B8G8R8A8_UNORM:
b8g8r8a8_get_tile_rgba((unsigned *) packed, w, h, p, dst_stride);
break;
@@ -723,6 +772,9 @@ pipe_put_tile_rgba(struct pipe_context *pipe,
case PIPE_FORMAT_A8R8G8B8_UNORM:
a8r8g8b8_put_tile_rgba((unsigned *) packed, w, h, p, src_stride);
break;
+ case PIPE_FORMAT_X8R8G8B8_UNORM:
+ x8r8g8b8_put_tile_rgba((unsigned *) packed, w, h, p, src_stride);
+ break;
case PIPE_FORMAT_B8G8R8A8_UNORM:
b8g8r8a8_put_tile_rgba((unsigned *) packed, w, h, p, src_stride);
break;