i965: Fix inversion for glCopyPixels to/from FBOs.
authorEric Anholt <eric@anholt.net>
Tue, 16 Mar 2010 20:14:38 +0000 (13:14 -0700)
committerEric Anholt <eric@anholt.net>
Tue, 16 Mar 2010 20:18:54 +0000 (13:18 -0700)
fixes piglit fbo-copypix.

src/mesa/drivers/dri/intel/intel_mipmap_tree.c
src/mesa/drivers/dri/intel/intel_pixel_copy.c
src/mesa/drivers/dri/intel/intel_regions.c
src/mesa/drivers/dri/intel/intel_regions.h

index 4f14946ec729df39af59a76be4776ac0fb4288b1..da17809f16cd64d676d4e540170541d03d8bb0df 100644 (file)
@@ -525,7 +525,8 @@ intel_miptree_image_copy(struct intel_context *intel,
       intel_miptree_get_image_offset(dst, level, face, i, &dst_x, &dst_y);
       success = intel_region_copy(intel,
                                  dst->region, 0, dst_x, dst_y,
-                                 src->region, 0, src_x, src_y, width, height,
+                                 src->region, 0, src_x, src_y,
+                                 width, height, GL_FALSE,
                                  GL_COPY);
       if (!success) {
         GLubyte *src_ptr, *dst_ptr;
index f4f3fd6d889e9008dc0ede03f8d57c3342246c4b..8efb7a60c265224b8eec267d5906bacd91561b29 100644 (file)
@@ -116,6 +116,7 @@ do_blit_copypixels(GLcontext * ctx,
    GLint orig_dsty;
    GLint orig_srcx;
    GLint orig_srcy;
+   GLboolean flip = GL_FALSE;
 
    if (type == GL_DEPTH || type == GL_STENCIL) {
       if (INTEL_DEBUG & DEBUG_FALLBACKS)
@@ -140,8 +141,6 @@ do_blit_copypixels(GLcontext * ctx,
 
    intel_prepare_render(intel);
 
-   /* XXX: We fail to handle different inversion between read and draw framebuffer. */
-
    /* Clip to destination buffer. */
    orig_dstx = dstx;
    orig_dsty = dsty;
@@ -164,23 +163,23 @@ do_blit_copypixels(GLcontext * ctx,
    dstx += srcx - orig_srcx;
    dsty += srcy - orig_srcy;
 
-   /* Convert from GL to hardware coordinates: */
+   /* Flip dest Y if it's a window system framebuffer. */
    if (fb->Name == 0) {
-      /* copypixels to a system framebuffer */
+      /* copypixels to a window system framebuffer */
       dsty = fb->Height - dsty - height;
-   } else {
-      /* copypixels to a user framebuffer object */
-      dsty = dsty;
+      flip = !flip;
    }
 
-   /* Flip source Y if it's a system framebuffer. */
-   if (read_fb->Name == 0)
-      srcy = fb->Height - srcy - height;
+   /* Flip source Y if it's a window system framebuffer. */
+   if (read_fb->Name == 0) {
+      srcy = read_fb->Height - srcy - height;
+      flip = !flip;
+   }
 
    if (!intel_region_copy(intel,
                          dst, 0, dstx, dsty,
                          src, 0, srcx, srcy,
-                         width, height,
+                         width, height, flip,
                          ctx->Color.ColorLogicOpEnabled ?
                          ctx->Color.LogicOp : GL_COPY)) {
       DBG("%s: blit failure\n", __FUNCTION__);
index f042bcbc28ce38c5a47ebdd4f53b6747f03b40cb..f8107bd06152c60acc07ed2efd98134cd07d1cb1 100644 (file)
@@ -380,8 +380,11 @@ intel_region_copy(struct intel_context *intel,
                   struct intel_region *src,
                   GLuint src_offset,
                   GLuint srcx, GLuint srcy, GLuint width, GLuint height,
+                 GLboolean flip,
                  GLenum logicop)
 {
+   uint32_t src_pitch = src->pitch;
+
    _DBG("%s\n", __FUNCTION__);
 
    if (intel == NULL)
@@ -397,9 +400,12 @@ intel_region_copy(struct intel_context *intel,
 
    assert(src->cpp == dst->cpp);
 
+   if (flip)
+      src_pitch = -src_pitch;
+
    return intelEmitCopyBlit(intel,
                            dst->cpp,
-                           src->pitch, src->buffer, src_offset, src->tiling,
+                           src_pitch, src->buffer, src_offset, src->tiling,
                            dst->pitch, dst->buffer, dst_offset, dst->tiling,
                            srcx, srcy, dstx, dsty, width, height,
                            logicop);
index 7ee6a988eae3d9c518648c12628bdd801deaf87c..8f32449f345f79e34ee627150bb58e47ce455c1d 100644 (file)
@@ -122,6 +122,7 @@ intel_region_copy(struct intel_context *intel,
                  struct intel_region *src,
                  GLuint src_offset,
                  GLuint srcx, GLuint srcy, GLuint width, GLuint height,
+                 GLboolean flip,
                  GLenum logicop);
 
 /* Helpers for zerocopy uploads, particularly texture image uploads: