From patchwork Fri Jul 27 09:06:21 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: zhigang.gong@linux.intel.com X-Patchwork-Id: 1247611 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork2.kernel.org (Postfix) with ESMTP id 3D1C2DFFBF for ; Fri, 27 Jul 2012 09:06:40 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 24014A0FBD for ; Fri, 27 Jul 2012 02:06:40 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga03.intel.com (mga03.intel.com [143.182.124.21]) by gabe.freedesktop.org (Postfix) with ESMTP id 4E9559E77A for ; Fri, 27 Jul 2012 02:06:07 -0700 (PDT) Received: from azsmga002.ch.intel.com ([10.2.17.35]) by azsmga101.ch.intel.com with ESMTP; 27 Jul 2012 02:06:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.71,315,1320652800"; d="scan'208";a="127513958" Received: from unknown (HELO desktop.x86.com) ([10.238.157.64]) by AZSMGA002.ch.intel.com with ESMTP; 27 Jul 2012 02:06:01 -0700 From: zhigang.gong@linux.intel.com To: intel-gfx@lists.freedesktop.org Date: Fri, 27 Jul 2012 17:06:21 +0800 Message-Id: <1343379981-12082-1-git-send-email-zhigang.gong@linux.intel.com> X-Mailer: git-send-email 1.7.4.4 Subject: [Intel-gfx] [PATCH] uxa_glamor_dri: Use exchange buffer in glamor fixup. X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 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 From: Zhigang Gong The previous implementation is to create a new textured pixmap based on the newly created pixmap's buffer object. This is not efficient, as we already created it when we call CreatePixmap. We can just exchange the underlying texture/image buffers by calling intel_glamor_exchange_buffers(). And this commit seems also fix a weird rendering problem when working with compiz/mutter. Signed-off-by: Zhigang Gong --- src/intel_dri.c | 29 ++++++++++------------------- 1 files changed, 10 insertions(+), 19 deletions(-) diff --git a/src/intel_dri.c b/src/intel_dri.c index d027a64..c168b78 100644 --- a/src/intel_dri.c +++ b/src/intel_dri.c @@ -110,6 +110,7 @@ static PixmapPtr fixup_glamor(DrawablePtr drawable, PixmapPtr pixmap) { ScreenPtr screen = drawable->pScreen; ScrnInfoPtr scrn = xf86ScreenToScrn(screen); + intel_screen_private *intel = intel_get_screen_private(scrn); PixmapPtr old = get_drawable_pixmap(drawable); struct intel_pixmap *priv = intel_get_pixmap_private(pixmap); GCPtr gc; @@ -139,28 +140,20 @@ static PixmapPtr fixup_glamor(DrawablePtr drawable, PixmapPtr pixmap) } intel_set_pixmap_private(pixmap, NULL); - screen->DestroyPixmap(pixmap); + /* Exchange the underlying texture/image. */ + intel_glamor_exchange_buffers(intel, old, pixmap); /* And redirect the pixmap to the new bo (for 3D). */ intel_set_pixmap_private(old, priv); old->refcnt++; - /* This creating should not fail, as we already created its - * successfully. But if it happens, we put a warning indicator - * here, and the old pixmap will still be a glamor pixmap, and - * latter the pixmap_flink will get a 0 name, then the X server - * will pass a BadAlloc to the client.*/ - if (!intel_glamor_create_textured_pixmap(old)) - xf86DrvMsg(scrn->scrnIndex, X_WARNING, - "Failed to get DRI drawable for glamor pixmap.\n"); - screen->ModifyPixmapHeader(old, drawable->width, drawable->height, 0, 0, priv->stride, NULL); - + screen->DestroyPixmap(pixmap); intel_get_screen_private(xf86ScreenToScrn(screen))->needs_flush = TRUE; return old; } @@ -194,10 +187,9 @@ I830DRI2CreateBuffers(DrawablePtr drawable, unsigned int *attachments, if (attachments[i] == DRI2BufferFrontLeft) { pixmap = get_front_buffer(drawable); - if (pixmap && intel_get_pixmap_private(pixmap) == NULL) { + if (pixmap == NULL) { + drawable = &(get_drawable_pixmap(drawable)->drawable); is_glamor_pixmap = TRUE; - drawable = &pixmap->drawable; - pixmap = NULL; } } else if (attachments[i] == DRI2BufferStencil && pDepthPixmap) { pixmap = pDepthPixmap; @@ -237,7 +229,7 @@ I830DRI2CreateBuffers(DrawablePtr drawable, unsigned int *attachments, goto unwind; } - if (attachment == DRI2BufferFrontLeft) + if (attachment == DRI2BufferFrontLeft && is_glamor_pixmap) pixmap = fixup_glamor(drawable, pixmap); } @@ -314,10 +306,9 @@ I830DRI2CreateBuffer(DrawablePtr drawable, unsigned int attachment, if (attachment == DRI2BufferFrontLeft) { pixmap = get_front_buffer(drawable); - if (pixmap && intel_get_pixmap_private(pixmap) == NULL) { + if (pixmap == NULL) { + drawable = &(get_drawable_pixmap(drawable)->drawable); is_glamor_pixmap = TRUE; - drawable = &pixmap->drawable; - pixmap = NULL; } } @@ -391,7 +382,7 @@ I830DRI2CreateBuffer(DrawablePtr drawable, unsigned int attachment, free(buffer); return NULL; } - if (attachment == DRI2BufferFrontLeft) + if (attachment == DRI2BufferFrontLeft && is_glamor_pixmap) pixmap = fixup_glamor(drawable, pixmap); }