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 <draw> 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
(55e3b2e519) 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: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3255>
This commit is contained in:
Daniel van Vugt 2023-09-07 18:54:18 +08:00 committed by Marge Bot
parent b6c7303ee9
commit 3f7c1be59a

View File

@ -543,6 +543,8 @@ cogl_onscreen_glx_get_buffer_age (CoglOnscreen *onscreen)
if (!_cogl_winsys_has_feature (COGL_WINSYS_FEATURE_BUFFER_AGE)) if (!_cogl_winsys_has_feature (COGL_WINSYS_FEATURE_BUFFER_AGE))
return 0; return 0;
cogl_onscreen_bind (onscreen);
drawable = onscreen_glx->glxwin ? onscreen_glx->glxwin : onscreen_glx->xwin; drawable = onscreen_glx->glxwin ? onscreen_glx->glxwin : onscreen_glx->xwin;
mtk_x11_error_trap_push (xlib_renderer->xdpy); mtk_x11_error_trap_push (xlib_renderer->xdpy);
glx_renderer->glXQueryDrawable (xlib_renderer->xdpy, drawable, GLX_BACK_BUFFER_AGE_EXT, &age); glx_renderer->glXQueryDrawable (xlib_renderer->xdpy, drawable, GLX_BACK_BUFFER_AGE_EXT, &age);