From 3f7c1be59a06c193ecb54a879e596c5b55a045ee Mon Sep 17 00:00:00 2001 From: Daniel van Vugt Date: Thu, 7 Sep 2023 18:54:18 +0800 Subject: [PATCH] cogl: Remember to bind the GLX context to our drawable before querying Or else `glXQueryDrawable` will fail per the `GLX_EXT_buffer_age` spec: > If querying GLX_BACK_BUFFER_AGE_EXT and is not bound to > the calling thread's current context a GLXBadDrawable error is > generated. This mistake went unnoticed until `mtk_x11_error_trap_push` was introduced (55e3b2e5193) because for some reason it is incapable of trapping `glXQueryDrawable`. Prior to that it seems `cogl_onscreen_glx_get_buffer_age` would trap and so always returned zero. This means we're reenabling clipped redraws on X11 here for the first time in a long time. Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3007 Part-of: --- cogl/cogl/winsys/cogl-onscreen-glx.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cogl/cogl/winsys/cogl-onscreen-glx.c b/cogl/cogl/winsys/cogl-onscreen-glx.c index cc724b3db..10642b2a4 100644 --- a/cogl/cogl/winsys/cogl-onscreen-glx.c +++ b/cogl/cogl/winsys/cogl-onscreen-glx.c @@ -543,6 +543,8 @@ cogl_onscreen_glx_get_buffer_age (CoglOnscreen *onscreen) if (!_cogl_winsys_has_feature (COGL_WINSYS_FEATURE_BUFFER_AGE)) return 0; + cogl_onscreen_bind (onscreen); + drawable = onscreen_glx->glxwin ? onscreen_glx->glxwin : onscreen_glx->xwin; mtk_x11_error_trap_push (xlib_renderer->xdpy); glx_renderer->glXQueryDrawable (xlib_renderer->xdpy, drawable, GLX_BACK_BUFFER_AGE_EXT, &age);