From patchwork Thu Mar 4 17:01:00 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jesse Barnes X-Patchwork-Id: 83658 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o24H0xim020258 for ; Thu, 4 Mar 2010 17:01:35 GMT Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0E29D9E86E; Thu, 4 Mar 2010 09:00:59 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from outbound-mail-01.bluehost.com (outbound-mail-01.bluehost.com [69.89.21.11]) by gabe.freedesktop.org (Postfix) with SMTP id 357B89E7B8 for ; Thu, 4 Mar 2010 09:00:57 -0800 (PST) Received: (qmail 496 invoked by uid 0); 4 Mar 2010 17:00:56 -0000 Received: from unknown (HELO box514.bluehost.com) (74.220.219.114) by cpoproxy1.bluehost.com with SMTP; 4 Mar 2010 17:00:56 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=virtuousgeek.org; h=Received:Date:From:To:Subject:Message-ID:X-Mailer:Mime-Version:Content-Type:Content-Transfer-Encoding:X-Identified-User; b=hMZr76m4LLAn6h0utmz3vNVKj8iH3st7DwiCZ7Tdr5Z39Gxe0BA3iFLAra772EaRR3quvZitM4YxyFgD+IA1I0q1v2tod/yb/EjXuhjY0Ssgn2U8Qi4k06yG0q9WkOUv; Received: from [75.111.28.251] (helo=jbarnes-piketon) by box514.bluehost.com with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.69) (envelope-from ) id 1NnEPw-0005C6-75 for intel-gfx@lists.freedesktop.org; Thu, 04 Mar 2010 10:00:56 -0700 Date: Thu, 4 Mar 2010 09:01:00 -0800 From: Jesse Barnes To: intel-gfx@lists.freedesktop.org Message-ID: <20100304090100.6896412e@jbarnes-piketon> X-Mailer: Claws Mail 3.7.2 (GTK+ 2.18.3; x86_64-pc-linux-gnu) Mime-Version: 1.0 X-Identified-User: {10642:box514.bluehost.com:virtuous:virtuousgeek.org} {sentby:smtp auth 75.111.28.251 authed with jbarnes@virtuousgeek.org} Subject: [Intel-gfx] [PATCH] DRI2: handle offscreen drawables better at swap time 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@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Thu, 04 Mar 2010 17:01:35 +0000 (UTC) diff --git a/src/i830_dri.c b/src/i830_dri.c index 64aeb76..8fc6367 100644 --- a/src/i830_dri.c +++ b/src/i830_dri.c @@ -641,28 +641,14 @@ I830DRI2ScheduleSwap(ClientPtr client, DrawablePtr draw, DRI2BufferPtr front, int ret, pipe = I830DRI2DrawablePipe(draw), flip = 0; DRI2FrameEventPtr swap_info; enum DRI2FrameEventType swap_type = DRI2_SWAP; + BoxRec box; + RegionRec region; swap_info = xcalloc(1, sizeof(DRI2FrameEventRec)); /* Drawable not displayed... just complete the swap */ - if (pipe == -1 || !swap_info) { - BoxRec box; - RegionRec region; - - box.x1 = 0; - box.y1 = 0; - box.x2 = draw->width; - box.y2 = draw->height; - REGION_INIT(pScreen, ®ion, &box, 0); - - I830DRI2CopyRegion(draw, ®ion, front, back); - - DRI2SwapComplete(client, draw, 0, 0, 0, DRI2_BLIT_COMPLETE, func, - data); - if (swap_info) - xfree(swap_info); - return TRUE; - } + if (pipe == -1 || !swap_info) + goto blit_fallback; swap_info->drawable_id = draw->id; swap_info->client = client; @@ -681,7 +667,7 @@ I830DRI2ScheduleSwap(ClientPtr client, DrawablePtr draw, DRI2BufferPtr front, xf86DrvMsg(scrn->scrnIndex, X_WARNING, "first get vblank counter failed: %s\n", strerror(errno)); - return FALSE; + goto blit_fallback; } /* Flips need to be submitted one frame before */ @@ -694,6 +680,21 @@ I830DRI2ScheduleSwap(ClientPtr client, DrawablePtr draw, DRI2BufferPtr front, swap_info->type = swap_type; /* + * Sanity check the target vblank count the server gave us. + * Note it'll be 1 if the drawable was offscreen for its last swap, + * so don't bother reporting that as it's common. + */ + if (*target_msc != 1 && vbl.reply.sequence > *target_msc) + xf86DrvMsg(scrn->scrnIndex, X_WARNING, + "missed vblank event: cur %ld, target %ld\n", + (unsigned long)vbl.reply.sequence, + (unsigned long)*target_msc); + else if (*target_msc != 1 && *target_msc - vbl.reply.sequence > 100) + ErrorF("vblank event in the distant future: cur %ld, target %ld\n", + (unsigned long)vbl.reply.sequence, + (unsigned long)*target_msc); + + /* * If divisor is zero, we just need to make sure target_msc passes * before waking up the client. */ @@ -711,7 +712,7 @@ I830DRI2ScheduleSwap(ClientPtr client, DrawablePtr draw, DRI2BufferPtr front, xf86DrvMsg(scrn->scrnIndex, X_WARNING, "divisor 0 get vblank counter failed: %s\n", strerror(errno)); - return FALSE; + goto blit_fallback; } *target_msc = vbl.reply.sequence; @@ -764,13 +765,28 @@ I830DRI2ScheduleSwap(ClientPtr client, DrawablePtr draw, DRI2BufferPtr front, xf86DrvMsg(scrn->scrnIndex, X_WARNING, "final get vblank counter failed: %s\n", strerror(errno)); - return FALSE; + goto blit_fallback; } *target_msc = vbl.reply.sequence; swap_info->frame = *target_msc; return TRUE; + +blit_fallback: + box.x1 = 0; + box.y1 = 0; + box.x2 = draw->width; + box.y2 = draw->height; + REGION_INIT(pScreen, ®ion, &box, 0); + + I830DRI2CopyRegion(draw, ®ion, front, back); + + DRI2SwapComplete(client, draw, 0, 0, 0, DRI2_BLIT_COMPLETE, func, data); + if (swap_info) + xfree(swap_info); + *target_msc = 0; /* offscreen, so zero out target vblank count */ + return TRUE; } /*