Merge remote branch 'origin/7.8'
[mesa.git] / src / mesa / drivers / dri / intel / intel_tex_copy.c
index d8e71093c47b06441f79d1de3eb1e38f2ec8c0e6..62e1e78f59be035ca2e3d9649a7e17f2aa4de8bc 100644 (file)
@@ -36,7 +36,6 @@
 
 #include "intel_screen.h"
 #include "intel_context.h"
-#include "intel_batchbuffer.h"
 #include "intel_buffers.h"
 #include "intel_mipmap_tree.h"
 #include "intel_regions.h"
@@ -110,12 +109,11 @@ do_copy_texsubimage(struct intel_context *intel,
    }
 
    /* intelFlush(ctx); */
+   intel_prepare_render(intel);
    {
       drm_intel_bo *dst_bo = intel_region_buffer(intel,
                                                 intelImage->mt->region,
                                                 INTEL_WRITE_PART);
-      const GLint orig_x = x;
-      const GLint orig_y = y;
       GLuint image_x, image_y;
       GLshort src_pitch;
 
@@ -125,9 +123,6 @@ do_copy_texsubimage(struct intel_context *intel,
                                     intelImage->face,
                                     0,
                                     &image_x, &image_y);
-      /* Update dst for clipped src.  Need to also clip the source rect. */
-      dstx += x - orig_x;
-      dsty += y - orig_y;
 
       /* Can't blit to tiled buffers with non-tile-aligned offset. */
       if (intelImage->mt->region->tiling == I915_TILING_Y) {
@@ -135,18 +130,8 @@ do_copy_texsubimage(struct intel_context *intel,
       }
 
       if (ctx->ReadBuffer->Name == 0) {
-        /* reading from a window, adjust x, y */
-        const __DRIdrawable *dPriv = intel->driReadDrawable;
-        y = dPriv->y + (dPriv->h - (y + height));
-        x += dPriv->x;
-
-        /* Invert the data coming from the source rectangle due to GL
-         * and hardware disagreeing on where y=0 is.
-         *
-         * It appears that our offsets and pitches get mangled
-         * appropriately by the hardware, and we don't need to adjust them
-         * on our own.
-         */
+        /* Flip vertical orientation for system framebuffers */
+        y = ctx->ReadBuffer->Height - (y + height);
         src_pitch = -src->pitch;
       } else {
         /* reading from a FBO, y is already oriented the way we like */
@@ -160,7 +145,7 @@ do_copy_texsubimage(struct intel_context *intel,
                             src->buffer,
                             0,
                             src->tiling,
-                            intelImage->mt->pitch,
+                            intelImage->mt->region->pitch,
                             dst_bo,
                             0,
                             intelImage->mt->region->tiling,