From dcd52d0c186e8b17569335338232298fbbea2b2d Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Thu, 7 Mar 2013 23:03:52 +0000 Subject: sna: Fallback if we cannot fit the tiling copy into the aperture If we cannot fit the source/destination and a tile into the aperture, then we cannot perform the copy and must do it using the CPU. Signed-off-by: Chris Wilson --- src/sna/sna_tiling.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'src/sna/sna_tiling.c') diff --git a/src/sna/sna_tiling.c b/src/sna/sna_tiling.c index 5bebf002..019b50a5 100644 --- a/src/sna/sna_tiling.c +++ b/src/sna/sna_tiling.c @@ -690,7 +690,7 @@ bool sna_tiling_blt_copy_boxes(struct sna *sna, uint8_t alu, { RegionRec region, tile, this; struct kgem_bo *bo; - int step; + int max_size, step; bool ret = false; if (!kgem_bo_can_blt(&sna->kgem, src_bo) || @@ -703,14 +703,27 @@ bool sna_tiling_blt_copy_boxes(struct sna *sna, uint8_t alu, return false; } + max_size = sna->kgem.aperture_high * PAGE_SIZE; + max_size -= MAX(kgem_bo_size(src_bo), kgem_bo_size(dst_bo)); + if (max_size <= 0) { + DBG(("%s: tiles cannot fit into aperture\n", __FUNCTION__)); + return false; + } + if (max_size > sna->kgem.max_copy_tile_size) + max_size = sna->kgem.max_copy_tile_size; + pixman_region_init_rects(®ion, box, nbox); /* Use a small step to accommodate enlargement through tile alignment */ step = sna->render.max_3d_size; if (region.extents.x1 & (8*512 / bpp - 1) || region.extents.y1 & 63) step /= 2; - while (step * step * 4 > sna->kgem.max_copy_tile_size) + while (step * step * 4 > max_size) step /= 2; + if (step == 0) { + DBG(("%s: tiles cannot fit into aperture\n", __FUNCTION__)); + return false; + } DBG(("%s (alu=%d), tile.size=%d, box=%dx[(%d, %d), (%d, %d)])\n", __FUNCTION__, alu, step, nbox, -- cgit v1.2.3