From da3df75a8ce43890bd1b42f69314fff9ca9ffccb Mon Sep 17 00:00:00 2001 From: Yuxuan Shui Date: Sat, 8 Dec 2018 18:15:19 +0000 Subject: [PATCH] Make sure the vsync methods are really available libglvnd seems to return a pointer to a function that does NOTHING for things the backing driver doesn't support. So we check if the extension is actually advertised before using it. Signed-off-by: Yuxuan Shui --- src/compton.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/compton.c b/src/compton.c index 0379ba1..f1dd016 100644 --- a/src/compton.c +++ b/src/compton.c @@ -4485,6 +4485,11 @@ vsync_opengl_init(session_t *ps) { if (!ensure_glx_context(ps)) return false; + if (!glx_hasglxext(ps, "GLX_SGI_video_sync")) { + printf_errf("(): Your driver doesn't support SGI_video_sync, giving up."); + return false; + } + // Get video sync functions if (!ps->psglx->glXGetVideoSyncSGI) ps->psglx->glXGetVideoSyncSGI = (f_GetVideoSync) @@ -4510,6 +4515,11 @@ vsync_opengl_oml_init(session_t *ps) { if (!ensure_glx_context(ps)) return false; + if (!glx_hasglxext(ps, "GLX_OML_sync_control")) { + printf_errf("(): Your driver doesn't support OML_sync_control, giving up."); + return false; + } + // Get video sync functions if (!ps->psglx->glXGetSyncValuesOML) ps->psglx->glXGetSyncValuesOML = (f_GetSyncValuesOML) @@ -4535,6 +4545,11 @@ vsync_opengl_swc_init(session_t *ps) { if (!ensure_glx_context(ps)) return false; + if (!glx_hasglxext(ps, "GLX_SGI_swap_control")) { + printf_errf("(): Your driver doesn't support SGI_swap_control, giving up."); + return false; + } + if (!bkend_use_glx(ps)) { printf_errf("(): I'm afraid glXSwapIntervalSGI wouldn't help if you are " "not using GLX backend. You could try, nonetheless."); @@ -4563,6 +4578,11 @@ vsync_opengl_mswc_init(session_t *ps) { if (!ensure_glx_context(ps)) return false; + if (!glx_hasglxext(ps, "GLX_MESA_swap_control")) { + printf_errf("(): Your driver doesn't support MESA_swap_control, giving up."); + return false; + } + if (!bkend_use_glx(ps)) { printf_errf("(): I'm afraid glXSwapIntervalMESA wouldn't help if you are " "not using GLX backend. You could try, nonetheless.");