summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Bumiller <e0425955@student.tuwien.ac.at>2011-12-10 13:32:24 +0100
committerChristoph Bumiller <e0425955@student.tuwien.ac.at>2011-12-10 13:32:24 +0100
commitad402333157c437ccd2c639f5b3f3bcb81e78d6c (patch)
treea8f3078ab076984ce20ea33ceb3c37fec85f03e6
parent3d2a752ca8aafee5e1e94dabfd7deec439890e95 (diff)
dri2: fix allocation of Z16 depth attachments
-rw-r--r--src/nouveau_dri2.c6
-rw-r--r--src/nouveau_local.h8
-rw-r--r--src/nv_accel_common.c4
3 files changed, 15 insertions, 3 deletions
diff --git a/src/nouveau_dri2.c b/src/nouveau_dri2.c
index d14443f..979216d 100644
--- a/src/nouveau_dri2.c
+++ b/src/nouveau_dri2.c
@@ -46,8 +46,12 @@ nouveau_dri2_create_buffer(DrawablePtr pDraw, unsigned int attachment,
ppix->refcnt++;
} else {
+ int bpp;
unsigned int usage_hint = NOUVEAU_CREATE_PIXMAP_TILED;
+ /* 'format' is just depth */
+ bpp = round_up_pow2(format);
+
if (attachment == DRI2BufferDepth ||
attachment == DRI2BufferDepthStencil)
usage_hint |= NOUVEAU_CREATE_PIXMAP_ZETA;
@@ -55,7 +59,7 @@ nouveau_dri2_create_buffer(DrawablePtr pDraw, unsigned int attachment,
usage_hint |= NOUVEAU_CREATE_PIXMAP_SCANOUT;
ppix = pScreen->CreatePixmap(pScreen, pDraw->width,
- pDraw->height, pDraw->depth,
+ pDraw->height, bpp,
usage_hint);
}
diff --git a/src/nouveau_local.h b/src/nouveau_local.h
index cc2fe34..cfce831 100644
--- a/src/nouveau_local.h
+++ b/src/nouveau_local.h
@@ -79,6 +79,14 @@ static inline int round_down_pow2(int x)
return 1 << log2i(x);
}
+static inline int round_up_pow2(int x)
+{
+ int r = round_down_pow2(x);
+ if (r < x)
+ r <<= 1;
+ return r;
+}
+
#define SWAP(x, y) do { \
typeof(x) __z = (x); \
(x) = (y); \
diff --git a/src/nv_accel_common.c b/src/nv_accel_common.c
index 3219dbe..51cc66a 100644
--- a/src/nv_accel_common.c
+++ b/src/nv_accel_common.c
@@ -71,7 +71,7 @@ nouveau_allocate_surface(ScrnInfoPtr scrn, int width, int height, int bpp,
tile_mode = 0x00;
if (usage_hint & NOUVEAU_CREATE_PIXMAP_ZETA)
- tile_flags = 0x1100; /* S8Z24 */
+ tile_flags = (bpp == 16) ? 0x0100 : 0x1100; /* Z16 : Z24S8 */
else
tile_flags = 0xfe00;
@@ -90,7 +90,7 @@ nouveau_allocate_surface(ScrnInfoPtr scrn, int width, int height, int bpp,
tile_mode = 0;
if (usage_hint & NOUVEAU_CREATE_PIXMAP_ZETA)
- tile_flags = 0x22800;
+ tile_flags = (bpp == 16) ? 0x26c00 : 0x22800;
else if (usage_hint & NOUVEAU_CREATE_PIXMAP_SCANOUT)
tile_flags = (bpp == 16 ? 0x7000 : 0x7a00);
else