From patchwork Mon Jun 6 03:36:07 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Chad Versace X-Patchwork-Id: 850602 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by demeter2.kernel.org (8.14.4/8.14.3) with ESMTP id p563c8Cm019806 for ; Mon, 6 Jun 2011 03:38:28 GMT Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3F5F59EF03 for ; Sun, 5 Jun 2011 20:38:08 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from cloud01.chad-versace.us (184-106-247-128.static.cloud-ips.com [184.106.247.128]) by gabe.freedesktop.org (Postfix) with ESMTP id D2A159E9D9 for ; Sun, 5 Jun 2011 20:37:15 -0700 (PDT) Received: from localhost (c-76-105-164-10.hsd1.or.comcast.net [76.105.164.10]) by cloud01.chad-versace.us (Postfix) with ESMTPSA id 19C3E1D4078; Mon, 6 Jun 2011 03:39:02 +0000 (UTC) From: Chad Versace To: intel-gfx@lists.freedesktop.org Date: Sun, 5 Jun 2011 20:36:07 -0700 Message-Id: <1307331367-524-4-git-send-email-chad@chad-versace.us> X-Mailer: git-send-email 1.7.5.2 In-Reply-To: <1307331367-524-1-git-send-email-chad@chad-versace.us> References: <1307331367-524-1-git-send-email-chad@chad-versace.us> MIME-Version: 1.0 Subject: [Intel-gfx] =?utf-8?q?=5BPATCH_3/3=5D_dri=3A_Add_support_for_DRI2?= =?utf-8?q?BufferStencil_and_DRI2BufferHiz?= X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org Errors-To: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Mon, 06 Jun 2011 03:38:28 +0000 (UTC) X-MIME-Autoconverted: from base64 to 8bit by demeter2.kernel.org id p563c8Cm019806 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 CC: Ian Romanick CC: Kristian Høgsberg CC: Kenneth Graunke Signed-off-by: Chad Versace --- configure.ac | 1 + src/intel_dri.c | 30 ++++++++++++++++++++++++++---- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/configure.ac b/configure.ac index 9449e56..cd28547 100644 --- a/configure.ac +++ b/configure.ac @@ -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` 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)