From 8c8f15c9d3a31c35bf2ef20faf8c4133295a678f Mon Sep 17 00:00:00 2001 From: Francisco Jerez Date: Sun, 10 Oct 2010 04:36:17 +0200 Subject: nv10-nv40/exa: Fix tiled pixmap pitch alignment calculation. Signed-off-by: Francisco Jerez --- src/nouveau_exa.c | 5 +++-- src/nouveau_local.h | 5 +++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/nouveau_exa.c b/src/nouveau_exa.c index f2995be..92dc946 100644 --- a/src/nouveau_exa.c +++ b/src/nouveau_exa.c @@ -347,8 +347,9 @@ nouveau_exa_create_pixmap(ScreenPtr pScreen, int width, int height, int depth, height = NOUVEAU_ALIGN(height, 1 << (tile_mode + 2)); } else { if (usage_hint & NOUVEAU_CREATE_PIXMAP_TILED) { - int pitch_align = - pNv->dev->chipset >= 0x40 ? 1024 : 256; + int pitch_align = max( + pNv->dev->chipset >= 0x40 ? 1024 : 256, + round_down_pow2(*new_pitch / 4)); *new_pitch = NOUVEAU_ALIGN(*new_pitch, pitch_align); diff --git a/src/nouveau_local.h b/src/nouveau_local.h index a950db4..5d3200a 100644 --- a/src/nouveau_local.h +++ b/src/nouveau_local.h @@ -69,4 +69,9 @@ static inline int log2i(int i) return r; } +static inline int round_down_pow2(int x) +{ + return 1 << log2i(x); +} + #endif -- cgit v1.2.1