Merge branch 'mesa_7_6_branch'
[mesa.git] / src / mesa / drivers / dri / intel / intel_blit.c
index 75d315d82bdcc85157b183952c5e1cd4bdce4c8c..43141c509c7c1c2522f5bde12c85418bfe568661 100644 (file)
@@ -26,9 +26,6 @@
  **************************************************************************/
 
 
-#include <stdio.h>
-#include <errno.h>
-
 #include "main/mtypes.h"
 #include "main/context.h"
 #include "main/enums.h"
@@ -252,12 +249,7 @@ intelEmitCopyBlit(struct intel_context *intel,
    } while (pass < 2);
 
    if (pass >= 2) {
-       GLboolean locked = GL_FALSE;       
-       if (!intel->locked) {
-           LOCK_HARDWARE(intel);
-           locked = GL_TRUE;
-       }
-
+       LOCK_HARDWARE(intel);
        dri_bo_map(dst_buffer, GL_TRUE);
        dri_bo_map(src_buffer, GL_FALSE);
        _mesa_copy_rect((GLubyte *)dst_buffer->virtual + dst_offset,
@@ -271,9 +263,7 @@ intelEmitCopyBlit(struct intel_context *intel,
        
        dri_bo_unmap(src_buffer);
        dri_bo_unmap(dst_buffer);
-       
-       if (locked)
-           UNLOCK_HARDWARE(intel);
+       UNLOCK_HARDWARE(intel);
 
        return GL_TRUE;
    }
@@ -484,6 +474,8 @@ intelClearWithBlit(GLcontext *ctx, GLbitfield mask)
                   BR13 |= BR13_565;
                }
 
+              assert(irb->region->tiling != I915_TILING_Y);
+
 #ifndef I915
               if (irb->region->tiling != I915_TILING_NONE) {
                  CMD |= XY_DST_TILED;
@@ -578,6 +570,7 @@ intelEmitImmediateColorExpandBlit(struct intel_context *intel,
 
    assert( logic_op - GL_CLEAR >= 0 );
    assert( logic_op - GL_CLEAR < 0x10 );
+   assert(dst_pitch > 0);
 
    if (w < 0 || h < 0)
       return GL_TRUE;
@@ -640,3 +633,43 @@ intelEmitImmediateColorExpandBlit(struct intel_context *intel,
 
    return GL_TRUE;
 }
+
+/* We don't have a memmove-type blit like some other hardware, so we'll do a
+ * rectangular blit covering a large space, then emit 1-scanline blit at the
+ * end to cover the last if we need.
+ */
+void
+intel_emit_linear_blit(struct intel_context *intel,
+                      drm_intel_bo *dst_bo,
+                      unsigned int dst_offset,
+                      drm_intel_bo *src_bo,
+                      unsigned int src_offset,
+                      unsigned int size)
+{
+   GLuint pitch, height;
+
+   /* The pitch is a signed value. */
+   pitch = MIN2(size, (1 << 15) - 1);
+   height = size / pitch;
+   intelEmitCopyBlit(intel, 1,
+                    pitch, src_bo, src_offset, I915_TILING_NONE,
+                    pitch, dst_bo, dst_offset, I915_TILING_NONE,
+                    0, 0, /* src x/y */
+                    0, 0, /* dst x/y */
+                    pitch, height, /* w, h */
+                    GL_COPY);
+
+   src_offset += pitch * height;
+   dst_offset += pitch * height;
+   size -= pitch * height;
+   assert (size < (1 << 15));
+   if (size != 0) {
+      intelEmitCopyBlit(intel, 1,
+                       size, src_bo, src_offset, I915_TILING_NONE,
+                       size, dst_bo, dst_offset, I915_TILING_NONE,
+                       0, 0, /* src x/y */
+                       0, 0, /* dst x/y */
+                       size, 1, /* w, h */
+                       GL_COPY);
+   }
+}