Mesa (master): intel: Kill dead code in intel_miptree_copy_teximage()

Chad Versace chadversary at kemper.freedesktop.org
Tue Oct 25 11:28:49 PDT 2011


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

Author: Chad Versace <chad at chad-versace.us>
Date:   Mon Oct 24 13:55:43 2011 -0700

intel: Kill dead code in intel_miptree_copy_teximage()

Kill the code paths taken when src_mt is null. It is never null, otherwise
there would be a segfault on line 4 of this function:
    GLuint width = src_mt->level[level].width;

(Some interleaved lines in the diff make the real diff non-obvious. All
I did was delete some code and then left-shifted what remained to correct
the indentation.)

Reviewed-by: Eric Anholt <eric at aholt.net>
Signed-off-by: Chad Versace <chad at chad-versace.us>

---

 src/mesa/drivers/dri/intel/intel_mipmap_tree.c |   87 ++++++++----------------
 1 files changed, 28 insertions(+), 59 deletions(-)

diff --git a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
index 9eb81de..54f73e8 100644
--- a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
+++ b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
@@ -371,75 +371,44 @@ intel_miptree_copy_teximage(struct intel_context *intel,
       intel_miptree_get_image_offset(dst_mt, level, face, slice,
 				     &dst_x, &dst_y);
 
-      if (src_mt) {
-	 /* Copy potentially with the blitter:
-	  */
-	 intel_miptree_get_image_offset(src_mt, level, face, slice,
-					&src_x, &src_y);
-
-	 DBG("validate blit mt %p %d,%d/%d -> mt %p %d,%d/%d (%dx%d)\n",
-	     src_mt, src_x, src_y, src_mt->region->pitch * src_mt->region->cpp,
-	     dst_mt, dst_x, dst_y, dst_mt->region->pitch * dst_mt->region->cpp,
-	     width, height);
-
-	 if (!intelEmitCopyBlit(intel,
-				dst_mt->region->cpp,
-				src_mt->region->pitch, src_mt->region->bo,
-				0, src_mt->region->tiling,
-				dst_mt->region->pitch, dst_mt->region->bo,
-				0, dst_mt->region->tiling,
-				src_x, src_y,
-				dst_x, dst_y,
-				width, height,
-				GL_COPY)) {
-
-	    fallback_debug("miptree validate blit for %s failed\n",
-			   _mesa_get_format_name(intelImage->base.Base.TexFormat));
-	    dst = intel_region_map(intel, dst_mt->region, GL_MAP_WRITE_BIT);
-	    src = intel_region_map(intel, src_mt->region, GL_MAP_READ_BIT);
-
-	    _mesa_copy_rect(dst,
-			    dst_mt->cpp,
-			    dst_mt->region->pitch,
-			    dst_x, dst_y,
-			    width, height,
-			    src, src_mt->region->pitch,
-			    src_x, src_y);
-
-	    intel_region_unmap(intel, dst_mt->region);
-	    intel_region_unmap(intel, src_mt->region);
-	 }
-      } else {
+      /* Copy potentially with the blitter:
+       */
+      intel_miptree_get_image_offset(src_mt, level, face, slice,
+				     &src_x, &src_y);
+
+      DBG("validate blit mt %p %d,%d/%d -> mt %p %d,%d/%d (%dx%d)\n",
+	  src_mt, src_x, src_y, src_mt->region->pitch * src_mt->region->cpp,
+	  dst_mt, dst_x, dst_y, dst_mt->region->pitch * dst_mt->region->cpp,
+	  width, height);
+
+      if (!intelEmitCopyBlit(intel,
+			     dst_mt->region->cpp,
+			     src_mt->region->pitch, src_mt->region->bo,
+			     0, src_mt->region->tiling,
+			     dst_mt->region->pitch, dst_mt->region->bo,
+			     0, dst_mt->region->tiling,
+			     src_x, src_y,
+			     dst_x, dst_y,
+			     width, height,
+			     GL_COPY)) {
+
+	 fallback_debug("miptree validate blit for %s failed\n",
+			_mesa_get_format_name(intelImage->base.Base.TexFormat));
 	 dst = intel_region_map(intel, dst_mt->region, GL_MAP_WRITE_BIT);
-
-	 DBG("validate upload mt %p -> mt %p %d,%d/%d (%dx%d)\n",
-	     src,
-	     dst_mt, dst_x, dst_y, dst_mt->region->pitch * dst_mt->region->cpp,
-	     width, height);
-
-	 src = intelImage->base.Data;
-	 src += (intelImage->base.RowStride *
-		 intelImage->base.Base.Height *
-		 dst_mt->region->cpp *
-		 slice);
+	 src = intel_region_map(intel, src_mt->region, GL_MAP_READ_BIT);
 
 	 _mesa_copy_rect(dst,
-			 dst_mt->region->cpp,
+			 dst_mt->cpp,
 			 dst_mt->region->pitch,
 			 dst_x, dst_y,
 			 width, height,
-			 src,
-			 intelImage->base.RowStride,
-			 0, 0);
+			 src, src_mt->region->pitch,
+			 src_x, src_y);
 
 	 intel_region_unmap(intel, dst_mt->region);
+	 intel_region_unmap(intel, src_mt->region);
       }
    }
 
-   if (!src_mt && intelImage->base.Data) {
-      _mesa_align_free(intelImage->base.Data);
-      intelImage->base.Data = NULL;
-   }
-
    intel_miptree_reference(&intelImage->mt, dst_mt);
 }



More information about the mesa-commit mailing list