diff options
author | Jakob Bornecrantz <[email protected]> | 2009-06-11 19:26:55 +0100 |
---|---|---|
committer | Jakob Bornecrantz <[email protected]> | 2009-06-12 12:29:02 +0100 |
commit | c6de08fff483911953692693c501bc200c235dce (patch) | |
tree | 98e5610107c9472b66f94b825f178bbe3e7cb21d /src/mesa/main/texstore.c | |
parent | 3754c4135cb29e23bd81d573af458742e9a624b2 (diff) |
mesa: Enable uploads of only depth to z24s8 textures
Diffstat (limited to 'src/mesa/main/texstore.c')
-rw-r--r-- | src/mesa/main/texstore.c | 39 |
1 files changed, 36 insertions, 3 deletions
diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c index f3739f950b0..bfced1b3f4f 100644 --- a/src/mesa/main/texstore.c +++ b/src/mesa/main/texstore.c @@ -2689,12 +2689,45 @@ GLboolean _mesa_texstore_z24_s8(TEXSTORE_PARAMS) { const GLfloat depthScale = (GLfloat) 0xffffff; + const GLint srcRowStride + = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType) + / sizeof(GLuint); + GLint img, row; ASSERT(dstFormat == &_mesa_texformat_z24_s8); - ASSERT(srcFormat == GL_DEPTH_STENCIL_EXT); - ASSERT(srcType == GL_UNSIGNED_INT_24_8_EXT); + ASSERT(srcFormat == GL_DEPTH_STENCIL_EXT || srcFormat == GL_DEPTH_COMPONENT); + ASSERT(srcFormat != GL_DEPTH_STENCIL_EXT || srcType == GL_UNSIGNED_INT_24_8_EXT); - if (ctx->Pixel.DepthScale == 1.0f && + /* In case we only upload depth we need to preserve the stencil */ + if (srcFormat == GL_DEPTH_COMPONENT) { + for (img = 0; img < srcDepth; img++) { + GLuint *dstRow = (GLuint *) dstAddr + + dstImageOffsets[dstZoffset + img] + + dstYoffset * dstRowStride / sizeof(GLuint) + + dstXoffset; + const GLuint *src + = (const GLuint *) _mesa_image_address(dims, srcPacking, srcAddr, + srcWidth, srcHeight, + srcFormat, srcType, + img, 0, 0); + for (row = 0; row < srcHeight; row++) { + GLuint depth[MAX_WIDTH]; + GLint i; + _mesa_unpack_depth_span(ctx, srcWidth, + GL_UNSIGNED_INT, /* dst type */ + depth, /* dst addr */ + depthScale, + srcType, src, srcPacking); + + for (i = 0; i < srcWidth; i++) + dstRow[i] = depth[i] << 8 | (dstRow[i] & 0x000000FF); + + src += srcRowStride; + dstRow += dstRowStride / sizeof(GLuint); + } + } + } + else if (ctx->Pixel.DepthScale == 1.0f && ctx->Pixel.DepthBias == 0.0f && !srcPacking->SwapBytes) { /* simple path */ |