From 2653524dffc1fe0dbff7d74bfc9be535d9ececb1 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Fri, 3 Feb 2012 20:06:43 +0000 Subject: [PATCH] sna: Reduce the downsample tile size to accommodate alignment If we need to enlarge the sampled tile due to tiling alignments, the resulting sample can become larger than we can accommodate through the 3D pipeline, resulting in FAIL. Signed-off-by: Chris Wilson --- src/sna/sna_render.c | 11 ++++++++--- src/sna/sna_tiling.c | 10 +++++++++- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/sna/sna_render.c b/src/sna/sna_render.c index bc8b2de7..c2b9e798 100644 --- a/src/sna/sna_render.c +++ b/src/sna/sna_render.c @@ -622,7 +622,7 @@ static int sna_render_picture_downsample(struct sna *sna, struct sna_pixmap *priv; pixman_transform_t t; PixmapPtr tmp; - int width, height; + int width, height, size; int sx, sy, ox, oy, ow, oh; int error, ret = 0; BoxRec box, b; @@ -743,8 +743,13 @@ static int sna_render_picture_downsample(struct sna *sna, ValidatePicture(tmp_dst); ValidatePicture(tmp_src); - w = sna->render.max_3d_size / sx - 2 * sx; - h = sna->render.max_3d_size / sy - 2 * sy; + /* Use a small size to accommodate enlargement through tile alignment */ + size = sna->render.max_3d_size - 4096 / pixmap->drawable.bitsPerPixel; + while (size * size * 4 > sna->kgem.max_copy_tile_size) + size /= 2; + + w = size / sx - 2 * sx; + h = size / sy - 2 * sy; DBG(("%s %d:%d downsampling using %dx%d GPU tiles\n", __FUNCTION__, (width + w-1)/w, (height + h-1)/h, w, h)); diff --git a/src/sna/sna_tiling.c b/src/sna/sna_tiling.c index 00e111ce..c6e898b1 100644 --- a/src/sna/sna_tiling.c +++ b/src/sna/sna_tiling.c @@ -142,7 +142,8 @@ sna_tiling_composite_done(struct sna *sna, /* Use a small step to accommodate enlargement through tile alignment */ step = sna->render.max_3d_size; - if (tile->dst_x & (8*512 / tile->dst->pDrawable->bitsPerPixel - 1)) + if (tile->dst_x & (8*512 / tile->dst->pDrawable->bitsPerPixel - 1) || + tile->dst_y & 63) step /= 2; while (step * step * 4 > sna->kgem.max_copy_tile_size) step /= 2; @@ -330,7 +331,11 @@ sna_tiling_fill_boxes(struct sna *sna, pixman_region_init_rects(®ion, box, n); + /* Use a small step to accommodate enlargement through tile alignment */ step = sna->render.max_3d_size; + if (region.extents.x1 & (8*512 / dst->drawable.bitsPerPixel - 1) || + region.extents.y1 & 63) + step /= 2; while (step * step * 4 > sna->kgem.max_copy_tile_size) step /= 2; @@ -443,7 +448,10 @@ Bool sna_tiling_blt_copy_boxes(struct sna *sna, uint8_t alu, 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) step /= 2;