diff mbox

[Branch,~glmark2-dev/glmark2/trunk] Rev 249: CanvasX11GLX: Updates to handle the API change for GLX_EXT_swap_control

Message ID 20120823225015.31647.59557.launchpad@ackee.canonical.com
State Accepted
Headers show

Commit Message

Jesse Barker Aug. 23, 2012, 10:50 p.m. UTC
------------------------------------------------------------
revno: 249
committer: Jesse Barker <jesse.barker@linaro.org>
branch nick: trunk
timestamp: Thu 2012-08-23 15:47:12 -0700
message:
  CanvasX11GLX: Updates to handle the API change for GLX_EXT_swap_control
  (The spec always had a void return value for glXSwapIntervalEXT, however, the
  original example and protocol had a return value of int.  To make matters worse,
  the header files in mesa were updated a year after the spec.).  Also, make the
  GLX_MESA_swap_control initialization match the new logic for GLX_EXT_swap_control.
modified:
  src/canvas-x11-glx.cpp


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

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

Patch

=== modified file 'src/canvas-x11-glx.cpp'
--- src/canvas-x11-glx.cpp	2012-05-11 13:53:08 +0000
+++ src/canvas-x11-glx.cpp	2012-08-23 22:47:12 +0000
@@ -28,6 +28,7 @@ 
 
 static PFNGLXSWAPINTERVALEXTPROC glXSwapIntervalEXT_;
 static PFNGLXSWAPINTERVALMESAPROC glXSwapIntervalMESA_;
+static PFNGLXGETSWAPINTERVALMESAPROC glXGetSwapIntervalMESA_;
 
 /*********************
  * Protected methods *
@@ -60,11 +61,23 @@ 
         return false;
     }
 
-    if ((!glXSwapIntervalEXT_ || glXSwapIntervalEXT_(xdpy_, xwin_, 0)) &&
-        (!glXSwapIntervalMESA_ || glXSwapIntervalMESA_(0)))
-    {
-        Log::info("** Failed to set swap interval. Results may be bounded above by refresh rate.\n");
-    }
+    unsigned int desired_swap(0);
+    unsigned int actual_swap(-1);
+    if (glXSwapIntervalEXT_) {
+        glXSwapIntervalEXT_(xdpy_, xwin_, desired_swap);
+        glXQueryDrawable(xdpy_, xwin_, GLX_SWAP_INTERVAL_EXT, &actual_swap);
+        if (actual_swap == desired_swap)
+            return true;
+    }
+
+    if (glXSwapIntervalMESA_) {
+        glXSwapIntervalMESA_(desired_swap);
+        actual_swap = glXGetSwapIntervalMESA_();
+        if (actual_swap == desired_swap)
+            return true;
+    }
+
+    Log::info("** Failed to set swap interval. Results may be bounded above by refresh rate.\n");
 
     return true;
 }
@@ -131,6 +144,12 @@ 
                     reinterpret_cast<const GLubyte *>("glXSwapIntervalMESA")
                 )
             );
+        glXGetSwapIntervalMESA_ =
+            reinterpret_cast<PFNGLXGETSWAPINTERVALMESAPROC>(
+                glXGetProcAddress(
+                    reinterpret_cast<const GLubyte *>("glXGetSwapIntervalMESA")
+                )
+            );
     }