From e05e6be4fb0716f4475c5406b10b3d9cfb46fdc2 Mon Sep 17 00:00:00 2001 From: Marcin Slusarz Date: Sat, 29 Sep 2012 02:29:40 +0200 Subject: [PATCH] nouveau: round up stride size Based on nouveau_allocate_surface from xf86-video-nouveau. Fixes FDO#55294. --- src/gallium/drivers/nv30/nv30_miptree.c | 8 ++++++++ src/gallium/drivers/nv50/nv50_miptree.c | 3 +++ 2 files changed, 11 insertions(+) diff --git a/src/gallium/drivers/nv30/nv30_miptree.c b/src/gallium/drivers/nv30/nv30_miptree.c index 7e67729..439e291 100644 --- a/src/gallium/drivers/nv30/nv30_miptree.c +++ b/src/gallium/drivers/nv30/nv30_miptree.c @@ -51,6 +51,7 @@ nv30_miptree_get_handle(struct pipe_screen *pscreen, struct winsys_handle *handle) { struct nv30_miptree *mt = nv30_miptree(pt); + struct nouveau_device *dev = nouveau_screen(pscreen)->device; unsigned stride; if (!mt || !mt->base.bo) @@ -59,6 +60,13 @@ nv30_miptree_get_handle(struct pipe_screen *pscreen, stride = util_format_get_stride(mt->base.base.format, mt->base.base.width0); + stride = align(stride, 64); + if (pt->bind & PIPE_BIND_SCANOUT) { + int pitch_align = MAX2(dev->chipset >= 0x40 ? 1024 : 256, + 1 << util_logbase2(stride / 4)); + + stride = align(stride, pitch_align); + } return nouveau_screen_bo_get_handle(pscreen, mt->base.bo, stride, handle); } diff --git a/src/gallium/drivers/nv50/nv50_miptree.c b/src/gallium/drivers/nv50/nv50_miptree.c index 7b8dfb8..8ed787e 100644 --- a/src/gallium/drivers/nv50/nv50_miptree.c +++ b/src/gallium/drivers/nv50/nv50_miptree.c @@ -135,6 +135,9 @@ nv50_miptree_get_handle(struct pipe_screen *pscreen, stride = util_format_get_stride(mt->base.base.format, mt->base.base.width0); + stride = align(stride, 64); + if ((pt->bind & PIPE_BIND_SCANOUT) && !mt->base.bo->config.nv50.memtype) + stride = align(stride, 256); return nouveau_screen_bo_get_handle(pscreen, mt->base.bo, -- 1.7.12