summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2010-04-23 13:38:13 -0600
committerBrian Paul <[email protected]>2010-04-23 15:41:49 -0600
commit57fc2e7802d1903848c2d7799f7e36308818b2e2 (patch)
tree1179fcbaf966c8dcca7ebf9ac9c8d8038d3c5255
parent67f928eef38f65462dcb286c0beb17ac02041562 (diff)
mesa: simplify some code in _mesa_generate_mipmap()
-rw-r--r--src/mesa/main/mipmap.c29
1 files 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;
}