Mesa (master): intel: Fix segfault when doing SW mipmap generation with a PBO texture upload.

Eric Anholt anholt at kemper.freedesktop.org
Wed Apr 15 19:56:57 UTC 2009


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

Author: Eric Anholt <eric at anholt.net>
Date:   Thu Apr  9 11:03:03 2009 -0700

intel: Fix segfault when doing SW mipmap generation with a PBO texture upload.

Triggered in test-fbo from clutter since
37fb2d9b23eab5dbbb43a212c3475cb8016837d8.

---

 src/mesa/drivers/dri/intel/intel_tex_image.c |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/src/mesa/drivers/dri/intel/intel_tex_image.c b/src/mesa/drivers/dri/intel/intel_tex_image.c
index 71561cf..c81f230 100644
--- a/src/mesa/drivers/dri/intel/intel_tex_image.c
+++ b/src/mesa/drivers/dri/intel/intel_tex_image.c
@@ -316,7 +316,7 @@ intelTexImage(GLcontext * ctx,
    GLint postConvHeight = height;
    GLint texelBytes, sizeInBytes;
    GLuint dstRowStride, srcRowStride = texImage->RowStride;
-
+   GLboolean needs_map;
 
    DBG("%s target %s level %d %dx%dx%d border %d\n", __FUNCTION__,
        _mesa_lookup_enum_by_nr(target), level, width, height, depth, border);
@@ -482,8 +482,15 @@ intelTexImage(GLcontext * ctx,
 
    LOCK_HARDWARE(intel);
 
+   /* Two cases where we need a mapping of the miptree: when the user supplied
+    * data is mapped as well (non-PBO, memcpy upload) or when we're going to do
+    * (software) mipmap generation.
+    */
+   needs_map = (pixels != NULL) || (level == texObj->BaseLevel &&
+				  texObj->GenerateMipmap);
+
    if (intelImage->mt) {
-      if (pixels)
+      if (needs_map)
          texImage->Data = intel_miptree_image_map(intel,
                                                   intelImage->mt,
                                                   intelImage->face,
@@ -549,7 +556,7 @@ intelTexImage(GLcontext * ctx,
    _mesa_unmap_teximage_pbo(ctx, unpack);
 
    if (intelImage->mt) {
-      if (pixels)
+      if (needs_map)
          intel_miptree_image_unmap(intel, intelImage->mt);
       texImage->Data = NULL;
    }




More information about the mesa-commit mailing list