summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Deucher <alexdeucher@gmail.com>2011-06-16 12:48:43 -0400
committerAlex Deucher <alexdeucher@gmail.com>2011-06-16 12:48:43 -0400
commita6154c00c64932332e8f6e334661ffd579cfd894 (patch)
treee2283e625ef82c8c4b8d8afd9d8d60a29b2ececc
parent41eb1fbb3d9da64feb4a96df7c575e44136b1538 (diff)
dri2/eg+: fix size and alignment of depth/stencil buffers
Base alignment may be 256B or 512B depending on the group size. Also need to check against front size for virtualX. Signed-off-by: Alex Deucher <alexdeucher@gmail.com>
-rw-r--r--src/radeon_dri2.c60
1 files changed, 48 insertions, 12 deletions
diff --git a/src/radeon_dri2.c b/src/radeon_dri2.c
index bbe1a94e..9bb5f397 100644
--- a/src/radeon_dri2.c
+++ b/src/radeon_dri2.c
@@ -83,6 +83,7 @@ radeon_dri2_create_buffers(DrawablePtr drawable,
int i, r, need_enlarge = 0;
int flags = 0;
unsigned front_width;
+ uint32_t tiling = 0;
pixmap = screen->GetScreenPixmap(screen);
front_width = pixmap->drawable.width;
@@ -148,17 +149,34 @@ radeon_dri2_create_buffers(DrawablePtr drawable,
flags = 0;
}
+ if (flags & RADEON_CREATE_PIXMAP_TILING_MICRO)
+ tiling |= RADEON_TILING_MICRO;
+ if (flags & RADEON_CREATE_PIXMAP_TILING_MICRO)
+ tiling |= RADEON_TILING_MACRO;
+
if (need_enlarge) {
/* evergreen uses separate allocations for depth and stencil
* so we make an extra large depth buffer to cover stencil
* as well.
*/
- int pitch = drawable->width * (drawable->depth / 8);
- int aligned_height = (drawable->height + 7) & ~7;
- int size = pitch * aligned_height;
- size = (size + 255) & ~255;
- size += drawable->width * aligned_height;
- aligned_height = ((size / pitch) + 7) & ~7;
+ unsigned aligned_width = drawable->width;
+ unsigned width_align = drmmode_get_pitch_align(pScrn, drawable->depth / 8, tiling);
+ unsigned aligned_height;
+ unsigned height_align = drmmode_get_height_align(pScrn, tiling);
+ unsigned base_align = drmmode_get_base_align(pScrn, drawable->depth / 8, tiling);
+ unsigned pitch_bytes;
+ unsigned size;
+
+ if (aligned_width == front_width)
+ aligned_width = pScrn->virtualX;
+ aligned_width = RADEON_ALIGN(aligned_width, width_align);
+ pitch_bytes = aligned_width * (drawable->depth / 8);
+ aligned_height = RADEON_ALIGN(drawable->height, height_align);
+ size = pitch_bytes * aligned_height;
+ size = RADEON_ALIGN(size, base_align);
+ /* add additional size for stencil */
+ size += aligned_width * aligned_height;
+ aligned_height = RADEON_ALIGN(size / pitch_bytes, height_align);
pixmap = (*pScreen->CreatePixmap)(pScreen,
drawable->width,
@@ -217,6 +235,7 @@ radeon_dri2_create_buffer(DrawablePtr drawable,
int r, need_enlarge = 0;
int flags;
unsigned front_width;
+ uint32_t tiling = 0;
pixmap = pScreen->GetScreenPixmap(pScreen);
front_width = pixmap->drawable.width;
@@ -282,18 +301,35 @@ radeon_dri2_create_buffer(DrawablePtr drawable,
flags = 0;
}
+ if (flags & RADEON_CREATE_PIXMAP_TILING_MICRO)
+ tiling |= RADEON_TILING_MICRO;
+ if (flags & RADEON_CREATE_PIXMAP_TILING_MICRO)
+ tiling |= RADEON_TILING_MACRO;
+
if (need_enlarge) {
/* evergreen uses separate allocations for depth and stencil
* so we make an extra large depth buffer to cover stencil
* as well.
*/
int depth = (format != 0) ? format : drawable->depth;
- int pitch = drawable->width * (depth / 8);
- int aligned_height = (drawable->height + 7) & ~7;
- int size = pitch * aligned_height;
- size = (size + 255) & ~255;
- size += drawable->width * aligned_height;
- aligned_height = ((size / pitch) + 7) & ~7;
+ unsigned aligned_width = drawable->width;
+ unsigned width_align = drmmode_get_pitch_align(pScrn, drawable->depth / 8, tiling);
+ unsigned aligned_height;
+ unsigned height_align = drmmode_get_height_align(pScrn, tiling);
+ unsigned base_align = drmmode_get_base_align(pScrn, drawable->depth / 8, tiling);
+ unsigned pitch_bytes;
+ unsigned size;
+
+ if (aligned_width == front_width)
+ aligned_width = pScrn->virtualX;
+ aligned_width = RADEON_ALIGN(aligned_width, width_align);
+ pitch_bytes = aligned_width * (depth / 8);
+ aligned_height = RADEON_ALIGN(drawable->height, height_align);
+ size = pitch_bytes * aligned_height;
+ size = RADEON_ALIGN(size, base_align);
+ /* add additional size for stencil */
+ size += aligned_width * aligned_height;
+ aligned_height = RADEON_ALIGN(size / pitch_bytes, height_align);
pixmap = (*pScreen->CreatePixmap)(pScreen,
drawable->width,