intel: Avoid trying to do blits to Y tiled regions.
authorEric Anholt <eric@anholt.net>
Mon, 22 Jun 2009 18:00:11 +0000 (11:00 -0700)
committerEric Anholt <eric@anholt.net>
Wed, 24 Jun 2009 02:31:11 +0000 (19:31 -0700)
This is somewhat nasty, but we need to do Y-tiled depth for FBO support.
May help with corruption and hangs since enabling texture tiling, and
since switching depth textures to Y tiled.

Fixes piglit depthtex.c on 965.

src/mesa/drivers/dri/intel/intel_blit.c
src/mesa/drivers/dri/intel/intel_blit.h
src/mesa/drivers/dri/intel/intel_mipmap_tree.c
src/mesa/drivers/dri/intel/intel_pixel_bitmap.c
src/mesa/drivers/dri/intel/intel_pixel_copy.c
src/mesa/drivers/dri/intel/intel_pixel_read.c
src/mesa/drivers/dri/intel/intel_regions.c
src/mesa/drivers/dri/intel/intel_regions.h
src/mesa/drivers/dri/intel/intel_tex_copy.c
src/mesa/drivers/dri/intel/intel_tex_image.c

index 698a0bf46526ad4d496d78f185bea643a23843a1..e0596a5531c7d47702f2dc8eef54cf9ef2072e8c 100644 (file)
@@ -108,6 +108,8 @@ intelCopyBuffer(const __DRIdrawablePrivate * dPriv,
         CMD = XY_SRC_COPY_BLT_CMD | XY_BLT_WRITE_ALPHA | XY_BLT_WRITE_RGB;
       }
 
+      assert(src->tiling != I915_TILING_Y);
+      assert(dst->tiling != I915_TILING_Y);
 #ifndef I915
       if (src->tiling != I915_TILING_NONE) {
         CMD |= XY_SRC_TILED;
@@ -201,7 +203,7 @@ static GLuint translate_raster_op(GLenum logicop)
 
 /* Copy BitBlt
  */
-void
+GLboolean
 intelEmitCopyBlit(struct intel_context *intel,
                  GLuint cpp,
                  GLshort src_pitch,
@@ -223,6 +225,11 @@ intelEmitCopyBlit(struct intel_context *intel,
    dri_bo *aper_array[3];
    BATCH_LOCALS;
 
+   if (dst_tiling == I915_TILING_Y)
+      return GL_FALSE;
+   if (src_tiling == I915_TILING_Y)
+      return GL_FALSE;
+
    /* do space/cliprects check before going any further */
    do {
        aper_array[0] = intel->batch->buf;
@@ -260,7 +267,7 @@ intelEmitCopyBlit(struct intel_context *intel,
        if (locked)
            UNLOCK_HARDWARE(intel);
 
-       return;
+       return GL_TRUE;
    }
 
    intel_batchbuffer_require_space(intel->batch, 8 * 4, NO_LOOP_CLIPRECTS);
@@ -287,7 +294,7 @@ intelEmitCopyBlit(struct intel_context *intel,
       CMD = XY_SRC_COPY_BLT_CMD | XY_BLT_WRITE_ALPHA | XY_BLT_WRITE_RGB;
       break;
    default:
-      return;
+      return GL_FALSE;
    }
 
 #ifndef I915
@@ -302,7 +309,7 @@ intelEmitCopyBlit(struct intel_context *intel,
 #endif
 
    if (dst_y2 <= dst_y || dst_x2 <= dst_x) {
-      return;
+      return GL_TRUE;
    }
 
    assert(dst_x < dst_x2);
@@ -324,6 +331,8 @@ intelEmitCopyBlit(struct intel_context *intel,
    ADVANCE_BATCH();
 
    intel_batchbuffer_emit_mi_flush(intel->batch);
+
+   return GL_TRUE;
 }
 
 
@@ -536,7 +545,7 @@ intelClearWithBlit(GLcontext *ctx, GLbitfield mask)
    UNLOCK_HARDWARE(intel);
 }
 
-void
+GLboolean
 intelEmitImmediateColorExpandBlit(struct intel_context *intel,
                                  GLuint cpp,
                                  GLubyte *src_bits, GLuint src_size,
@@ -552,11 +561,14 @@ intelEmitImmediateColorExpandBlit(struct intel_context *intel,
    int dwords = ALIGN(src_size, 8) / 4;
    uint32_t opcode, br13, blit_cmd;
 
+   if (dst_tiling == I915_TILING_Y)
+      return GL_FALSE;
+
    assert( logic_op - GL_CLEAR >= 0 );
    assert( logic_op - GL_CLEAR < 0x10 );
 
    if (w < 0 || h < 0)
-      return;
+      return GL_TRUE;
 
    dst_pitch *= cpp;
 
@@ -613,4 +625,6 @@ intelEmitImmediateColorExpandBlit(struct intel_context *intel,
                           REFERENCES_CLIPRECTS );
 
    intel_batchbuffer_emit_mi_flush(intel->batch);
+
+   return GL_TRUE;
 }
index 2b4267ef6a7df63406766910efe3b3095ec99063..152fa3f17bfd1875ff73749b4e1e0d08559fa5b0 100644 (file)
@@ -35,7 +35,8 @@ extern void intelCopyBuffer(const __DRIdrawablePrivate * dpriv,
 
 extern void intelClearWithBlit(GLcontext * ctx, GLbitfield mask);
 
-extern void intelEmitCopyBlit(struct intel_context *intel,
+GLboolean
+intelEmitCopyBlit(struct intel_context *intel,
                               GLuint cpp,
                               GLshort src_pitch,
                               dri_bo *src_buffer,
@@ -50,7 +51,7 @@ extern void intelEmitCopyBlit(struct intel_context *intel,
                               GLshort w, GLshort h,
                              GLenum logicop );
 
-void
+GLboolean
 intelEmitImmediateColorExpandBlit(struct intel_context *intel,
                                  GLuint cpp,
                                  GLubyte *src_bits, GLuint src_size,
index fadcc89b3e429cdabc7f2542200f897bdf219780..660d7e5350b0a26490be043f83313ace05e0547f 100644 (file)
@@ -498,6 +498,7 @@ intel_miptree_image_copy(struct intel_context *intel,
    const GLuint *dst_depth_offset = intel_miptree_depth_offsets(dst, level);
    const GLuint *src_depth_offset = intel_miptree_depth_offsets(src, level);
    GLuint i;
+   GLboolean success;
 
    if (dst->compressed) {
        GLuint alignment = intel_compressed_alignment(dst->internal_format);
@@ -506,12 +507,26 @@ intel_miptree_image_copy(struct intel_context *intel,
    }
 
    for (i = 0; i < depth; i++) {
-      intel_region_copy(intel,
-                        dst->region, dst_offset + dst_depth_offset[i],
-                        0,
-                        0,
-                        src->region, src_offset + src_depth_offset[i],
-                        0, 0, width, height, GL_COPY);
+      success = intel_region_copy(intel,
+                                 dst->region, dst_offset + dst_depth_offset[i],
+                                 0, 0,
+                                 src->region, src_offset + src_depth_offset[i],
+                                 0, 0, width, height, GL_COPY);
+      if (!success) {
+        GLubyte *src_ptr, *dst_ptr;
+
+        src_ptr = intel_region_map(intel, src->region);
+        dst_ptr = intel_region_map(intel, dst->region);
+
+        _mesa_copy_rect(dst_ptr + dst_offset + dst_depth_offset[i],
+                        dst->cpp,
+                        dst->pitch,
+                        0, 0, width, height,
+                        src_ptr + src_offset + src_depth_offset[i],
+                        src->pitch,
+                        0, 0);
+        intel_region_unmap(intel, src->region);
+        intel_region_unmap(intel, dst->region);
+      }
    }
-
 }
index 191d9b08463e604b362924c22a279cdb70c40d12..e678cd2c26f489f9bceb4a52a3c57c8ecb6e8f6d 100644 (file)
@@ -194,7 +194,7 @@ do_blit_bitmap( GLcontext *ctx,
    struct gl_framebuffer *fb = ctx->DrawBuffer;
    GLfloat tmpColor[4];
    GLubyte ubcolor[4];
-   GLuint color8888, color565;
+   GLuint color;
    unsigned int num_cliprects;
    drm_clip_rect_t *cliprects;
    int x_off, y_off;
@@ -232,8 +232,11 @@ do_blit_bitmap( GLcontext *ctx,
    UNCLAMPED_FLOAT_TO_UBYTE(ubcolor[2], tmpColor[2]);
    UNCLAMPED_FLOAT_TO_UBYTE(ubcolor[3], tmpColor[3]);
 
-   color8888 = INTEL_PACKCOLOR8888(ubcolor[0], ubcolor[1], ubcolor[2], ubcolor[3]);
-   color565 = INTEL_PACKCOLOR565(ubcolor[0], ubcolor[1], ubcolor[2]);
+   if (dst->cpp == 2)
+      color = INTEL_PACKCOLOR565(ubcolor[0], ubcolor[1], ubcolor[2]);
+   else
+      color = INTEL_PACKCOLOR8888(ubcolor[0], ubcolor[1],
+                                 ubcolor[2], ubcolor[3]);
 
    if (!intel_check_blit_fragment_ops(ctx, tmpColor[3] == 1.0F))
       return GL_FALSE;
@@ -307,21 +310,21 @@ do_blit_bitmap( GLcontext *ctx,
                                   fb->Name == 0 ? GL_TRUE : GL_FALSE) == 0)
                  continue;
 
-              /* 
-               */
-              intelEmitImmediateColorExpandBlit( intel,
-                                                 dst->cpp,
-                                                 (GLubyte *)stipple, 
-                                                 sz,
-                                                 (dst->cpp == 2) ? color565 : color8888,
-                                                 dst->pitch,
-                                                 dst->buffer,
-                                                 0,
-                                                 dst->tiling,
-                                                 box_x + px,
-                                                 box_y + py,
-                                                 w, h,
-                                                 logic_op);
+              if (!intelEmitImmediateColorExpandBlit(intel,
+                                                     dst->cpp,
+                                                     (GLubyte *)stipple,
+                                                     sz,
+                                                     color,
+                                                     dst->pitch,
+                                                     dst->buffer,
+                                                     0,
+                                                     dst->tiling,
+                                                     box_x + px,
+                                                     box_y + py,
+                                                     w, h,
+                                                     logic_op)) {
+                 return GL_FALSE;
+              }
            } 
         } 
       }
index 1a3e3638469073103c8f8cab4df3d1bd05933505..f523d3eead92607ea288fa20cf6d2b16841a7e6b 100644 (file)
@@ -362,12 +362,16 @@ do_blit_copypixels(GLcontext * ctx,
                                   &clip_x, &clip_y, &clip_w, &clip_h))
             continue;
 
-        intel_region_copy(intel,
-                          dst, 0, clip_x, clip_y,
-                          src, 0, clip_x + delta_x, clip_y + delta_y,
-                          clip_w, clip_h,
-                          ctx->Color.ColorLogicOpEnabled ?
-                          ctx->Color.LogicOp : GL_COPY);
+        if (!intel_region_copy(intel,
+                               dst, 0, clip_x, clip_y,
+                               src, 0, clip_x + delta_x, clip_y + delta_y,
+                               clip_w, clip_h,
+                               ctx->Color.ColorLogicOpEnabled ?
+                               ctx->Color.LogicOp : GL_COPY)) {
+           DBG("%s: blit failure\n", __FUNCTION__);
+           UNLOCK_HARDWARE(intel);
+           return GL_FALSE;
+        }
       }
    }
 out:
index 74da6d39a2fa6d3e2cf120ea6c470898e5e047ce..8713463ace27b899d8e07753be90cf48c6145857 100644 (file)
@@ -261,16 +261,19 @@ do_blit_readpixels(GLcontext * ctx,
          if (!intel_intersect_cliprects(&rect, &src_rect, &box[i]))
             continue;
 
-         intelEmitCopyBlit(intel,
-                           src->cpp,
-                           src->pitch, src->buffer, 0, src->tiling,
-                           rowLength, dst_buffer, dst_offset, GL_FALSE,
-                           rect.x1,
-                           rect.y1,
-                           rect.x1 - src_rect.x1,
-                           rect.y2 - src_rect.y2,
-                           rect.x2 - rect.x1, rect.y2 - rect.y1,
-                          GL_COPY);
+         if (!intelEmitCopyBlit(intel,
+                               src->cpp,
+                               src->pitch, src->buffer, 0, src->tiling,
+                               rowLength, dst_buffer, dst_offset, GL_FALSE,
+                               rect.x1,
+                               rect.y1,
+                               rect.x1 - src_rect.x1,
+                               rect.y2 - src_rect.y2,
+                               rect.x2 - rect.x1, rect.y2 - rect.y1,
+                               GL_COPY)) {
+           UNLOCK_HARDWARE(intel);
+           return GL_FALSE;
+        }
       }
    }
    UNLOCK_HARDWARE(intel);
index 98109235b74c9b15550944dc2baa245bddb7c17a..4ce7f12e40df858eaab89710af45b28e65e9f02b 100644 (file)
@@ -360,7 +360,7 @@ intel_region_data(struct intel_context *intel,
 /* Copy rectangular sub-regions. Need better logic about when to
  * push buffers into AGP - will currently do so whenever possible.
  */
-void
+GLboolean
 intel_region_copy(struct intel_context *intel,
                   struct intel_region *dst,
                   GLuint dst_offset,
@@ -373,7 +373,7 @@ intel_region_copy(struct intel_context *intel,
    _DBG("%s\n", __FUNCTION__);
 
    if (intel == NULL)
-      return;
+      return GL_FALSE;
 
    if (dst->pbo) {
       if (dstx == 0 &&
@@ -385,12 +385,12 @@ intel_region_copy(struct intel_context *intel,
 
    assert(src->cpp == dst->cpp);
 
-   intelEmitCopyBlit(intel,
-                     dst->cpp,
-                     src->pitch, src->buffer, src_offset, src->tiling,
-                     dst->pitch, dst->buffer, dst_offset, dst->tiling,
-                     srcx, srcy, dstx, dsty, width, height,
-                    logicop);
+   return intelEmitCopyBlit(intel,
+                           dst->cpp,
+                           src->pitch, src->buffer, src_offset, src->tiling,
+                           dst->pitch, dst->buffer, dst_offset, dst->tiling,
+                           srcx, srcy, dstx, dsty, width, height,
+                           logicop);
 }
 
 /* Attach to a pbo, discarding our data.  Effectively zero-copy upload
@@ -477,13 +477,13 @@ intel_region_cow(struct intel_context *intel, struct intel_region *region)
    if (!was_locked)
       LOCK_HARDWARE(intel);
 
-   intelEmitCopyBlit(intel,
-                    region->cpp,
-                    region->pitch, pbo->buffer, 0, region->tiling,
-                    region->pitch, region->buffer, 0, region->tiling,
-                    0, 0, 0, 0,
-                    region->pitch, region->height,
-                    GL_COPY);
+   assert(intelEmitCopyBlit(intel,
+                           region->cpp,
+                           region->pitch, pbo->buffer, 0, region->tiling,
+                           region->pitch, region->buffer, 0, region->tiling,
+                           0, 0, 0, 0,
+                           region->pitch, region->height,
+                           GL_COPY));
 
    if (!was_locked)
       UNLOCK_HARDWARE(intel);
index c2d4810df2cf620ef68236d69694509073650e7f..0d379bdc6e273c2483c3cb279fb668fbcefbfe6d 100644 (file)
@@ -110,14 +110,15 @@ void intel_region_data(struct intel_context *intel,
 
 /* Copy rectangular sub-regions
  */
-void intel_region_copy(struct intel_context *intel,
-                       struct intel_region *dest,
-                       GLuint dest_offset,
-                       GLuint destx, GLuint desty,
-                       struct intel_region *src,
-                       GLuint src_offset,
-                       GLuint srcx, GLuint srcy, GLuint width, GLuint height,
-                      GLenum logicop);
+GLboolean
+intel_region_copy(struct intel_context *intel,
+                 struct intel_region *dest,
+                 GLuint dest_offset,
+                 GLuint destx, GLuint desty,
+                 struct intel_region *src,
+                 GLuint src_offset,
+                 GLuint srcx, GLuint srcy, GLuint width, GLuint height,
+                 GLenum logicop);
 
 /* Helpers for zerocopy uploads, particularly texture image uploads:
  */
index e1820e3fcf590b6794c4c2d5163aa10defd1e1b3..0335c13307167db0ffa80da26b6d6555df2cc639 100644 (file)
@@ -147,18 +147,21 @@ do_copy_texsubimage(struct intel_context *intel,
         src_pitch = src->pitch;
       }
 
-      intelEmitCopyBlit(intel,
-                       intelImage->mt->cpp,
-                       src_pitch,
-                       src->buffer,
-                       0,
-                       src->tiling,
-                       intelImage->mt->pitch,
-                       dst_bo,
-                       image_offset,
-                       intelImage->mt->region->tiling,
-                       x, y, dstx, dsty, width, height,
-                       GL_COPY);
+      if (!intelEmitCopyBlit(intel,
+                            intelImage->mt->cpp,
+                            src_pitch,
+                            src->buffer,
+                            0,
+                            src->tiling,
+                            intelImage->mt->pitch,
+                            dst_bo,
+                            image_offset,
+                            intelImage->mt->region->tiling,
+                            x, y, dstx, dsty, width, height,
+                            GL_COPY)) {
+        UNLOCK_HARDWARE(intel);
+        return GL_FALSE;
+      }
    }
 
    UNLOCK_HARDWARE(intel);
index 03311e58aab484d0e6722bc50a1d7d657ba089a2..ab9541359d29070a673b52f10617af1aa401fa4a 100644 (file)
@@ -235,12 +235,15 @@ try_pbo_upload(struct intel_context *intel,
                                               INTEL_WRITE_FULL);
 
 
-      intelEmitCopyBlit(intel,
-                        intelImage->mt->cpp,
-                        src_stride, src_buffer, src_offset, GL_FALSE,
-                        dst_stride, dst_buffer, dst_offset, GL_FALSE,
-                        0, 0, 0, 0, width, height,
-                       GL_COPY);
+      if (!intelEmitCopyBlit(intel,
+                            intelImage->mt->cpp,
+                            src_stride, src_buffer, src_offset, GL_FALSE,
+                            dst_stride, dst_buffer, dst_offset, GL_FALSE,
+                            0, 0, 0, 0, width, height,
+                            GL_COPY)) {
+        UNLOCK_HARDWARE(intel);
+        return GL_FALSE;
+      }
    }
    UNLOCK_HARDWARE(intel);