From patchwork Fri Nov 22 06:58:09 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Packard X-Patchwork-Id: 3221531 Return-Path: X-Original-To: patchwork-dri-devel@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 63FC19F26C for ; Fri, 22 Nov 2013 06:58:29 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A853420780 for ; Fri, 22 Nov 2013 06:58:25 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id DAD5A2076B for ; Fri, 22 Nov 2013 06:58:21 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B2250FAFB6; Thu, 21 Nov 2013 22:58:17 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from keithp.com (home.keithp.com [63.227.221.253]) by gabe.freedesktop.org (Postfix) with ESMTP id 22835FAFB6; Thu, 21 Nov 2013 22:58:16 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by keithp.com (Postfix) with ESMTP id CEED51488005; Thu, 21 Nov 2013 22:58:15 -0800 (PST) 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 I-1TZKGVnREQ; Thu, 21 Nov 2013 22:58:11 -0800 (PST) Received: by keithp.com (Postfix, from userid 1033) id A21AC1488002; Thu, 21 Nov 2013 22:58:11 -0800 (PST) Received: from miki.keithp.com (localhost [127.0.0.1]) by keithp.com (Postfix) with ESMTP id 74CFB15803D; Thu, 21 Nov 2013 22:58:11 -0800 (PST) Received: by miki.keithp.com (Postfix, from userid 1001) id 1C941B0C; Thu, 21 Nov 2013 22:58:11 -0800 (PST) From: Keith Packard To: mesa-dev@lists.freedesktop.org Subject: [PATCH] dri3: Support GLX_INTEL_swap_event Date: Thu, 21 Nov 2013 22:58:09 -0800 Message-Id: <1385103489-24727-1-git-send-email-keithp@keithp.com> X-Mailer: git-send-email 1.8.4.2 Cc: dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dri-devel-bounces@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org X-Spam-Status: No, score=-4.7 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 The easy part is turning on the extension, now that the X server has a patch to send the events. The only trick was making sure the Present extension reliably provided the right 'sbc' count back in the event, and that's done by making sure the sbc count is always the same as the sequence number that we send in the PresentPixmap requests, and that's done by using the same variable for both roles. Signed-off-by: Keith Packard Reviewed-by: Eric Anholt --- This passes the piglet glx-swap-event test. src/glx/dri3_glx.c | 27 ++++++--------------------- src/glx/dri3_priv.h | 3 +-- 2 files changed, 7 insertions(+), 23 deletions(-) diff --git a/src/glx/dri3_glx.c b/src/glx/dri3_glx.c index 669f0bb..a7bf318 100644 --- a/src/glx/dri3_glx.c +++ b/src/glx/dri3_glx.c @@ -423,7 +423,7 @@ dri3_wait_for_msc(__GLXDRIdrawable *pdraw, int64_t target_msc, int64_t divisor, *ust = priv->ust; *msc = priv->msc; - *sbc = priv->sbc; + *sbc = priv->present_count; return 1; } @@ -450,7 +450,7 @@ dri3_wait_for_sbc(__GLXDRIdrawable *pdraw, int64_t target_sbc, int64_t *ust, { struct dri3_drawable *priv = (struct dri3_drawable *) pdraw; - while (priv->sbc < target_sbc) { + while (priv->present_count < target_sbc) { sleep(1); } return dri3_wait_for_msc(pdraw, 0, 0, 0, ust, msc, sbc); @@ -1282,7 +1282,8 @@ dri3_swap_buffers(__GLXDRIdrawable *pdraw, int64_t target_msc, int64_t divisor, /* Compute when we want the frame shown by taking the last known successful * MSC and adding in a swap interval for each outstanding swap request */ - ++priv->present_request_serial; + ++priv->present_count; + priv->present_request_serial = (uint32_t) priv->present_count; if (target_msc == 0) target_msc = priv->msc + priv->swap_interval * (priv->present_request_serial - priv->present_event_serial); @@ -1302,7 +1303,7 @@ dri3_swap_buffers(__GLXDRIdrawable *pdraw, int64_t target_msc, int64_t divisor, target_msc, divisor, remainder, 0, NULL); - ret = ++priv->sbc; + ret = priv->present_count; /* If there's a fake front, then copy the source back buffer * to the fake front to keep it up to date. This needs @@ -1494,23 +1495,7 @@ dri3_bind_extensions(struct dri3_screen *psc, struct glx_display * priv, __glXEnableDirectExtension(&psc->base, "GLX_SGI_swap_control"); __glXEnableDirectExtension(&psc->base, "GLX_MESA_swap_control"); __glXEnableDirectExtension(&psc->base, "GLX_SGI_make_current_read"); - - /* - * GLX_INTEL_swap_event is broken on the server side, where it's - * currently unconditionally enabled. This completely breaks - * systems running on drivers which don't support that extension. - * There's no way to test for its presence on this side, so instead - * of disabling it unconditionally, just disable it for drivers - * which are known to not support it, or for DDX drivers supporting - * only an older (pre-ScheduleSwap) version of DRI2. - * - * This is a hack which is required until: - * http://lists.x.org/archives/xorg-devel/2013-February/035449.html - * is merged and updated xserver makes it's way into distros: - */ -// if (pdp->swapAvailable && strcmp(driverName, "vmwgfx") != 0) { -// __glXEnableDirectExtension(&psc->base, "GLX_INTEL_swap_event"); -// } + __glXEnableDirectExtension(&psc->base, "GLX_INTEL_swap_event"); mask = psc->image_driver->getAPIMask(psc->driScreen); diff --git a/src/glx/dri3_priv.h b/src/glx/dri3_priv.h index 05f66cf..cdf986d 100644 --- a/src/glx/dri3_priv.h +++ b/src/glx/dri3_priv.h @@ -183,11 +183,10 @@ struct dri3_drawable { uint8_t have_fake_front; uint8_t is_pixmap; + uint64_t present_count; uint32_t present_request_serial; uint32_t present_event_serial; - uint64_t sbc; - uint64_t ust, msc; /* For WaitMSC */