summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2011-11-04 13:26:13 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2011-11-04 13:25:45 +0000
commit4c7c94ad98ac94a1f8fffbf2ffd79fc3bfcef647 (patch)
tree1d1be42dc9834246fa90be65156defe4c6f82e7b
parent9c29be40bcb139ba57927fde954f66dcc4f0e6c8 (diff)
testdisplay: Round tiled allocations up to pot stride and fence size
Be simple and use the strictest requirements from gen2/3 with old kernels so that this simply works everywhere. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=42585
-rw-r--r--tests/testdisplay.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/tests/testdisplay.c b/tests/testdisplay.c
index e58461a..3c9741c 100644
--- a/tests/testdisplay.c
+++ b/tests/testdisplay.c
@@ -421,8 +421,23 @@ allocate_surface(int fd, int width, int height, uint32_t depth, uint32_t bpp,
int size, stride;
if (tiled) {
- stride = (width * (bpp / 8) + 511) & ~511;
- size = stride * (height + 7) & ~7;
+ int v;
+
+ /* Round the tiling up to the next power-of-two and the
+ * region up to the next pot fence size so that this works
+ * on all generations.
+ *
+ * This can still fail if the framebuffer is too large to
+ * be tiled. But then that failure is expected.
+ */
+
+ v = width * bpp / 8;
+ for (stride = 512; stride < v; stride *= 2)
+ ;
+
+ v = stride * height;
+ for (size = 1024*1024; size < v; size *= 2)
+ ;
} else {
/* Scan-out has a 64 byte alignment restriction */
stride = (width * (bpp / 8) + 63) & ~63;
@@ -456,8 +471,8 @@ allocate_surface(int fd, int width, int height, uint32_t depth, uint32_t bpp,
set_tiling.tiling_mode = I915_TILING_X;
set_tiling.stride = stride;
if (ioctl(fd, DRM_IOCTL_I915_GEM_SET_TILING, &set_tiling)) {
- fprintf(stderr, "set tiling failed: %s\n",
- strerror(errno));
+ fprintf(stderr, "set tiling failed: %s (stride=%d, size=%d)\n",
+ strerror(errno), stride, size);
return NULL;
}
}