summaryrefslogtreecommitdiffstats
path: root/src/mesa/main
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2011-10-11 17:07:37 -0700
committerEric Anholt <[email protected]>2011-11-03 23:29:52 -0700
commitff27e058bc93338ef0dbe322ab4e588ea4bbec0d (patch)
tree1281874e1016191ba644cbcc37b60917dc928481 /src/mesa/main
parent492d223590569448c5666d421444102b50dda90d (diff)
swrast: Directly map the stencil buffer in read_stencil_pixels.
This avoids going through the wrapper that has to rewrite the data for packed depth/stencil. This isn't done in _swrast_read_stencil_span because we don't want to map/unmap for each span. v2: Move the unpack code to format_unpack.c. 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.c58
-rw-r--r--src/mesa/main/format_unpack.h4
2 files changed, 62 insertions, 0 deletions
diff --git a/src/mesa/main/format_unpack.c b/src/mesa/main/format_unpack.c
index fbda03135e9..3d044af0d4d 100644
--- a/src/mesa/main/format_unpack.c
+++ b/src/mesa/main/format_unpack.c
@@ -1480,4 +1480,62 @@ _mesa_unpack_uint_z_row(gl_format format, GLuint n,
}
}
+static void
+unpack_ubyte_s_S8(const void *src, GLubyte *dst, GLuint n)
+{
+ memcpy(dst, src, n);
+}
+
+static void
+unpack_ubyte_s_Z24_S8(const void *src, GLubyte *dst, GLuint n)
+{
+ GLuint i;
+ const GLuint *src32 = src;
+
+ for (i = 0; i < n; i++)
+ dst[i] = src32[i] & 0xff;
+}
+
+static void
+unpack_ubyte_s_S8_Z24(const void *src, GLubyte *dst, GLuint n)
+{
+ GLuint i;
+ const GLuint *src32 = src;
+
+ for (i = 0; i < n; i++)
+ dst[i] = src32[i] >> 24;
+}
+
+static void
+unpack_ubyte_s_Z32_FLOAT_X24S8(const void *src, GLubyte *dst, GLuint n)
+{
+ GLuint i;
+ const GLuint *src32 = src;
+
+ for (i = 0; i < n; i++)
+ dst[i] = src32[i * 2 + 1] & 0xff;
+}
+void
+_mesa_unpack_ubyte_stencil_row(gl_format format, GLuint n,
+ const void *src, GLubyte *dst)
+{
+ switch (format) {
+ case MESA_FORMAT_S8:
+ unpack_ubyte_s_S8(src, dst, n);
+ break;
+ case MESA_FORMAT_Z24_S8:
+ unpack_ubyte_s_Z24_S8(src, dst, n);
+ break;
+ case MESA_FORMAT_S8_Z24:
+ unpack_ubyte_s_S8_Z24(src, dst, n);
+ break;
+ case MESA_FORMAT_Z32_FLOAT_X24S8:
+ unpack_ubyte_s_Z32_FLOAT_X24S8(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 c37727d91a0..2e00047c201 100644
--- a/src/mesa/main/format_unpack.h
+++ b/src/mesa/main/format_unpack.h
@@ -45,5 +45,9 @@ void
_mesa_unpack_uint_z_row(gl_format format, GLuint n,
const void *src, GLuint *dst);
+void
+_mesa_unpack_ubyte_stencil_row(gl_format format, GLuint n,
+ const void *src, GLubyte *dst);
+
#endif /* FORMAT_UNPACK_H */