diff mbox

[Branch,~glcompbench-dev/glcompbench/trunk] Rev 37: Also check and use GLX_MESA_swap_control (if GL_EXT_swap_control is not present).

Message ID 20110624150047.26723.15283.launchpad@loganberry.canonical.com
State Accepted
Headers show

Commit Message

alexandros.frantzis@linaro.org June 24, 2011, 3 p.m. UTC
------------------------------------------------------------
revno: 37
committer: Alexandros Frantzis <alexandros.frantzis@linaro.org>
branch nick: trunk
timestamp: Fri 2011-06-24 16:31:15 +0300
message:
  Also check and use GLX_MESA_swap_control (if GL_EXT_swap_control is not present).
modified:
  src/composite-canvas-glx.cc


--
lp:glcompbench
https://code.launchpad.net/~glcompbench-dev/glcompbench/trunk

You are subscribed to branch lp:glcompbench.
To unsubscribe from this branch go to https://code.launchpad.net/~glcompbench-dev/glcompbench/trunk/+edit-subscription
diff mbox

Patch

=== modified file 'src/composite-canvas-glx.cc'
--- src/composite-canvas-glx.cc	2011-06-23 09:49:07 +0000
+++ src/composite-canvas-glx.cc	2011-06-24 13:31:15 +0000
@@ -34,6 +34,7 @@ 
 
 PFNGLXBINDTEXIMAGEEXTPROC glXBindTexImageEXT_;
 PFNGLXSWAPINTERVALEXTPROC glXSwapIntervalEXT_;
+PFNGLXSWAPINTERVALMESAPROC glXSwapIntervalMESA_;
 
 bool
 CompositeCanvasGLX::check_glx_version()
@@ -77,15 +78,25 @@ 
         Log::info("** GLX does not support GLX_EXT_texture_from_pixmap!\n");
     }
 
-    /* GLX_EXT_swap_control */
+    /* 
+     * GLX_EXT_swap_control or GL_MESA_swap_control. Note that
+     * GLX_SGI_swap_control is not enough because it doesn't allow 0 as a valid
+     * value (i.e. you can't turn off VSync).
+     */
     if (extString.find("GLX_EXT_swap_control") != std::string::npos) {
         glXSwapIntervalEXT_ =
             reinterpret_cast<PFNGLXSWAPINTERVALEXTPROC>(
                 glXGetProcAddress((const GLubyte *)"glXSwapIntervalEXT"));
     }
-
-    if (!glXSwapIntervalEXT_) {
-        Log::info("** GLX does not support GLX_EXT_swap_control!\n");
+    else if (extString.find("GLX_MESA_swap_control") != std::string::npos) {
+        glXSwapIntervalMESA_ =
+            reinterpret_cast<PFNGLXSWAPINTERVALMESAPROC>(
+                glXGetProcAddress((const GLubyte *)"glXSwapIntervalMESA"));
+    }
+
+
+    if (!glXSwapIntervalEXT_ && !glXSwapIntervalMESA_) {
+        Log::info("** GLX does not support GLX_EXT_swap_control or GLX_MESA_swap_control!\n");
     }
 
     Log::debug("=======================\n");
@@ -172,8 +183,11 @@ 
         return false;
     }
 
-    if (!glXSwapIntervalEXT_ || glXSwapIntervalEXT_(xdpy_, canvas_, 0))
+    if ((!glXSwapIntervalEXT_ || glXSwapIntervalEXT_(xdpy_, canvas_, 0)) &&
+        (!glXSwapIntervalMESA_ || glXSwapIntervalMESA_(0)))
+    {
         Log::info("** Failed to set swap interval. Results may be bounded above by refresh rate.\n");
+    }
 
     use_accel_tfp_ = Options::use_accel_tfp;