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
This commit is contained in:
Chris Wilson 2011-11-04 13:26:13 +00:00
parent 9c29be40bc
commit 4c7c94ad98

View File

@ -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;
}
}