xf86-video-ati: Branch 'master'

Alex Deucher agd5f at kemper.freedesktop.org
Thu Jun 16 09:52:23 PDT 2011


 src/radeon_dri2.c |   60 +++++++++++++++++++++++++++++++++++++++++++-----------
 1 file changed, 48 insertions(+), 12 deletions(-)

New commits:
commit a6154c00c64932332e8f6e334661ffd579cfd894
Author: Alex Deucher <alexdeucher at gmail.com>
Date:   Thu Jun 16 12:48:43 2011 -0400

    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 at gmail.com>

diff --git a/src/radeon_dri2.c b/src/radeon_dri2.c
index bbe1a94..9bb5f39 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,


More information about the xorg-commit mailing list