From 57fc2e7802d1903848c2d7799f7e36308818b2e2 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 23 Apr 2010 13:38:13 -0600 Subject: [PATCH] mesa: simplify some code in _mesa_generate_mipmap() --- src/mesa/main/mipmap.c | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) 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; } -- 2.30.2