intel: Remove unused stored values reported by clang.
[mesa.git] / src / mesa / drivers / dri / intel / intel_blit.c
index 979f2025842f5f2bd845db987d50dbed8c003cde..da9beba030d5597374821991cea18fd96da4b2eb 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"
@@ -56,7 +52,6 @@ intelCopyBuffer(const __DRIdrawablePrivate * dPriv,
 {
 
    struct intel_context *intel;
-   const intelScreenPrivate *intelScreen;
 
    DBG("%s\n", __FUNCTION__);
 
@@ -66,8 +61,6 @@ intelCopyBuffer(const __DRIdrawablePrivate * dPriv,
    if (!intel)
       return;
 
-   intelScreen = intel->intelScreen;
-
    /* The LOCK_HARDWARE is required for the cliprects.  Buffer offsets
     * should work regardless.
     */
@@ -374,8 +367,6 @@ intelClearWithBlit(GLcontext *ctx, GLbitfield mask)
       skipBuffers = BUFFER_BIT_STENCIL;
    }
 
-   /* XXX Move this flush/lock into the following conditional? */
-   intelFlush(&intel->ctx);
    LOCK_HARDWARE(intel);
 
    intel_get_cliprects(intel, &cliprects, &num_cliprects, &x_off, &y_off);
@@ -441,6 +432,10 @@ intelClearWithBlit(GLcontext *ctx, GLbitfield mask)
                   intel_region_buffer(intel, irb->region,
                                       all ? INTEL_WRITE_FULL :
                                       INTEL_WRITE_PART);
+              int x1 = b.x1 + irb->region->draw_x;
+              int y1 = b.y1 + irb->region->draw_y;
+              int x2 = b.x2 + irb->region->draw_x;
+              int y2 = b.y2 + irb->region->draw_y;
 
                GLuint clearVal;
                GLint pitch, cpp;
@@ -449,11 +444,10 @@ intelClearWithBlit(GLcontext *ctx, GLbitfield mask)
                pitch = irb->region->pitch;
                cpp = irb->region->cpp;
 
-               DBG("%s dst:buf(%p)/%d+%d %d,%d sz:%dx%d\n",
+               DBG("%s dst:buf(%p)/%d %d,%d sz:%dx%d\n",
                    __FUNCTION__,
                    irb->region->buffer, (pitch * cpp),
-                   irb->region->draw_offset,
-                   b.x1, b.y1, b.x2 - b.x1, b.y2 - b.y1);
+                   x1, y1, x2 - x1, y2 - y1);
 
               BR13 = 0xf0 << 16;
               CMD = XY_COLOR_BLT_CMD;
@@ -499,12 +493,14 @@ 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->Base.Format) {
                  case MESA_FORMAT_ARGB8888:
-                    clearVal = intel->ClearColor8888;
+                 case MESA_FORMAT_XRGB8888:
+                    clearVal = PACK_COLOR_8888(clear[3], clear[0],
+                                               clear[1], clear[2]);
                     break;
                  case MESA_FORMAT_RGB565:
-                    clearVal = intel->ClearColor565;
+                    clearVal = PACK_COLOR_565(clear[0], clear[1], clear[2]);
                     break;
                  case MESA_FORMAT_ARGB4444:
                     clearVal = PACK_COLOR_4444(clear[3], clear[0],
@@ -516,7 +512,7 @@ intelClearWithBlit(GLcontext *ctx, GLbitfield mask)
                     break;
                  default:
                     _mesa_problem(ctx, "Unexpected renderbuffer format: %d\n",
-                                  irb->texformat->MesaFormat);
+                                  irb->Base.Format);
                     clearVal = 0;
                  }
               }
@@ -526,17 +522,17 @@ intelClearWithBlit(GLcontext *ctx, GLbitfield mask)
                   buf, irb->Base.Name);
                 */
 
-               assert(b.x1 < b.x2);
-               assert(b.y1 < b.y2);
+               assert(x1 < x2);
+               assert(y1 < y2);
 
                BEGIN_BATCH(6, REFERENCES_CLIPRECTS);
                OUT_BATCH(CMD);
                OUT_BATCH(BR13);
-               OUT_BATCH((b.y1 << 16) | b.x1);
-               OUT_BATCH((b.y2 << 16) | b.x2);
+               OUT_BATCH((y1 << 16) | x1);
+               OUT_BATCH((y2 << 16) | x2);
                OUT_RELOC(write_buffer,
                         I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER,
-                         irb->region->draw_offset);
+                         0);
                OUT_BATCH(clearVal);
                ADVANCE_BATCH();
                clearMask &= ~bufBit;    /* turn off bit, for faster loop exit */
@@ -636,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);
+   }
+}