From 4478926b3a6d15d079a44f6cebebc1db85d382f6 Mon Sep 17 00:00:00 2001 From: "Xiang, Haihao" Date: Mon, 17 Mar 2008 16:52:07 +0800 Subject: [PATCH] intel: It is needed to allocating texture memory to accommodate a texture when calling TexImage with pixels set to NULL pointer. --- src/mesa/drivers/dri/intel/intel_tex_image.c | 46 +++++++++---------- .../drivers/dri/intel/intel_tex_subimage.c | 14 +++++- 2 files changed, 35 insertions(+), 25 deletions(-) diff --git a/src/mesa/drivers/dri/intel/intel_tex_image.c b/src/mesa/drivers/dri/intel/intel_tex_image.c index 5bf1c51538c..3d2fc243575 100644 --- a/src/mesa/drivers/dri/intel/intel_tex_image.c +++ b/src/mesa/drivers/dri/intel/intel_tex_image.c @@ -456,8 +456,6 @@ intelTexImage(GLcontext * ctx, format, type, pixels, unpack, "glTexImage"); } - if (!pixels) - return; LOCK_HARDWARE(intel); @@ -494,27 +492,29 @@ intelTexImage(GLcontext * ctx, * the blitter to copy. Or, use the hardware to do the format * conversion and copy: */ - if (compressed) { - if (intelImage->mt) { - struct intel_region *dst = intelImage->mt->region; - _mesa_copy_rect(texImage->Data, dst->cpp, dst->pitch, - 0, 0, - intelImage->mt->level[level].width, - intelImage->mt->level[level].height/4, - pixels, - srcRowStride, - 0, 0); - } else - memcpy(texImage->Data, pixels, imageSize); - } else if (!texImage->TexFormat->StoreImage(ctx, dims, - texImage->_BaseFormat, - texImage->TexFormat, - texImage->Data, 0, 0, 0, /* dstX/Y/Zoffset */ - dstRowStride, - texImage->ImageOffsets, - width, height, depth, - format, type, pixels, unpack)) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage"); + if (pixels) { + if (compressed) { + if (intelImage->mt) { + struct intel_region *dst = intelImage->mt->region; + _mesa_copy_rect(texImage->Data, dst->cpp, dst->pitch, + 0, 0, + intelImage->mt->level[level].width, + intelImage->mt->level[level].height/4, + pixels, + srcRowStride, + 0, 0); + } else + memcpy(texImage->Data, pixels, imageSize); + } else if (!texImage->TexFormat->StoreImage(ctx, dims, + texImage->_BaseFormat, + texImage->TexFormat, + texImage->Data, 0, 0, 0, /* dstX/Y/Zoffset */ + dstRowStride, + texImage->ImageOffsets, + width, height, depth, + format, type, pixels, unpack)) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage"); + } } /* GL_SGIS_generate_mipmap */ diff --git a/src/mesa/drivers/dri/intel/intel_tex_subimage.c b/src/mesa/drivers/dri/intel/intel_tex_subimage.c index bd27b86bf32..688e3870df7 100644 --- a/src/mesa/drivers/dri/intel/intel_tex_subimage.c +++ b/src/mesa/drivers/dri/intel/intel_tex_subimage.c @@ -50,8 +50,8 @@ intelTexSubimage(GLcontext * ctx, { struct intel_context *intel = intel_context(ctx); struct intel_texture_image *intelImage = intel_texture_image(texImage); - GLuint dstRowStride; - + GLuint dstRowStride = 0; + DBG("%s target %s level %d offset %d,%d %dx%d\n", __FUNCTION__, _mesa_lookup_enum_by_nr(target), level, xoffset, yoffset, width, height); @@ -76,6 +76,16 @@ intelTexSubimage(GLcontext * ctx, intelImage->level, &dstRowStride, texImage->ImageOffsets); + else { + if (texImage->IsCompressed) { + dstRowStride = + _mesa_compressed_row_stride(texImage->TexFormat->MesaFormat, width); + assert(dims != 3); + } + else { + dstRowStride = texImage->RowStride * texImage->TexFormat->TexelBytes; + } + } assert(dstRowStride); -- 2.30.2