From: Brian Paul Date: Fri, 23 Apr 2010 19:38:13 +0000 (-0600) Subject: mesa: simplify some code in _mesa_generate_mipmap() X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=57fc2e7802d1903848c2d7799f7e36308818b2e2;p=mesa.git mesa: simplify some code in _mesa_generate_mipmap() --- diff --git a/src/mesa/main/mipmap.c b/src/mesa/main/mipmap.c index 51f7edfab12..c0c29f78893 100644 --- a/src/mesa/main/mipmap.c +++ b/src/mesa/main/mipmap.c @@ -1581,7 +1581,7 @@ _mesa_generate_mipmap(GLcontext *ctx, GLenum target, struct gl_texture_image *dstImage; GLint srcWidth, srcHeight, srcDepth; GLint dstWidth, dstHeight, dstDepth; - GLint border, bytesPerTexel; + GLint border; GLboolean nextLevel; /* get src image parameters */ @@ -1623,33 +1623,24 @@ _mesa_generate_mipmap(GLcontext *ctx, GLenum target, dstImage->FetchTexelc = srcImage->FetchTexelc; dstImage->FetchTexelf = srcImage->FetchTexelf; - /* Alloc new teximage data buffer. - * Setup src and dest data pointers. - */ - if (_mesa_is_format_compressed(dstImage->TexFormat)) { - GLuint dstCompressedSize = - _mesa_format_image_size(dstImage->TexFormat, dstImage->Width, - dstImage->Height, dstImage->Depth); - ASSERT(dstCompressedSize > 0); - - dstImage->Data = _mesa_alloc_texmemory(dstCompressedSize); + /* Alloc new teximage data buffer */ + { + GLuint size = _mesa_format_image_size(dstImage->TexFormat, + dstWidth, dstHeight, dstDepth); + dstImage->Data = _mesa_alloc_texmemory(size); if (!dstImage->Data) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "generating mipmaps"); return; } + } + + /* Setup src and dest data pointers */ + if (_mesa_is_format_compressed(dstImage->TexFormat)) { /* srcData and dstData are already set */ ASSERT(srcData); ASSERT(dstData); } else { - bytesPerTexel = _mesa_get_format_bytes(dstImage->TexFormat); - ASSERT(dstWidth * dstHeight * dstDepth * bytesPerTexel > 0); - dstImage->Data = _mesa_alloc_texmemory(dstWidth * dstHeight - * dstDepth * bytesPerTexel); - if (!dstImage->Data) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "generating mipmaps"); - return; - } srcData = (const GLubyte *) srcImage->Data; dstData = (GLubyte *) dstImage->Data; }