intel: Avoid mapping the texture image for CopyTex{,Sub}Image
authorAdam Jackson <ajax@redhat.com>
Mon, 30 Mar 2009 20:32:11 +0000 (16:32 -0400)
committerAdam Jackson <ajax@redhat.com>
Mon, 30 Mar 2009 20:32:11 +0000 (16:32 -0400)
We don't upload the pixels with the CPU in that case, so the map will
only serve as a way of triggering cache flushes over a bunch of data we
don't touch.

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

index e902187637d9ad39290be0d98b658e5064dacce1..61ecabfa68070d599b5bc030599c9e5631bd6b2b 100644 (file)
@@ -482,12 +482,13 @@ intelTexImage(GLcontext * ctx,
    LOCK_HARDWARE(intel);
 
    if (intelImage->mt) {
-      texImage->Data = intel_miptree_image_map(intel,
-                                               intelImage->mt,
-                                               intelImage->face,
-                                               intelImage->level,
-                                               &dstRowStride,
-                                               intelImage->base.ImageOffsets);
+      if (pixels)
+         texImage->Data = intel_miptree_image_map(intel,
+                                                  intelImage->mt,
+                                                  intelImage->face,
+                                                  intelImage->level,
+                                                  &dstRowStride,
+                                                  intelImage->base.ImageOffsets);
       texImage->RowStride = dstRowStride / intelImage->mt->cpp;
    }
    else {
@@ -537,17 +538,18 @@ intelTexImage(GLcontext * ctx,
                                                   format, type, pixels, unpack)) {
           _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage");
        }
-   }
 
-   /* GL_SGIS_generate_mipmap */
-   if (level == texObj->BaseLevel && texObj->GenerateMipmap) {
-      intel_generate_mipmap(ctx, target, texObj);
+       /* GL_SGIS_generate_mipmap */
+       if (level == texObj->BaseLevel && texObj->GenerateMipmap) {
+         intel_generate_mipmap(ctx, target, texObj);
+       }
    }
 
    _mesa_unmap_teximage_pbo(ctx, unpack);
 
    if (intelImage->mt) {
-      intel_miptree_image_unmap(intel, intelImage->mt);
+      if (pixels)
+         intel_miptree_image_unmap(intel, intelImage->mt);
       texImage->Data = NULL;
    }