Skip to contentSkip to conversation

ddx/dri: Add support for hiz and separate stencil buffers

PATCH New Chad Versace 1 participant 4 messages Jun 6, 2011

lore
Share & tools
lore
#0 lore raw

cover ddx/dri: Add support for hiz and separate stencil buffers

patch 1: dri2proto
patch 2-3: xf86-video-intel

Quoted 6 lines · Eric Anholt

This should make configure.ac depend on the bumped version of dri2proto.h, so people get an explanation instead of just build failure.

Also, I'm surprised to see you didn't fix the "we'll allocate a buffer for *anything*" behavior that made the compat path in Mesa strange this time around.

Eric, I've fixed the patch series according to your comments and resubmitted.

Chad Versace (2):
dri: Do not create DRI2 buffers for unrecognized DRI2 buffer tokens
dri: Add support for DRI2BufferStencil and DRI2BufferHiz

 configure.ac    |    1 +
 src/intel_dri.c |   44 ++++++++++++++++++++++++++++++++++++++------
 2 files changed, 39 insertions(+), 6 deletions(-)
Signature · 1 line
1.7.5.2
#1 lore raw

PATCH 1/1 Add attachment token DRI2BufferHiz

... and bump version to 2.6.

CC Eric Anholt <[email protected]>
CC Ian Romanick <[email protected]>
CC Kristian Høgsberg <[email protected]>
---
 configure.ac  |    2 +-
 dri2proto.txt |    6 +++++-
 dri2tokens.h  |    1 +
 3 files changed, 7 insertions(+), 2 deletions(-)
configure.ac +1 -1
index 297be0e..d671f5a 100644
@@ -1,5 +1,5 @@
 AC_PREREQ([2.60])
-AC_INIT([DRI2Proto], [2.5], [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg])
+AC_INIT([DRI2Proto], [2.6], [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg])
 AM_INIT_AUTOMAKE([foreign dist-bzip2])
 AM_MAINTAINER_MODE
 
dri2proto.txt +5 -1
index dc46e58..df763c7 100644
@@ -178,7 +178,8 @@ DRI2ATTACHMENT { DRI2BufferFrontLeft
 	       	 DRI2BufferAccum
 		 DRI2BufferFakeFrontLeft
 		 DRI2BufferFakeFrontRight
-		 DRI2BufferDepthStencil }
+		 DRI2BufferDepthStencil
+		 DRI2BufferHiz }
 
 	These values describe various attachment points for DRI2
 	buffers.
@@ -509,6 +510,8 @@ The DRI2 extension has undergone a number of revisions before
 
 	2.3: Added the DRI2InvalidateBuffers event.
 
+	2.6: Enlightenment attained.  Added the DRI2BufferHiz attachment.
+
 Compatibility up to 2.0 is not preserved, but was also never released.
 
 
@@ -569,6 +572,7 @@ A.1 Common Types
 	0x7	DRI2BufferFakeFrontLeft
 	0x8	DRI2BufferFakeFrontRight
 	0x9	DRI2BufferDepthStencil
+	0xa	DRI2BufferHiz
 └───
 	Used to encode the possible attachment points.  The attachment
 	DRI2BufferDepthStencil is only available with protocol version 1.1 or
dri2tokens.h +1 -0
index 7804e4d..16c9008 100644
@@ -43,6 +43,7 @@
 #define DRI2BufferFakeFrontLeft		7
 #define DRI2BufferFakeFrontRight	8
 #define DRI2BufferDepthStencil		9
+#define DRI2BufferHiz			10
 
 #define DRI2DriverDRI			0
 #define DRI2DriverVDPAU			1
Signature · 6 lines
1.7.5.2

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#2 lore raw

PATCH 2/3 dri: Do not create DRI2 buffers for unrecognized DRI2 buffer tokens

In reply to Chad Versace

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 <[email protected]>
CC Ian Romanick <[email protected]>
CC Kristian Høgsberg <[email protected]>
CC Kenneth Graunke <[email protected]>
---
 src/intel_dri.c |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)
src/intel_dri.c +12 -2
index 48d0f56..4571d07 100644
@@ -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,
Signature · 6 lines
1.7.5.2

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#3 lore raw

PATCH 3/3 dri: Add support for DRI2BufferStencil and DRI2BufferHiz

In reply to Chad Versace

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 <[email protected]>
CC Ian Romanick <[email protected]>
CC Kristian Høgsberg <[email protected]>
CC Kenneth Graunke <[email protected]>
---
 configure.ac    |    1 +
 src/intel_dri.c |   30 ++++++++++++++++++++++++++----
 2 files changed, 27 insertions(+), 4 deletions(-)
configure.ac +1 -0
index 9449e56..cd28547 100644
@@ -105,6 +105,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`
src/intel_dri.c +26 -4
index 4571d07..be5c6b1 100644
@@ -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)
Signature · 6 lines
1.7.5.2

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx