← Back to team overview

compiz team mailing list archive

[Merge] lp:~vanvugt/compiz/fix-763005-trunk into lp:compiz

 

Daniel van Vugt has proposed merging lp:~vanvugt/compiz/fix-763005-trunk into lp:compiz.

Requested reviews:
  Sam Spilsbury (smspillaz)
  compiz packagers (compiz)
Related bugs:
  Bug #763005 in fglrx-installer (Ubuntu): "Compiz's "Sync to Vblank" makes display stutter/slow with some drivers (like fglrx)"
  https://bugs.launchpad.net/ubuntu/+source/fglrx-installer/+bug/763005

For more details, see:
https://code.launchpad.net/~vanvugt/compiz/fix-763005-trunk/+merge/68244

Fix slow/stuttering display when sync to Vblank is enabled. (LP: #763005)

Use the GLX_SGI_swap_control extension for Vsync instead. It's more efficient and is the OpenGL recommended solution (http://www.opengl.org/wiki/Swap_Interval). If the extension is not supported then fall back to the old logic.

-- 
https://code.launchpad.net/~vanvugt/compiz/fix-763005-trunk/+merge/68244
Your team compiz packagers is requested to review the proposed merge of lp:~vanvugt/compiz/fix-763005-trunk into lp:compiz.
=== added file 'debian/patches/092_fix_slow_vsync_lp763005.patch'
--- debian/patches/092_fix_slow_vsync_lp763005.patch	1970-01-01 00:00:00 +0000
+++ debian/patches/092_fix_slow_vsync_lp763005.patch	2011-07-18 13:09:31 +0000
@@ -0,0 +1,89 @@
+Description: Fix slow/stuttering display when sync to Vblank is enabled.
+ Use the GLX_SGI_swap_control extension for more efficient Vsync
+ (http://www.opengl.org/wiki/Swap_Interval).
+Author: Daniel van Vugt <vanvugt@xxxxxxxxx>
+Bug-Ubuntu: https://launchpad.net/bugs/763005
+
+=== modified file 'plugins/opengl/include/opengl/opengl.h'
+--- old/plugins/opengl/include/opengl/opengl.h	2011-02-24 17:31:29 +0000
++++ new/plugins/opengl/include/opengl/opengl.h	2011-07-18 11:54:25 +0000
+@@ -102,6 +102,7 @@
+     typedef int (*GLXWaitVideoSyncProc) (int	  divisor,
+ 					 int	  remainder,
+ 					 unsigned int *count);
++    typedef int (*GLXSwapIntervalProc) (int interval);
+ 
+     #ifndef GLX_VERSION_1_3
+     typedef struct __GLXFBConfigRec *GLXFBConfig;
+
+=== modified file 'plugins/opengl/src/screen.cpp'
+--- old/plugins/opengl/src/screen.cpp	2011-04-06 19:37:45 +0000
++++ new/plugins/opengl/src/screen.cpp	2011-07-18 12:46:15 +0000
+@@ -38,6 +38,7 @@
+     GLXCopySubBufferProc     copySubBuffer = NULL;
+     GLXGetVideoSyncProc      getVideoSync = NULL;
+     GLXWaitVideoSyncProc     waitVideoSync = NULL;
++    GLXSwapIntervalProc      swapInterval = NULL;
+     GLXGetFBConfigsProc      getFBConfigs = NULL;
+     GLXGetFBConfigAttribProc getFBConfigAttrib = NULL;
+     GLXCreatePixmapProc      createPixmap = NULL;
+@@ -234,6 +235,12 @@
+ 	    getProcAddress ("glXWaitVideoSyncSGI");
+     }
+ 
++    if (strstr (glxExtensions, "GLX_SGI_swap_control"))
++    {
++        GL::swapInterval = (GL::GLXSwapIntervalProc)
++	    getProcAddress ("glXSwapIntervalSGI");
++    }
++
+     glXMakeCurrent (dpy, CompositeScreen::get (s)->output (), priv->ctx);
+ 
+     glExtensions = (const char *) glGetString (GL_EXTENSIONS);
+@@ -1004,17 +1011,24 @@
+ void
+ PrivateGLScreen::waitForVideoSync ()
+ {
+-    unsigned int sync;
+-
+-    if (!optionGetSyncToVblank ())
+-	return;
+-
+-    if (GL::getVideoSync)
+-    {
+-	glFlush ();
+-
+-	(*GL::getVideoSync) (&sync);
+-	(*GL::waitVideoSync) (2, (sync + 1) % 2, &sync);
++    bool sync = optionGetSyncToVblank ();
++    glFlush ();
++    /*
++     * swapInterval (glXSwapIntervalSGI) is more efficient, if supported.
++     * It effectively offloads the "waiting" to the driver/GPU. Note
++     * however swapInterval may do nothing if you have waiting for vsync
++     * disabled in your driver control panel.
++     * (http://www.opengl.org/wiki/Swap_Interval)
++     */
++    if (GL::swapInterval)
++    {
++	(*GL::swapInterval) (sync ? 1 : 0);
++    }
++    else if (sync && GL::getVideoSync && GL::waitVideoSync)
++    {
++	unsigned int frame;
++	(*GL::getVideoSync) (&frame);
++	(*GL::waitVideoSync) (2, (frame + 1) % 2, &frame);
+     }
+ }
+ 
+@@ -1161,7 +1175,8 @@
+ {
+     if (pendingCommands)
+     {
+-	glFinish ();
++	// Flush, don't finish. Finishing blocks the CPU.
++	glFlush ();
+ 	pendingCommands = false;
+     }
+ }
+

=== modified file 'debian/patches/series'
--- debian/patches/series	2011-07-05 09:29:20 +0000
+++ debian/patches/series	2011-07-18 13:09:31 +0000
@@ -8,3 +8,4 @@
 086_new_grid_defaults.patch
 090_run_gtk_init.patch
 091_no_use_gnome_but_desktop_file.patch
+092_fix_slow_vsync_lp763005.patch


Follow ups