From acaf07c24b348100ca6e011c5ca4531175ab0593 Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Mon, 16 Nov 2020 13:24:23 -0500 Subject: [PATCH] glx: Fix GLX_SGI_video_sync for the no-current-drawable case MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Starting with GL 3.0 it's legal to have no drawable bound to the current context. GLX_SGI_video_sync doesn't take a drawable for an argument so it implicitly operates on... something. NVIDIA's driver throws GLX_BAD_CONTEXT for GetVideoSync, but WaitVideoSync seems to actually wait for the next MSC on the context's screen. We could work around this by internally creating/destroying a GLXWindow for the root window, but for Xwayland there's not necessarily a good answer it can return. Just throw GLX_BAD_CONTEXT for both. Fixes: mesa/mesa#1207 Reviewed-by: Michel Dänzer Part-of: --- src/glx/glxcmds.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/glx/glxcmds.c b/src/glx/glxcmds.c index fcd82bab4a4..7882d606554 100644 --- a/src/glx/glxcmds.c +++ b/src/glx/glxcmds.c @@ -1888,6 +1888,9 @@ glXGetVideoSyncSGI(unsigned int *count) if (!gc->isDirect) return GLX_BAD_CONTEXT; + if (!gc->currentDrawable) + return GLX_BAD_CONTEXT; + psc = GetGLXScreenConfigs(gc->currentDpy, gc->screen); pdraw = GetGLXDRIDrawable(gc->currentDpy, gc->currentDrawable); @@ -1926,6 +1929,9 @@ glXWaitVideoSyncSGI(int divisor, int remainder, unsigned int *count) if (!gc->isDirect) return GLX_BAD_CONTEXT; + if (!gc->currentDrawable) + return GLX_BAD_CONTEXT; + psc = GetGLXScreenConfigs( gc->currentDpy, gc->screen); pdraw = GetGLXDRIDrawable(gc->currentDpy, gc->currentDrawable);