summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2005-10-01 16:02:38 +0000
committerBrian Paul <[email protected]>2005-10-01 16:02:38 +0000
commit31340f6645b34314469894c02b1df88886811e85 (patch)
treecf77023da750c500709634a23331a6230c9ae68c /src/mesa
parent3d61c2e778e5592a52eef21fab6cc301b54f449e (diff)
added _mesa_pack_depth_stencil_span()
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/main/image.c47
-rw-r--r--src/mesa/main/image.h7
2 files changed, 54 insertions, 0 deletions
diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c
index b6841d7a136..3523505cfcb 100644
--- a/src/mesa/main/image.c
+++ b/src/mesa/main/image.c
@@ -4084,6 +4084,53 @@ _mesa_pack_depth_span( const GLcontext *ctx, GLuint n, GLvoid *dest,
}
+
+/**
+ * Pack depth and stencil values as GL_DEPTH_STENCIL/GL_UNSIGNED_INT_24_8.
+ */
+void
+_mesa_pack_depth_stencil_span(const GLcontext *ctx, GLuint n, GLuint *dest,
+ const GLfloat *depthVals,
+ const GLstencil *stencilVals,
+ const struct gl_pixelstore_attrib *dstPacking)
+{
+ GLfloat depthCopy[MAX_WIDTH];
+ GLstencil stencilCopy[MAX_WIDTH];
+ GLuint i;
+
+ ASSERT(n <= MAX_WIDTH);
+
+ if (ctx->Pixel.DepthScale != 1.0 || ctx->Pixel.DepthBias != 0.0) {
+ _mesa_memcpy(depthCopy, depthVals, n * sizeof(GLfloat));
+ _mesa_scale_and_bias_depth(ctx, n, depthCopy);
+ depthVals = depthCopy;
+ }
+
+ if (ctx->Pixel.IndexShift || ctx->Pixel.IndexOffset) {
+ _mesa_memcpy(stencilCopy, stencilVals, n * sizeof(GLstencil));
+ _mesa_shift_and_offset_stencil(ctx, n, stencilCopy);
+ stencilVals = stencilCopy;
+ }
+ if (ctx->Pixel.MapStencilFlag) {
+ if (stencilVals != stencilCopy)
+ _mesa_memcpy(stencilCopy, stencilVals, n * sizeof(GLstencil));
+ _mesa_map_stencil(ctx, n, stencilCopy);
+ stencilVals = stencilCopy;
+ }
+
+ for (i = 0; i < n; i++) {
+ GLuint z = (GLuint) (depthVals[i] * 0xffffff);
+ dest[i] = (z << 8) | (stencilVals[i] & 0xff);
+ }
+
+ if (dstPacking->SwapBytes) {
+ _mesa_swap4(dest, n);
+ }
+}
+
+
+
+
/**
* Unpack image data. Apply byte swapping, byte flipping (bitmap).
* Return all image data in a contiguous block. This is used when we
diff --git a/src/mesa/main/image.h b/src/mesa/main/image.h
index 74be4aebaa0..e31959565af 100644
--- a/src/mesa/main/image.h
+++ b/src/mesa/main/image.h
@@ -189,6 +189,13 @@ _mesa_pack_depth_span( const GLcontext *ctx, GLuint n, GLvoid *dest,
const struct gl_pixelstore_attrib *dstPacking );
+extern void
+_mesa_pack_depth_stencil_span(const GLcontext *ctx, GLuint n, GLuint *dest,
+ const GLfloat *depthVals,
+ const GLstencil *stencilVals,
+ const struct gl_pixelstore_attrib *dstPacking);
+
+
extern void *
_mesa_unpack_image( GLuint dimensions,
GLsizei width, GLsizei height, GLsizei depth,