{
struct brw_context *brw = brw_context(ctx);
struct gl_renderbuffer *rb = ctx->ReadBuffer->_ColorReadBuffer;
+ const struct gen_device_info *devinfo = &brw->screen->devinfo;
/* This path supports reading from color buffers only */
if (rb == NULL)
int dst_pitch;
/* The miptree's buffer. */
- drm_bacon_bo *bo;
-
- int error = 0;
+ struct brw_bo *bo;
uint32_t cpp;
mem_copy_fn mem_copy = NULL;
* a 2D BGRA, RGBA, L8 or A8 texture. It could be generalized to support
* more types.
*/
- if (!brw->has_llc ||
+ if (!devinfo->has_llc ||
!(type == GL_UNSIGNED_BYTE || type == GL_UNSIGNED_INT_8_8_8_8_REV) ||
pixels == NULL ||
_mesa_is_bufferobj(pack->BufferObj) ||
return false;
if (!irb->mt ||
- (irb->mt->tiling != I915_TILING_X &&
- irb->mt->tiling != I915_TILING_Y)) {
+ (irb->mt->surf.tiling != ISL_TILING_X &&
+ irb->mt->surf.tiling != ISL_TILING_Y0)) {
/* The algorithm is written only for X- or Y-tiled memory. */
return false;
}
+ /* tiled_to_linear() assumes that if the object is swizzled, it is using
+ * I915_BIT6_SWIZZLE_9_10 for X and I915_BIT6_SWIZZLE_9 for Y. This is only
+ * true on gen5 and above.
+ *
+ * The killer on top is that some gen4 have an L-shaped swizzle mode, where
+ * parts of the memory aren't swizzled at all. Userspace just can't handle
+ * that.
+ */
+ if (devinfo->gen < 5 && brw->has_swizzling)
+ return false;
+
/* Since we are going to read raw data to the miptree, we need to resolve
* any pending fast color clears before we start.
*/
- intel_miptree_all_slices_resolve_color(brw, irb->mt, 0);
+ intel_miptree_access_raw(brw, irb->mt, irb->mt_level, irb->mt_layer, false);
bo = irb->mt->bo;
intel_batchbuffer_flush(brw);
}
- error = brw_bo_map(brw, bo, false /* write enable */, "miptree");
- if (error) {
+ void *map = brw_bo_map(brw, bo, MAP_READ | MAP_RAW);
+ if (map == NULL) {
DBG("%s: failed to map bo\n", __func__);
return false;
}
- xoffset += irb->mt->level[irb->mt_level].slice[irb->mt_layer].x_offset;
- yoffset += irb->mt->level[irb->mt_level].slice[irb->mt_layer].y_offset;
+ unsigned slice_offset_x, slice_offset_y;
+ intel_miptree_get_image_offset(irb->mt, irb->mt_level, irb->mt_layer,
+ &slice_offset_x, &slice_offset_y);
+ xoffset += slice_offset_x;
+ yoffset += slice_offset_y;
dst_pitch = _mesa_image_row_stride(pack, width, format, type);
"mesa_format=0x%x tiling=%d "
"pack=(alignment=%d row_length=%d skip_pixels=%d skip_rows=%d)\n",
__func__, xoffset, yoffset, width, height,
- format, type, rb->Format, irb->mt->tiling,
+ format, type, rb->Format, irb->mt->surf.tiling,
pack->Alignment, pack->RowLength, pack->SkipPixels,
pack->SkipRows);
xoffset * cpp, (xoffset + width) * cpp,
yoffset, yoffset + height,
pixels - (ptrdiff_t) yoffset * dst_pitch - (ptrdiff_t) xoffset * cpp,
- bo->virtual + irb->mt->offset,
- dst_pitch, irb->mt->pitch,
+ map + irb->mt->offset,
+ dst_pitch, irb->mt->surf.row_pitch,
brw->has_swizzling,
- irb->mt->tiling,
+ irb->mt->surf.tiling,
mem_copy
);
- drm_bacon_bo_unmap(bo);
+ brw_bo_unmap(bo);
return true;
}