Mesa (mesa_7_7_branch): intel: Fix PBO blit ReadPixels from an FBO.

Eric Anholt anholt at kemper.freedesktop.org
Sat Feb 6 16:46:49 UTC 2010


Module: Mesa
Branch: mesa_7_7_branch
Commit: 0b9990b2fdc42e3ee582f5e03ef640f296a63087
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=0b9990b2fdc42e3ee582f5e03ef640f296a63087

Author: Eric Anholt <eric at anholt.net>
Date:   Sat Feb  6 17:16:18 2010 +0100

intel: Fix PBO blit ReadPixels from an FBO.

Bug #25921 -- clutter PBO usage gave unreliable results.
(cherry picked from commit 63b10e8fe71c1de5b0ee9aac72fd7303551f59a0)

Conflicts:

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

---

 src/mesa/drivers/dri/intel/intel_pixel_read.c |   81 +++++++++++--------------
 1 files changed, 36 insertions(+), 45 deletions(-)

diff --git a/src/mesa/drivers/dri/intel/intel_pixel_read.c b/src/mesa/drivers/dri/intel/intel_pixel_read.c
index 01a0570..8e3db4d 100644
--- a/src/mesa/drivers/dri/intel/intel_pixel_read.c
+++ b/src/mesa/drivers/dri/intel/intel_pixel_read.c
@@ -172,6 +172,8 @@ do_blit_readpixels(GLcontext * ctx,
    struct intel_buffer_object *dst = intel_buffer_object(pack->BufferObj);
    GLuint dst_offset;
    GLuint rowLength;
+   drm_intel_bo *dst_buffer;
+   drm_clip_rect_t read_bounds, rect, src_rect;
 
    if (INTEL_DEBUG & DEBUG_PIXEL)
       _mesa_printf("%s\n", __FUNCTION__);
@@ -212,58 +214,47 @@ do_blit_readpixels(GLcontext * ctx,
       return GL_FALSE;
    }
    else {
-      rowLength = -rowLength;
+      if (ctx->ReadBuffer->Name == 0)
+	 rowLength = -rowLength;
    }
 
    dst_offset = (GLintptr) _mesa_image_address(2, pack, pixels, width, height,
 					       format, type, 0, 0, 0);
 
+   GLboolean all = (width * height * src->cpp == dst->Base.Size &&
+		    x == 0 && dst_offset == 0);
 
-   /* Although the blits go on the command buffer, need to do this and
-    * fire with lock held to guarentee cliprects are correct.
-    */
-   intelFlush(&intel->ctx);
-   LOCK_HARDWARE(intel);
+   dst_buffer = intel_bufferobj_buffer(intel, dst,
+					       all ? INTEL_WRITE_FULL :
+					       INTEL_WRITE_PART);
 
-   if (intel->driReadDrawable->numClipRects) {
-      GLboolean all = (width * height * src->cpp == dst->Base.Size &&
-                       x == 0 && dst_offset == 0);
-
-      dri_bo *dst_buffer = intel_bufferobj_buffer(intel, dst,
-						  all ? INTEL_WRITE_FULL :
-						  INTEL_WRITE_PART);
-      __DRIdrawablePrivate *dPriv = intel->driReadDrawable;
-      int nbox = dPriv->numClipRects;
-      drm_clip_rect_t *box = dPriv->pClipRects;
-      drm_clip_rect_t rect;
-      drm_clip_rect_t src_rect;
-      int i;
-
-      src_rect.x1 = dPriv->x + x;
-      src_rect.y1 = dPriv->y + dPriv->h - (y + height);
-      src_rect.x2 = src_rect.x1 + width;
-      src_rect.y2 = src_rect.y1 + height;
-
-
-
-      for (i = 0; i < nbox; i++) {
-         if (!intel_intersect_cliprects(&rect, &src_rect, &box[i]))
-            continue;
-
-         if (!intelEmitCopyBlit(intel,
-				src->cpp,
-				src->pitch, src->buffer, 0, src->tiling,
-				rowLength, dst_buffer, dst_offset, GL_FALSE,
-				rect.x1,
-				rect.y1,
-				rect.x1 - src_rect.x1,
-				rect.y2 - src_rect.y2,
-				rect.x2 - rect.x1, rect.y2 - rect.y1,
-				GL_COPY)) {
-	    UNLOCK_HARDWARE(intel);
-	    return GL_FALSE;
-	 }
-      }
+   src_rect.x1 = x;
+   if (ctx->ReadBuffer->Name == 0)
+      src_rect.y1 = ctx->ReadBuffer->Height - (y + height);
+   else
+      src_rect.y1 = y;
+   src_rect.x2 = src_rect.x1 + width;
+   src_rect.y2 = src_rect.y1 + height;
+
+   read_bounds.x1 = 0;
+   read_bounds.y1 = 0;
+   read_bounds.x2 = ctx->ReadBuffer->Width;
+   read_bounds.y2 = ctx->ReadBuffer->Height;
+
+   if (!intel_intersect_cliprects(&rect, &src_rect, &read_bounds))
+      return GL_TRUE;
+
+   if (!intelEmitCopyBlit(intel,
+			  src->cpp,
+			  src->pitch, src->buffer, 0, src->tiling,
+			  rowLength, dst_buffer, dst_offset, GL_FALSE,
+			  rect.x1,
+			  rect.y1,
+			  rect.x1 - src_rect.x1,
+			  rect.y2 - src_rect.y2,
+			  rect.x2 - rect.x1, rect.y2 - rect.y1,
+			  GL_COPY)) {
+      return GL_FALSE;
    }
    UNLOCK_HARDWARE(intel);
 




More information about the mesa-commit mailing list