intel: It is needed to allocating texture memory to accommodate
authorXiang, Haihao <haihao.xiang@intel.com>
Mon, 17 Mar 2008 08:52:07 +0000 (16:52 +0800)
committerXiang, Haihao <haihao.xiang@intel.com>
Mon, 17 Mar 2008 08:52:07 +0000 (16:52 +0800)
a texture when calling TexImage with pixels set to NULL pointer.

src/mesa/drivers/dri/intel/intel_tex_image.c
src/mesa/drivers/dri/intel/intel_tex_subimage.c

index 5bf1c51538cd8496b5926ee812ee608a57d06617..3d2fc243575806ca81d1de83050a664cdf984181 100644 (file)
@@ -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 */
index bd27b86bf323004d845ae01852f696c6fc2d6234..688e3870df7e2d215af8207a6294659a841b9b47 100644 (file)
@@ -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);