summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBrian <[email protected]>2007-12-12 16:30:49 -0700
committerBrian <[email protected]>2007-12-12 16:30:49 -0700
commit417c2953339bc281f0ac486777afbbd00a385294 (patch)
tree30ab9202461ee4dbe86b541661ca4a59b1e34fd8 /src
parent4416514aa82e59eae559b59e49846931fdf85f56 (diff)
added r5g5b5_put_tile_rgba()
Diffstat (limited to 'src')
-rw-r--r--src/mesa/pipe/softpipe/sp_rgba_tile.c35
1 files changed, 33 insertions, 2 deletions
diff --git a/src/mesa/pipe/softpipe/sp_rgba_tile.c b/src/mesa/pipe/softpipe/sp_rgba_tile.c
index 9d8d6a79e07..c42635a1ad9 100644
--- a/src/mesa/pipe/softpipe/sp_rgba_tile.c
+++ b/src/mesa/pipe/softpipe/sp_rgba_tile.c
@@ -275,6 +275,37 @@ r5g6b5_get_tile_rgba(struct pipe_surface *ps,
}
+static void
+r5g5b5_put_tile_rgba(struct pipe_surface *ps,
+ unsigned x, unsigned y, unsigned w, unsigned h,
+ const float *p)
+{
+ ushort *dst
+ = ((ushort *) (ps->map))
+ + y * ps->pitch + x;
+ unsigned i, j;
+ unsigned w0 = w;
+
+ assert(ps->format == PIPE_FORMAT_R5G6B5_UNORM);
+
+ CLIP_TILE;
+
+ for (i = 0; i < h; i++) {
+ const float *pRow = p;
+ for (j = 0; j < w; j++) {
+ uint r = (uint) (CLAMP(pRow[0], 0.0, 1.0) * 31.0);
+ uint g = (uint) (CLAMP(pRow[1], 0.0, 1.0) * 63.0);
+ uint b = (uint) (CLAMP(pRow[2], 0.0, 1.0) * 31.0);
+ dst[j] = (r << 11) | (g << 5) | (b);
+ pRow += 4;
+ }
+ dst += ps->pitch;
+ p += w0 * 4;
+ }
+}
+
+
+
/*** PIPE_FORMAT_Z16_UNORM ***/
/**
@@ -690,9 +721,9 @@ softpipe_put_tile_rgba(struct pipe_context *pipe,
/*a1r5g5b5_put_tile_rgba(ps, x, y, w, h, p);*/
break;
case PIPE_FORMAT_R5G6B5_UNORM:
+ r5g5b5_put_tile_rgba(ps, x, y, w, h, p);
+ break;
case PIPE_FORMAT_R8G8B8A8_UNORM:
- /* XXX need these */
- fprintf(stderr, "unsup pipe format in softpipe_put_tile_rgba()\n");
break;
case PIPE_FORMAT_U_L8:
/*l8_put_tile_rgba(ps, x, y, w, h, p);*/