From patchwork Thu Jul 24 23:18:19 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Packard X-Patchwork-Id: 4620441 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B1E609F375 for ; Thu, 24 Jul 2014 23:18:47 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DE82C20179 for ; Thu, 24 Jul 2014 23:18:46 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 0631520170 for ; Thu, 24 Jul 2014 23:18:46 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 07B6C6E781; Thu, 24 Jul 2014 16:18:45 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from keithp.com (home.keithp.com [63.227.221.253]) by gabe.freedesktop.org (Postfix) with ESMTP id A0FE46E779; Thu, 24 Jul 2014 16:18:43 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by keithp.com (Postfix) with ESMTP id 57C94760141; Thu, 24 Jul 2014 16:18:43 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at keithp.com Received: from keithp.com ([127.0.0.1]) by localhost (keithp.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id gRqVfRAIvEEO; Thu, 24 Jul 2014 16:18:39 -0700 (PDT) Received: by keithp.com (Postfix, from userid 1033) id 9C009760130; Thu, 24 Jul 2014 16:18:33 -0700 (PDT) Received: from hiro.keithp.com (localhost [127.0.0.1]) by keithp.com (Postfix) with ESMTP id 3236C76012B; Thu, 24 Jul 2014 16:18:33 -0700 (PDT) Received: by hiro.keithp.com (Postfix, from userid 1001) id 7864774A541; Thu, 24 Jul 2014 16:18:32 -0700 (PDT) From: Keith Packard To: xorg-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Date: Thu, 24 Jul 2014 16:18:19 -0700 Message-Id: <1406243908-1123-4-git-send-email-keithp@keithp.com> X-Mailer: git-send-email 2.0.1 In-Reply-To: <1406243908-1123-1-git-send-email-keithp@keithp.com> References: <1406243908-1123-1-git-send-email-keithp@keithp.com> Subject: [Intel-gfx] [PATCH 03/12] Don't use GetScratchPixmapHeader for shadow pixmaps X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP GetScratchPixmapHeader should only be used for local memory pixmaps, as used by PutImage and friends. That's because when you free the scratch pixmap header, it doesn't actually free the pixmap; instead, it gets stuffed in pScreen->pScratchPixmap and any private data stored on it will be left hanging around forever. In the case of glamor, that private data includes all of the GL state. Using that scratch pixmap later results in glamor getting mightily confused as the pixmap and underlying objects do not match. Avoid this by allocating pixmap headers explicitly for this purpose. Signed-off-by: Keith Packard --- src/uxa/intel_display.c | 44 ++++++++++++++++++++++++++++++-------------- 1 file changed, 30 insertions(+), 14 deletions(-) diff --git a/src/uxa/intel_display.c b/src/uxa/intel_display.c index 0b83140..bcaafaa 100644 --- a/src/uxa/intel_display.c +++ b/src/uxa/intel_display.c @@ -545,13 +545,31 @@ intel_crtc_shadow_allocate(xf86CrtcPtr crtc, int width, int height) return NULL; } - drm_intel_bo_disable_reuse(intel_crtc->rotate_bo); - intel_crtc->rotate_pitch = rotate_pitch; return intel_crtc->rotate_bo; } static PixmapPtr +intel_create_pixmap_header(ScreenPtr pScreen, int width, int height, int depth, + int bitsPerPixel, int devKind, void *pPixData) +{ + PixmapPtr pixmap; + + /* width and height of 0 means don't allocate any pixmap data */ + pixmap = (*pScreen->CreatePixmap) (pScreen, 0, 0, depth, 0); + + if (pixmap) { + if ((*pScreen->ModifyPixmapHeader) (pixmap, width, height, depth, + bitsPerPixel, devKind, pPixData)) + { + return pixmap; + } + (*pScreen->DestroyPixmap) (pixmap); + } + return NullPixmap; +} + +static PixmapPtr intel_crtc_shadow_create(xf86CrtcPtr crtc, void *data, int width, int height) { ScrnInfoPtr scrn = crtc->scrn; @@ -573,12 +591,12 @@ intel_crtc_shadow_create(xf86CrtcPtr crtc, void *data, int width, int height) return NULL; } - rotate_pixmap = GetScratchPixmapHeader(scrn->pScreen, - width, height, - scrn->depth, - scrn->bitsPerPixel, - intel_crtc->rotate_pitch, - NULL); + rotate_pixmap = intel_create_pixmap_header(scrn->pScreen, + width, height, + scrn->depth, + scrn->bitsPerPixel, + intel_crtc->rotate_pitch, + NULL); if (rotate_pixmap == NULL) { xf86DrvMsg(scrn->scrnIndex, X_ERROR, @@ -602,8 +620,8 @@ intel_crtc_shadow_destroy(xf86CrtcPtr crtc, PixmapPtr rotate_pixmap, void *data) struct intel_mode *mode = intel_crtc->mode; if (rotate_pixmap) { - intel_set_pixmap_bo(rotate_pixmap, NULL); - FreeScratchPixmapHeader(rotate_pixmap); + intel_set_pixmap_bo(rotate_pixmap, NULL); + rotate_pixmap->drawable.pScreen->DestroyPixmap(rotate_pixmap); } if (data) { @@ -1415,7 +1433,6 @@ intel_xf86crtc_resize(ScrnInfoPtr scrn, int width, int height) int i, old_width, old_height, old_pitch; int pitch; uint32_t tiling; - ScreenPtr screen; if (scrn->virtualX == width && scrn->virtualY == height) return TRUE; @@ -1430,8 +1447,7 @@ intel_xf86crtc_resize(ScrnInfoPtr scrn, int width, int height) old_front = intel->front_buffer; if (intel->back_pixmap) { - screen = intel->back_pixmap->drawable.pScreen; - screen->DestroyPixmap(intel->back_pixmap); + scrn->pScreen->DestroyPixmap(intel->back_pixmap); intel->back_pixmap = NULL; } @@ -1454,7 +1470,6 @@ intel_xf86crtc_resize(ScrnInfoPtr scrn, int width, int height) if (ret) goto fail; - drm_intel_bo_disable_reuse(intel->front_buffer); intel->front_pitch = pitch; intel->front_tiling = tiling; @@ -2204,6 +2219,7 @@ Bool intel_crtc_on(xf86CrtcPtr crtc) return ret; } + static PixmapPtr intel_create_pixmap_for_bo(ScreenPtr pScreen, dri_bo *bo, int width, int height,