From 7fb4becf986872268af4ba3f62c0a85b41ef7e5d Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 6 Jul 2009 11:36:17 -0700 Subject: demos: Fix vsync checking in glxgears Of course glXGetVideoSyncSGI doesn't return the swap interval. The feature only exists in the Mesa extension... which is the whole reason I created the Mesa extension! Note that the Mesa extension allows drivers to default to a swap interval of 0. If the Mesa extension exists, use its value. Only consider the SGI extension when the Mesa extension is not available. Fixes bug #22604. --- progs/xdemos/glxgears.c | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) (limited to 'progs/xdemos') diff --git a/progs/xdemos/glxgears.c b/progs/xdemos/glxgears.c index 2dc157a..bc84ee3 100644 --- a/progs/xdemos/glxgears.c +++ b/progs/xdemos/glxgears.c @@ -39,6 +39,12 @@ #include #include +#ifndef GLX_MESA_swap_control +#define GLX_MESA_swap_control 1 +typedef int (*PFNGLXGETSWAPINTERVALMESAPROC)(void); +#endif + + static int is_glx_extension_supported(Display *dpy, const char *query); static void query_vsync(Display *dpy); @@ -592,31 +598,22 @@ query_vsync(Display *dpy) int interval = 0; -#ifdef GLX_MESA_swap_control - if ((interval <= 0) - && is_glx_extension_supported(dpy, "GLX_MESA_swap_control")) { + if (is_glx_extension_supported(dpy, "GLX_MESA_swap_control")) { PFNGLXGETSWAPINTERVALMESAPROC pglXGetSwapIntervalMESA = (PFNGLXGETSWAPINTERVALMESAPROC) glXGetProcAddressARB((const GLubyte *) "glXGetSwapIntervalMESA"); interval = (*pglXGetSwapIntervalMESA)(); + } else if (is_glx_extension_supported(dpy, "GLX_SGI_swap_control")) { + /* The default swap interval with this extension is 1. Assume that it + * is set to the default. + * + * Many Mesa-based drivers default to 0, but all of these drivers also + * export GLX_MESA_swap_control. In that case, this branch will never + * be taken, and the correct result should be reported. + */ + interval = 1; } -#endif - - -#ifdef GLX_SGI_video_sync - if ((interval <= 0) - && is_glx_extension_supported(dpy, "GLX_SGI_video_sync")) { - PFNGLXGETVIDEOSYNCSGIPROC pglXGetVideoSyncSGI = - (PFNGLXGETVIDEOSYNCSGIPROC) - glXGetProcAddressARB((const GLubyte *) "glXGetVideoSyncSGI"); - unsigned count; - - if ((*pglXGetVideoSyncSGI)(& count) == 0) { - interval = (int) count; - } - } -#endif if (interval > 0) { -- cgit v1.1