mesa: remove a bunch of gl_renderbuffer fields
[mesa.git] / src / mesa / drivers / dri / intel / intel_blit.c
index 2e95bd1013f6bc25b58379c06473d34fdb869690..0158bd309f74e91a26d2826cec50c4c4ae0c294a 100644 (file)
  **************************************************************************/
 
 
-#include <stdio.h>
-#include <errno.h>
-
 #include "main/mtypes.h"
 #include "main/context.h"
 #include "main/enums.h"
-#include "main/texformat.h"
 #include "main/colormac.h"
 
 #include "intel_blit.h"
@@ -477,6 +473,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;
@@ -497,7 +495,7 @@ intelClearWithBlit(GLcontext *ctx, GLbitfield mask)
                  CLAMPED_FLOAT_TO_UBYTE(clear[2], color[2]);
                  CLAMPED_FLOAT_TO_UBYTE(clear[3], color[3]);
 
-                 switch (irb->texformat->MesaFormat) {
+                 switch (irb->texformat) {
                  case MESA_FORMAT_ARGB8888:
                     clearVal = intel->ClearColor8888;
                     break;
@@ -514,7 +512,7 @@ intelClearWithBlit(GLcontext *ctx, GLbitfield mask)
                     break;
                  default:
                     _mesa_problem(ctx, "Unexpected renderbuffer format: %d\n",
-                                  irb->texformat->MesaFormat);
+                                  irb->texformat);
                     clearVal = 0;
                  }
               }
@@ -571,6 +569,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;
@@ -633,3 +632,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);
+   }
+}