diff options
author | Michel Dänzer <[email protected]> | 2007-12-11 19:07:12 +0100 |
---|---|---|
committer | Michel Dänzer <[email protected]> | 2007-12-11 19:10:56 +0100 |
commit | f3789748d4b8f38bfea2f30ef93e9ff3e3888af4 (patch) | |
tree | 33dd43f35c2509113c34d11b393aa42917a01421 | |
parent | 88723b2fc84628c1bc1e0008b88602b85e8668be (diff) |
softpipe: Support for PIPE_FORMAT_A4R4G4B4_UNORM and PIPE_FORMAT_R5G6B5_UNORM.
The packedpixels test runs with the xlib winsys, though not all cases look
correct yet.
-rw-r--r-- | src/mesa/pipe/softpipe/sp_surface.c | 59 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_format.c | 4 |
2 files changed, 63 insertions, 0 deletions
diff --git a/src/mesa/pipe/softpipe/sp_surface.c b/src/mesa/pipe/softpipe/sp_surface.c index 3ef3db9f1f2..1dc494d6ff8 100644 --- a/src/mesa/pipe/softpipe/sp_surface.c +++ b/src/mesa/pipe/softpipe/sp_surface.c @@ -215,6 +215,59 @@ a1r5g5b5_get_tile(struct pipe_surface *ps, } +/*** PIPE_FORMAT_A4R4G4B4_UNORM ***/ + +static void +a4r4g4b4_get_tile(struct pipe_surface *ps, + unsigned x, unsigned y, unsigned w, unsigned h, float *p) +{ + const ushort *src + = ((const ushort *) (ps->map)) + + y * ps->pitch + x; + unsigned i, j; + + assert(ps->format == PIPE_FORMAT_A4R4G4B4_UNORM); + + for (i = 0; i < h; i++) { + for (j = 0; j < w; j++) { + const ushort pixel = src[j]; + p[0] = ((pixel >> 8) & 0xf) * (1.0f / 15.0f); + p[1] = ((pixel >> 4) & 0xf) * (1.0f / 15.0f); + p[2] = ((pixel ) & 0xf) * (1.0f / 15.0f); + p[3] = ((pixel >> 12) ) * (1.0f / 15.0f); + p += 4; + } + src += ps->pitch; + } +} + + +/*** PIPE_FORMAT_R5G6B5_UNORM ***/ + +static void +r5g6b5_get_tile(struct pipe_surface *ps, + unsigned x, unsigned y, unsigned w, unsigned h, float *p) +{ + const ushort *src + = ((const ushort *) (ps->map)) + + y * ps->pitch + x; + unsigned i, j; + + assert(ps->format == PIPE_FORMAT_R5G6B5_UNORM); + + for (i = 0; i < h; i++) { + for (j = 0; j < w; j++) { + const ushort pixel = src[j]; + p[0] = ((pixel >> 11) & 0x1f) * (1.0f / 31.0f); + p[1] = ((pixel >> 5) & 0x3f) * (1.0f / 63.0f); + p[2] = ((pixel ) & 0x1f) * (1.0f / 31.0f); + p[3] = 1.0f; + p += 4; + } + src += ps->pitch; + } +} + /*** PIPE_FORMAT_Z16_UNORM ***/ @@ -674,6 +727,12 @@ softpipe_get_tile_rgba(struct pipe_context *pipe, case PIPE_FORMAT_A1R5G5B5_UNORM: a1r5g5b5_get_tile(ps, x, y, w, h, p); break; + case PIPE_FORMAT_A4R4G4B4_UNORM: + a4r4g4b4_get_tile(ps, x, y, w, h, p); + break; + case PIPE_FORMAT_R5G6B5_UNORM: + r5g6b5_get_tile(ps, x, y, w, h, p); + break; case PIPE_FORMAT_U_L8: l8_get_tile(ps, x, y, w, h, p); break; diff --git a/src/mesa/state_tracker/st_format.c b/src/mesa/state_tracker/st_format.c index c292a975f38..98cc2084f05 100644 --- a/src/mesa/state_tracker/st_format.c +++ b/src/mesa/state_tracker/st_format.c @@ -254,8 +254,12 @@ st_mesa_format_to_pipe_format(GLuint mesaFormat) case MESA_FORMAT_ARGB8888_REV: case MESA_FORMAT_ARGB8888: return PIPE_FORMAT_A8R8G8B8_UNORM; + case MESA_FORMAT_ARGB1555: + return PIPE_FORMAT_A1R5G5B5_UNORM; case MESA_FORMAT_ARGB4444: return PIPE_FORMAT_A4R4G4B4_UNORM; + case MESA_FORMAT_RGB565: + return PIPE_FORMAT_R5G6B5_UNORM; case MESA_FORMAT_AL88: return PIPE_FORMAT_U_A8_L8; case MESA_FORMAT_A8: |