From f4d12fb19c2c379842a43a9f58d5df49348e745d Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Sat, 8 Jan 2022 17:11:13 -0800 Subject: [PATCH] Force Mesa to use its own call Mesa does not support adaptive swapping but will sometimes report that it does. This prevents Mesa drivers from testing (and segfaulting) the limits of their call Fixes https://gitlab.com/kicad/code/kicad/issues/10069 (cherry picked from commit 100cf757fe19d031308726c4cec263f3e960d74f) --- include/gl_utils.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/include/gl_utils.h b/include/gl_utils.h index 6a3896fa45..0723558f7b 100644 --- a/include/gl_utils.h +++ b/include/gl_utils.h @@ -47,12 +47,16 @@ public: Display *dpy = glXGetCurrentDisplay(); GLXDrawable drawable = glXGetCurrentDrawable(); + std::string vendor( reinterpret_cast( glGetString( GL_VENDOR ) ) ); + bool is_mesa = ( vendor.find( "Mesa" ) != std::string::npos ); - if( glXSwapIntervalEXT && glXQueryDrawable && dpy && drawable ) + if( !is_mesa && glXSwapIntervalEXT && glXQueryDrawable && dpy && drawable ) { + std::string exts( glXQueryExtensionsString( dpy, DefaultScreen( dpy ) ) ); + if( aVal < 0 ) { - if( !wxGLCanvas::IsExtensionSupported( "GLX_EXT_swap_control_tear" ) ) + if( exts.find( "GLX_EXT_swap_control_tear" ) == std::string::npos ) { aVal = 0; } @@ -62,7 +66,7 @@ public: // we need to be sure that late/adaptive swaps are // enabled on the drawable. - unsigned lateSwapsEnabled; + unsigned lateSwapsEnabled = 0; glXQueryDrawable( dpy, drawable, GLX_LATE_SWAPS_TEAR_EXT, &lateSwapsEnabled ); if( !lateSwapsEnabled )