diff options
author | Eric Anholt <[email protected]> | 2011-10-11 20:41:01 -0700 |
---|---|---|
committer | Eric Anholt <[email protected]> | 2011-11-03 23:29:52 -0700 |
commit | b832ac974f2b5a0f07ff9b7bb9338e8d6942eb74 (patch) | |
tree | fb6bd704b944d2c84df0f7f82d18adff249562a4 /src/mesa/main | |
parent | ff27e058bc93338ef0dbe322ab4e588ea4bbec0d (diff) |
swrast: Make the packed depth/stencil read fastpath use MapRenderbuffer.
This also makes it handle 24/8 vs 8/24, fixing piglit
depthstencil-default_fb-readpixels-24_8 on i965. While here, avoid
incorrectly fast-pathing if packing->SwapBytes is set.
v2: Move the unpack code to format_unpack.c, fix BUFFER_DEPTH typo
v3: Fix signed/unsigned comparison.
Reviewed-by: Brian Paul <[email protected]>
Diffstat (limited to 'src/mesa/main')
-rw-r--r-- | src/mesa/main/format_unpack.c | 35 | ||||
-rw-r--r-- | src/mesa/main/format_unpack.h | 4 |
2 files changed, 39 insertions, 0 deletions
diff --git a/src/mesa/main/format_unpack.c b/src/mesa/main/format_unpack.c index 3d044af0d4d..eaa33dfdb71 100644 --- a/src/mesa/main/format_unpack.c +++ b/src/mesa/main/format_unpack.c @@ -1539,3 +1539,38 @@ _mesa_unpack_ubyte_stencil_row(gl_format format, GLuint n, return; } } + +static void +unpack_uint_24_8_depth_stencil_S8_Z24(const GLuint *src, GLuint *dst, GLuint n) +{ + GLuint i; + + for (i = 0; i < n; i++) { + GLuint val = src[i]; + dst[i] = val >> 24 | val << 8; + } +} + +static void +unpack_uint_24_8_depth_stencil_Z24_S8(const GLuint *src, GLuint *dst, GLuint n) +{ + memcpy(dst, src, n * 4); +} + +void +_mesa_unpack_uint_24_8_depth_stencil_row(gl_format format, GLuint n, + const void *src, GLuint *dst) +{ + switch (format) { + case MESA_FORMAT_Z24_S8: + unpack_uint_24_8_depth_stencil_Z24_S8(src, dst, n); + break; + case MESA_FORMAT_S8_Z24: + unpack_uint_24_8_depth_stencil_S8_Z24(src, dst, n); + break; + default: + _mesa_problem(NULL, "bad format %s in _mesa_unpack_ubyte_s_row", + _mesa_get_format_name(format)); + return; + } +} diff --git a/src/mesa/main/format_unpack.h b/src/mesa/main/format_unpack.h index 2e00047c201..a8a829c8867 100644 --- a/src/mesa/main/format_unpack.h +++ b/src/mesa/main/format_unpack.h @@ -49,5 +49,9 @@ void _mesa_unpack_ubyte_stencil_row(gl_format format, GLuint n, const void *src, GLubyte *dst); +void +_mesa_unpack_uint_24_8_depth_stencil_row(gl_format format, GLuint n, + const void *src, GLuint *dst); + #endif /* FORMAT_UNPACK_H */ |