Permalink
Browse files

dri2: fix allocation of Z16 depth attachments

  • Loading branch information...
1 parent 3d2a752 commit ad402333157c437ccd2c639f5b3f3bcb81e78d6c Christoph Bumiller committed Dec 10, 2011
Showing with 15 additions and 3 deletions.
  1. +5 −1 src/nouveau_dri2.c
  2. +8 −0 src/nouveau_local.h
  3. +2 −2 src/nv_accel_common.c
View
@@ -46,16 +46,20 @@ 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;
else
usage_hint |= NOUVEAU_CREATE_PIXMAP_SCANOUT;
ppix = pScreen->CreatePixmap(pScreen, pDraw->width,
- pDraw->height, pDraw->depth,
+ pDraw->height, bpp,
usage_hint);
}
View
@@ -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); \
View
@@ -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

0 comments on commit ad40233

Please sign in to comment.