summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2011-11-05 11:56:17 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2011-11-05 11:56:17 +0000
commitd21c30d0b8b08ec85c3b5d9a02a6969f7c8b9315 (patch)
tree9d82a621755a14e65d47ce27c6f6af713a0061ff
parente309cea3ae5c22c58a918008a52e3d8d694c9ff2 (diff)
sna: Constrain GPU pixmaps to always fit within the blitter
Otherwise we end up always doing expensive readbacks where we would obviously prefer it if we simply used cached memory for the CPU operation and then upload. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r--src/sna/kgem.c27
1 files changed, 21 insertions, 6 deletions
diff --git a/src/sna/kgem.c b/src/sna/kgem.c
index b0e76b7a..29f572b8 100644
--- a/src/sna/kgem.c
+++ b/src/sna/kgem.c
@@ -443,16 +443,31 @@ static uint32_t kgem_surface_size(struct kgem *kgem,
break;
}
+ /* If it is too wide for the blitter, don't even bother. */
*pitch = ALIGN(width * bpp / 8, tile_width);
- if (kgem->gen < 40 && tiling != I915_TILING_NONE) {
- if (*pitch > 8192)
+ if (kgem->gen < 40) {
+ if(tiling != I915_TILING_NONE) {
+ if (*pitch > 8192)
+ return 0;
+ for (size = tile_width; size < *pitch; size <<= 1)
+ ;
+ *pitch = size;
+ } else {
+ if (*pitch >= 32768)
+ return 0;
+ }
+ } else {
+ int limit = 32768;
+ if (tiling)
+ limit *= 4;
+ if (*pitch >= limit)
return 0;
- for (size = tile_width; size < *pitch; size <<= 1)
- ;
- *pitch = size;
}
+ height = ALIGN(height, tile_height);
+ if (height >= 65536)
+ return 0;
- size = *pitch * ALIGN(height, tile_height);
+ size = *pitch * height;
if (kgem->has_relaxed_fencing || tiling == I915_TILING_NONE)
return ALIGN(size, PAGE_SIZE);