Bug 27190

Summary: [945, calpella bisected] screen flicker issue with clutter test case on MeeGo
Product: Mesa Reporter: Li Peng <peng.li>
Component: Drivers/DRI/i915Assignee: Jesse Barnes <jbarnes>
Status: VERIFIED FIXED QA Contact: Xorg Project Team <xorg-team>
Severity: blocker    
Priority: highest CC: cworth, idr, jbarnes, suka.hiroaki
Version: git   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:
Attachments: expose swap control if present
xorg.0.log
fix invalidate path for when server support isn't present

Description Li Peng 2010-03-18 23:38:14 UTC
I tested latest graphics driver under MeeGo and met screen flickering issue on both 945 and Calpella. It should be related to the page-flipping feature. because if I disabled it with below patch, the problem will not happen.

diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index ae200ca..bb0830d 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -1460,6 +1460,7 @@ Bool drmmode_pre_init(ScrnInfoPtr scrn, int fd, int cpp)
 	gp.value = &has_flipping;
 	(void)drmCommandWriteRead(intel->drmSubFD, DRM_I915_GETPARAM, &gp,
 				  sizeof(gp));
+	has_flipping = 0;
 	if (has_flipping) {
 		xf86DrvMsg(scrn->scrnIndex, X_INFO,
 			   "Kernel page flipping support detected, enabling\n");


the driver I used is

kernel 2.6.33
mesa-7.8 git commit 346298c765
libdrm 2.4.19 + fix (intel: Align untiled buffer pitch to 64B)
xf86-video-intel git commit 3d4b3f257fbbb69c6f236d9803abe54a90d7d434
Comment 1 zhao jian 2010-03-22 04:38:31 UTC
On our 945GM and 945GME, we find the applications that use pageflip(compiz or other in fullscreen) will freeze(not refreshed) instead of flicker. As bug#26162. But if I disable pageflip in drmmode_display.c, it also works well. So I think these two bugs may be same. 
Comment 2 Carl Worth 2010-03-22 14:47:34 UTC
(In reply to comment #0)
> I tested latest graphics driver under MeeGo and met screen flickering issue on
> both 945 and Calpella. It should be related to the page-flipping feature.
> because if I disabled it with below patch, the problem will not happen.

The page-flipping code was using an uninitialized flip_count until the very
recent commit of 10cd04a84bcb6313903fc23b2d7791658ebc6b8e

Could you please retest with that and let us know if things get any better?
(And please clear the NEEDINFO keyword when you report back.)

Thanks,

-Carl
Comment 3 Li Peng 2010-03-22 19:25:32 UTC
(In reply to comment #2)
> (In reply to comment #0)
> > I tested latest graphics driver under MeeGo and met screen flickering issue on
> > both 945 and Calpella. It should be related to the page-flipping feature.
> > because if I disabled it with below patch, the problem will not happen.
> 
> The page-flipping code was using an uninitialized flip_count until the very
> recent commit of 10cd04a84bcb6313903fc23b2d7791658ebc6b8e
> 
> Could you please retest with that and let us know if things get any better?
> (And please clear the NEEDINFO keyword when you report back.)
> 
> Thanks,
> 
> -Carl
> 

The commit 10cd04a84bcb6313903fc23b2d7791658ebc6b8e doesn't fix screen-flickering problem in MeeGo.

I made some investigation and feel it looks like a clutter issue, because "glsync" works well with “glXGetVideoSyncSGI”  “glXWaitVideoSyncSGI” “glXSwapIntervalSGI” and “glXSwapBuffers”, but a clutter test case "clutter-1.2.2/tests/interactive/test-text" can reproduce the screen-flickering issue. 

I have sent mail to clutter-developer and waiting for their reply.
Comment 4 Carl Worth 2010-03-23 10:53:56 UTC
(In reply to comment #3)
> The commit 10cd04a84bcb6313903fc23b2d7791658ebc6b8e doesn't fix
> screen-flickering problem in MeeGo.
> 
> I made some investigation and feel it looks like a clutter issue, because
> "glsync" works well with “glXGetVideoSyncSGI”  “glXWaitVideoSyncSGI”
> “glXSwapIntervalSGI” and “glXSwapBuffers”, but a clutter test case
> "clutter-1.2.2/tests/interactive/test-text" can reproduce the screen-flickering
> issue. 

Thanks for clarifying this. I've updated the bug description to make things
more clear, (and removed the NEEDINFO keyword).

-Carl
Comment 5 Carl Worth 2010-03-23 11:15:48 UTC
Jesse made some comments about this bug on the mailing list (in reply
to comments from Li):

   > I think that could be related to this Clutter bug:
   > http://bugzilla.openedhand.com/show_bug.cgi?id=2044
   > 
   > It looks like we were using glXSwapInterval wrong for quite a while, but
   > since we changed to using a dummy drawable in Clutter 1.2 it ended up
   > completely broken.
   > 
   > My i965 laptop with Mesa git master is no longer reporting the
   > GLX_SGI_swap_control extension for some reason so Clutter falls back to
   > the GLX_SGI_video_sync extension for me. My netbook is in a bit of a
   > state at the moment so I can't check whether that's true for MeeGo.

   Our extensions string hasn't been very accurate in the past, has it?
   Thanks for pointing this out, it was an easy fix.  When I made DRI2
   more honest about the extensions it supported I guess we lost this one
   and I never re-added support to the server to indicate that we really
   do support it now.

   I'll send the X fix out today.

   Thanks,
   Jesse

Re-assigning to Jesse, then.

-Carl
Comment 6 Jesse Barnes 2010-03-23 11:49:18 UTC
Created attachment 34374 [details] [review]
expose swap control if present

Server patch to expose swap control if present.
Comment 7 zhao jian 2010-03-26 02:41:15 UTC
Maybe this still is our drivers bug. I test with the glxgears_fbconfig in full screen mode, and bisected out its first regression was caused by commit 51c75906329a4727e37c8d1f64f257ea9602caa2 in 2D driver. Its log is in attachment.

commit 51c75906329a4727e37c8d1f64f257ea9602caa2
Author: Jesse Barnes <jbarnes@virtuousgeek.org>
Date:   Fri May 1 14:52:26 2009 -0700

    DRI2: support new DRI2 APIs

    The new interfaces allow for improved buffer swap, and support for the SGI_swap_control, SGI_video_sync and OML_sync_control GLX extensions.

    The Intel implementation allows page flipping to occur for swaps that are full screen and not rotated.

    Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>

Comment 8 zhao jian 2010-03-26 02:41:55 UTC
Created attachment 34471 [details]
xorg.0.log
Comment 9 Jesse Barnes 2010-03-29 09:20:23 UTC
Can you try my patch series starting with https://patchwork.kernel.org/patch/88541/ to see if it helps with this issue?
Comment 10 fangxun 2010-03-30 00:55:53 UTC
With this patch series, it still fails.
Comment 11 Jesse Barnes 2010-04-01 16:14:46 UTC
If you disable page flipping:

diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index 1348e08..b9cd984 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -1464,7 +1464,7 @@ Bool drmmode_pre_init(ScrnInfoPtr scrn, int fd, int cpp)
 	if (has_flipping) {
 		xf86DrvMsg(scrn->scrnIndex, X_INFO,
 			   "Kernel page flipping support detected, enabling\n");
-		intel->use_pageflipping = TRUE;
+		intel->use_pageflipping = FALSE;
 		drmmode->flip_count = 0;
 		drmmode->event_context.version = DRM_EVENT_CONTEXT_VERSION;
 		drmmode->event_context.vblank_handler = drmmode_vblank_handler;
diff --git a/src/i830_dri.c b/src/i830_dri.c
index 321faf6..d220e3d 100644
--- a/src/i830_dri.c
+++ b/src/i830_dri.c
@@ -1013,7 +1013,7 @@ Bool I830DRI2ScreenInit(ScreenPtr screen)
 
 	info.CopyRegion = I830DRI2CopyRegion;
 #if DRI2INFOREC_VERSION >= 4
-	if (intel->use_pageflipping) {
+	if (intel->use_pageflipping || 1) {
 	    info.version = 4;
 	    info.ScheduleSwap = I830DRI2ScheduleSwap;
 	    info.GetMSC = I830DRI2GetMSC;

does it stop the flicker?
Comment 12 Jesse Barnes 2010-04-01 17:22:09 UTC
Created attachment 34604 [details] [review]
fix invalidate path for when server support isn't present

Please confirm this works for you too
Comment 13 Jesse Barnes 2010-04-01 17:33:15 UTC
Module: Mesa
Branch: 7.8
Commit: 2b4d8616f581a36ed98a491ac1ec14be69d37511
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=2b4d8616f581a36ed98a491ac1ec14be69d37511

Author: Jesse Barnes <jbarnes@virtuousgeek.org>
Date:   Thu Apr  1 17:26:04 2010 -0700

GLX/DRI2: pass GLX drawable ID to dri2InvalidateBuffers

The IDs will be the same in the case where an X window is used directly
as a GLX drawable, but will fail if a new GLX drawable is created
explicitly, as with glxgears_fbconfig.

Fixes fdo bug #27190.
Comment 14 zhao jian 2010-04-01 19:52:54 UTC
(In reply to comment #13)
> Module: Mesa
> Branch: 7.8
> Commit: 2b4d8616f581a36ed98a491ac1ec14be69d37511
> URL:   
> http://cgit.freedesktop.org/mesa/mesa/commit/?id=2b4d8616f581a36ed98a491ac1ec14be69d37511
> Author: Jesse Barnes <jbarnes@virtuousgeek.org>
> Date:   Thu Apr  1 17:26:04 2010 -0700
> GLX/DRI2: pass GLX drawable ID to dri2InvalidateBuffers
> The IDs will be the same in the case where an X window is used directly
> as a GLX drawable, but will fail if a new GLX drawable is created
> explicitly, as with glxgears_fbconfig.
> Fixes fdo bug #27190.

Yes, it now works well on 945GM, 945GME and capella with the newest code on mesa 7.8 branch. 
Comment 15 Li Peng 2010-04-01 20:04:30 UTC
confirmed, no flicker at all in MeeGo. Thanks for fixing this bug !
Comment 16 Gordon Jin 2010-04-01 20:12:00 UTC
Ian, how about to make mesa 7.8.1 for this?

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.