diff options
author | Eric Anholt <[email protected]> | 2011-09-29 14:09:07 -0700 |
---|---|---|
committer | Eric Anholt <[email protected]> | 2011-10-03 13:29:38 -0700 |
commit | 6fc576fd8aa2680e7e35dc7108e29d0091472e33 (patch) | |
tree | 314dadda39024d02af03c86c1becc7342686b813 /src/mesa | |
parent | 229ebf511dcd9b501d9299cfc06d029d1d50079d (diff) |
mesa: Make the uncompressed sw mipmap gen path do a Map per 1D array slice.
This also fixes what was probably a bug in 1D arrays with border.
Reviewed-by: Brian Paul <[email protected]>
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/main/mipmap.c | 61 |
1 files changed, 17 insertions, 44 deletions
diff --git a/src/mesa/main/mipmap.c b/src/mesa/main/mipmap.c index cc46f5c4d22..4dc64a3145b 100644 --- a/src/mesa/main/mipmap.c +++ b/src/mesa/main/mipmap.c @@ -1652,45 +1652,6 @@ make_3d_mipmap(GLenum datatype, GLuint comps, GLint border, } } - -static void -make_1d_stack_mipmap(GLenum datatype, GLuint comps, GLint border, - GLint srcWidth, const GLubyte *srcPtr, GLuint srcRowStride, - GLint dstWidth, GLint dstHeight, - GLubyte *dstPtr, GLuint dstRowStride ) -{ - const GLint bpt = bytes_per_pixel(datatype, comps); - const GLint srcWidthNB = srcWidth - 2 * border; /* sizes w/out border */ - const GLint dstWidthNB = dstWidth - 2 * border; - const GLint dstHeightNB = dstHeight - 2 * border; - const GLubyte *src; - GLubyte *dst; - GLint row; - - /* Compute src and dst pointers, skipping any border */ - src = srcPtr + border * ((srcWidth + 1) * bpt); - dst = dstPtr + border * ((dstWidth + 1) * bpt); - - for (row = 0; row < dstHeightNB; row++) { - do_row(datatype, comps, srcWidthNB, src, src, - dstWidthNB, dst); - src += srcRowStride; - dst += dstRowStride; - } - - if (border) { - /* copy left-most pixel from source */ - assert(dstPtr); - assert(srcPtr); - memcpy(dstPtr, srcPtr, bpt); - /* copy right-most pixel from source */ - memcpy(dstPtr + (dstWidth - 1) * bpt, - srcPtr + (srcWidth - 1) * bpt, - bpt); - } -} - - /** * \bug * There is quite a bit of refactoring that could be done with this function @@ -1805,6 +1766,8 @@ _mesa_generate_mipmap_level(GLenum target, GLubyte **dstData, GLint dstRowStride) { + int i; + switch (target) { case GL_TEXTURE_1D: make_1d_mipmap(datatype, comps, border, @@ -1830,10 +1793,13 @@ _mesa_generate_mipmap_level(GLenum target, dstData, dstRowStride); break; case GL_TEXTURE_1D_ARRAY_EXT: - make_1d_stack_mipmap(datatype, comps, border, - srcWidth, srcData[0], srcRowStride, - dstWidth, dstHeight, - dstData[0], dstRowStride); + assert(srcHeight == 1); + assert(dstHeight == 1); + for (i = 0; i < dstDepth; i++) { + make_1d_mipmap(datatype, comps, border, + srcWidth, srcData[i], + dstWidth, dstData[i]); + } break; case GL_TEXTURE_2D_ARRAY_EXT: make_2d_stack_mipmap(datatype, comps, border, @@ -1957,6 +1923,13 @@ generate_mipmap_uncompressed(struct gl_context *ctx, GLenum target, ASSERT(dstImage->TexFormat); + if (target == GL_TEXTURE_1D_ARRAY) { + srcDepth = srcHeight; + dstDepth = dstHeight; + srcHeight = 1; + dstHeight = 1; + } + /* Map src texture image slices */ srcMaps = (GLubyte **) malloc(srcDepth * sizeof(GLubyte *)); for (slice = 0; slice < srcDepth; slice++) { @@ -1988,7 +1961,7 @@ generate_mipmap_uncompressed(struct gl_context *ctx, GLenum target, } free(srcMaps); - /* Unmap src image slices */ + /* Unmap dst image slices */ for (slice = 0; slice < dstDepth; slice++) { ctx->Driver.UnmapTextureImage(ctx, dstImage, slice); } |