Mesa (master): st/mesa: check image size before copy_image_data_to_texture( )

Brian Paul brianp at kemper.freedesktop.org
Thu Apr 21 12:02:25 PDT 2011


Module: Mesa
Branch: master
Commit: a22aba4eae9b29db731487bce90e8292f7e82c72
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=a22aba4eae9b29db731487bce90e8292f7e82c72

Author: Brian Paul <brianp at vmware.com>
Date:   Thu Apr 21 12:59:16 2011 -0600

st/mesa: check image size before copy_image_data_to_texture()

We should only copy images into the dest texture if the size is correct.
This fixes a failed assertion when finalizing a texture with mis-defined
mipmap levels such as:
level 0: 32x32
level 1: 8x8

Also, fix incorrect mipmap level used in assertion at the top of
copy_image_data_to_texture().

NOTE: This is a candidate for the 7.10 branch.

---

 src/mesa/state_tracker/st_cb_texture.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c
index 43c24ae..ab7f6a5 100644
--- a/src/mesa/state_tracker/st_cb_texture.c
+++ b/src/mesa/state_tracker/st_cb_texture.c
@@ -1686,7 +1686,7 @@ copy_image_data_to_texture(struct st_context *st,
    /* debug checks */
    {
       const struct gl_texture_image *dstImage =
-         stObj->base.Image[stImage->face][stImage->level];
+         stObj->base.Image[stImage->face][dstLevel];
       assert(dstImage);
       assert(dstImage->Width == stImage->base.Width);
       assert(dstImage->Height == stImage->base.Height);
@@ -1843,7 +1843,12 @@ st_finalize_texture(struct gl_context *ctx,
          /* Need to import images in main memory or held in other textures.
           */
          if (stImage && stObj->pt != stImage->pt) {
-            copy_image_data_to_texture(st, stObj, level, stImage);
+            if (stImage->base.Width == u_minify(stObj->width0, level) &&
+                stImage->base.Height == u_minify(stObj->height0, level) &&
+                stImage->base.Depth == u_minify(stObj->depth0, level)) {
+               /* src image fits expected dest mipmap level size */
+               copy_image_data_to_texture(st, stObj, level, stImage);
+            }
          }
       }
    }



More information about the mesa-commit mailing list