xf86-video-intel: 2 commits - configure.ac src/intel_dri.c

Chad Versace chadversary at kemper.freedesktop.org
Wed Jun 8 10:12:01 PDT 2011


 configure.ac    |    1 +
 src/intel_dri.c |   44 ++++++++++++++++++++++++++++++++++++++------
 2 files changed, 39 insertions(+), 6 deletions(-)

New commits:
commit a62db5b050dee10246c02c72385358acb5e72b56
Author: Chad Versace <chad at chad-versace.us>
Date:   Mon May 23 14:23:54 2011 -0700

    dri: Add support for DRI2BufferStencil and DRI2BufferHiz
    
    And bump configure.ac to require dri2proto >= 2.6, because
    DRI2BufferStencil and DRI2BufferHiz were introduced in that version.
    
    When a client requests DRI2BufferHiz or DRI2BufferStencil,
    I830DRI2CreateBuffer() now returns a Y-tiled buffer. The stencil buffer is
    handled as a special case due its quirky pitch requirements.
    
    CC: Eric Anholt <eric at anholt.net>
    CC: Ian Romanick <idr at freedesktop.org>
    CC: Kristian Høgsberg <krh at bitplanet.net
    Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
    Signed-off-by: Chad Versace <chad at chad-versace.us>

diff --git a/configure.ac b/configure.ac
index b4b693e..1776489 100644
--- a/configure.ac
+++ b/configure.ac
@@ -120,6 +120,7 @@ XORG_DRIVER_CHECK_EXT(DPMSExtension, xextproto)
 PKG_CHECK_MODULES(XORG, [xorg-server >= 1.6 xproto fontsproto $REQUIRED_MODULES])
 PKG_CHECK_MODULES(DRM, [libdrm >= 2.4.23])
 PKG_CHECK_MODULES(DRI, [xf86driproto], , DRI=no)
+PKG_CHECK_MODULES(DRI2, [dri2proto >= 2.6])
 PKG_CHECK_MODULES(PCIACCESS, [pciaccess >= 0.10])
 
 sdkdir=`$PKG_CONFIG --variable=sdkdir xorg-server`
diff --git a/src/intel_dri.c b/src/intel_dri.c
index 4571d07..be5c6b1 100644
--- a/src/intel_dri.c
+++ b/src/intel_dri.c
@@ -329,11 +329,16 @@ I830DRI2CreateBuffer(DrawablePtr drawable, unsigned int attachment,
 		pixmap = get_front_buffer(drawable);
 	if (pixmap == NULL) {
 		unsigned int hint = INTEL_CREATE_PIXMAP_DRI2;
+		int pixmap_width = drawable->width;
+		int pixmap_height = drawable->height;
+		int pixmap_cpp = (format != 0) ? format : drawable->depth;
 
 		if (intel->tiling & INTEL_TILING_3D) {
 			switch (attachment) {
 			case DRI2BufferDepth:
 			case DRI2BufferDepthStencil:
+			case DRI2BufferStencil:
+			case DRI2BufferHiz:
 				if (SUPPORTS_YTILING(intel)) {
 					hint |= INTEL_CREATE_PIXMAP_TILING_Y;
 					break;
@@ -354,11 +359,28 @@ I830DRI2CreateBuffer(DrawablePtr drawable, unsigned int attachment,
                         }
 		}
 
+		/*
+		 * The stencil buffer has quirky pitch requirements.  From Vol
+		 * 2a, 11.5.6.2.1 3DSTATE_STENCIL_BUFFER, field "Surface
+		 * Pitch":
+		 *    The pitch must be set to 2x the value computed based on
+		 *    width, as the stencil buffer is stored with two rows
+		 *    interleaved.
+		 * To accomplish this, we resort to the nasty hack of doubling
+		 * the drm region's cpp and halving its height.
+		 *
+		 * If we neglect to double the pitch, then
+		 * drm_intel_gem_bo_map_gtt() maps the memory incorrectly.
+		 */
+		if (attachment == DRI2BufferStencil) {
+			pixmap_height /= 2;
+			pixmap_cpp *= 2;
+		}
+
 		pixmap = screen->CreatePixmap(screen,
-					      drawable->width,
-					      drawable->height,
-					      (format != 0) ? format :
-							      drawable->depth,
+					      pixmap_width,
+					      pixmap_height,
+					      pixmap_cpp,
 					      hint);
 		if (pixmap == NULL || intel_get_pixmap_bo(pixmap) == NULL) {
 			if (pixmap)
commit 263daba7e6afb37bd471fdc8dd8e4458da0a45ff
Author: Chad Versace <chad at chad-versace.us>
Date:   Sun Jun 5 19:48:19 2011 -0700

    dri: Do not create DRI2 buffers for unrecognized DRI2 buffer tokens
    
    Before this commit, if a client were to request an unrecognized DRI2
    buffer, such as DRI2BufferStencil, then I830DRI2CreateBuffer() allocated
    and returned an X-tiled buffer by accident. The problem was that
    unrecognized tokens were caught by the default case of a switch statement.
    
    Now, when given unrecognized DRI2 tokens, I830DRI2CreateBuffers() returns
    null.
    
    This shouldn't break older Mesa versions, because they never query (via
    DRI2GetBuffersWithFormat) for the drawable's DRI2BufferStencil.
    
    CC: Eric Anholt <eric at anholt.net>
    CC: Ian Romanick <idr at freedesktop.org>
    CC: Kenneth Graunke <kenneth at whitecape.org>
    CC: Kristian Høgsberg <krh at bitplanet.net
    Signed-off-by: Chad Versace <chad at chad-versace.us>

diff --git a/src/intel_dri.c b/src/intel_dri.c
index 48d0f56..4571d07 100644
--- a/src/intel_dri.c
+++ b/src/intel_dri.c
@@ -338,10 +338,20 @@ I830DRI2CreateBuffer(DrawablePtr drawable, unsigned int attachment,
 					hint |= INTEL_CREATE_PIXMAP_TILING_Y;
 					break;
 				}
-			default:
+			case DRI2BufferAccum:
+			case DRI2BufferBackLeft:
+			case DRI2BufferBackRight:
+			case DRI2BufferFakeFrontLeft:
+			case DRI2BufferFakeFrontRight:
+			case DRI2BufferFrontLeft:
+			case DRI2BufferFrontRight:
 				hint |= INTEL_CREATE_PIXMAP_TILING_X;
 				break;
-			}
+			default:
+				free(privates);
+				free(buffer);
+				return NULL;
+                        }
 		}
 
 		pixmap = screen->CreatePixmap(screen,


More information about the xorg-commit mailing list