glx: fix querying GLX_FBCONFIG_ID for Window

This commit fixes apps using the following sequence:
1. XCreateWindow(dpy) -> win
2. glXCreateContextAttribsARB(dpy, ...) -> ctx
3. glXMakeCurrent(dpy, win, ctx)
4. glXQueryDrawable(dpy, win, GLX_FBCONFIG_ID, ...)

glXQueryDrawable returned 0 (while correctly returning a valid
GLXFCONFIG_ID for other types of drawables).

This commit adds the same dance as driInferDrawableConfig to get
the GLX visual from the Window, and then the GLXFBCONFIG_ID of
this visual.

This fixes:
* piglit: glx-query-drawable --attr=GLX_FBCONFIG_ID --type=WINDOW
* Maya which uses the config ID from step 4 as an input to
glXChooseFBConfig.

Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14174>
This commit is contained in:
Pierre-Eric Pelloux-Prayer 2021-12-13 15:07:13 +01:00 committed by Marge Bot
parent 6c5b3c6bb5
commit 1cb5c1775b
15 changed files with 41 additions and 16 deletions

View file

@ -1,7 +1,6 @@
glx@glx-make-current,Crash
glx@glx-multi-window-single-context,Fail
glx@glx-multithread-buffer,Fail
glx@glx-query-drawable-glx_fbconfig_id-window,Fail
glx@glx-swap-pixmap-bad,Fail
glx@glx-visuals-depth -pixmap,Crash
glx@glx-visuals-stencil -pixmap,Crash

View file

@ -420,7 +420,6 @@ glx@glx-copy-sub-buffer samples=2,Crash
glx@glx-copy-sub-buffer samples=4,Crash
glx@glx-make-current,Crash
glx@glx-multithread-buffer,Fail
glx@glx-query-drawable-glx_fbconfig_id-window,Fail
glx@glx-swap-pixmap-bad,Fail
glx@glx-visuals-depth -pixmap,Crash
glx@glx-visuals-depth,Crash

View file

@ -161,7 +161,6 @@ spec@glsl-1.30@execution@interpolation@interpolation-noperspective-other-smooth-
glx@glx-make-current,Crash
glx@glx-multi-window-single-context,Fail
glx@glx-query-drawable-glx_fbconfig_id-window,Fail
glx@glx-swap-pixmap-bad,Fail
glx@glx-visuals-depth -pixmap,Crash
glx@glx-visuals-stencil -pixmap,Crash

View file

@ -133,7 +133,6 @@ KHR-GLES3.packed_pixels.varied_rectangle.rgba32ui,Fail
glx@glx-make-current,Crash
glx@glx-multi-window-single-context,Fail
glx@glx-query-drawable-glx_fbconfig_id-window,Fail
glx@glx-swap-pixmap-bad,Fail
glx@glx-visuals-depth -pixmap,Crash
glx@glx-visuals-stencil -pixmap,Crash

View file

@ -59,7 +59,6 @@ glx@glx_ext_import_context@make current- single process,Fail
glx@glx_ext_import_context@query context info,Fail
glx@glx-make-current,Crash
glx@glx-multi-window-single-context,Fail
glx@glx-query-drawable-glx_fbconfig_id-window,Fail
glx@glx-swap-pixmap-bad,Fail
glx@glx-visuals-depth -pixmap,Crash
glx@glx-visuals-stencil -pixmap,Crash

View file

@ -54,9 +54,6 @@ glx@glx-make-current,Crash
glx@glx-multi-window-single-context,Fail
# error: no fbconfig id returned
glx@glx-query-drawable-glx_fbconfig_id-window,Fail
glx@glx-swap-pixmap-bad,Fail
# failed to create drawable

View file

@ -14,7 +14,6 @@ glx/glx-multithread-makecurrent-2: skip
glx/glx-multithread-makecurrent-3: skip
glx/glx-multithread-makecurrent-4: skip
glx/glx-multithread-texture: fail
glx/glx-query-drawable-glx_fbconfig_id-window: fail
glx/glx-swap-copy: fail
glx/glx-swap-event_async: skip
glx/glx-swap-event_event: skip

View file

@ -1,6 +1,5 @@
glx@glx-make-current,Crash
glx@glx-multi-window-single-context,Fail
glx@glx-query-drawable-glx_fbconfig_id-window,Fail
glx@glx-visuals-depth -pixmap,Crash
glx@glx-visuals-stencil -pixmap,Crash
glx@glx_arb_create_context_es2_profile@invalid opengl es version,Fail

1 glx@glx-make-current Crash
2 glx@glx-multi-window-single-context Fail
glx@glx-query-drawable-glx_fbconfig_id-window Fail
3 glx@glx-visuals-depth -pixmap Crash
4 glx@glx-visuals-stencil -pixmap Crash
5 glx@glx_arb_create_context_es2_profile@invalid opengl es version Fail

View file

@ -1,6 +1,5 @@
glx@glx-make-current,Crash
glx@glx-multi-window-single-context,Fail
glx@glx-query-drawable-glx_fbconfig_id-window,Fail
glx@glx-visuals-depth -pixmap,Crash
glx@glx-visuals-stencil -pixmap,Crash
glx@glx_arb_create_context_es2_profile@invalid opengl es version,Fail

1 glx@glx-make-current Crash
2 glx@glx-multi-window-single-context Fail
glx@glx-query-drawable-glx_fbconfig_id-window Fail
3 glx@glx-visuals-depth -pixmap Crash
4 glx@glx-visuals-stencil -pixmap Crash
5 glx@glx_arb_create_context_es2_profile@invalid opengl es version Fail

View file

@ -1,6 +1,5 @@
glx@glx-make-current,Crash
glx@glx-multi-window-single-context,Fail
glx@glx-query-drawable-glx_fbconfig_id-window,Fail
glx@glx-visuals-depth -pixmap,Crash
glx@glx-visuals-stencil -pixmap,Crash
glx@glx_arb_create_context_es2_profile@invalid opengl es version,Fail

1 glx@glx-make-current Crash
2 glx@glx-multi-window-single-context Fail
glx@glx-query-drawable-glx_fbconfig_id-window Fail
3 glx@glx-visuals-depth -pixmap Crash
4 glx@glx-visuals-stencil -pixmap Crash
5 glx@glx_arb_create_context_es2_profile@invalid opengl es version Fail

View file

@ -16,7 +16,6 @@ glx/glx-multithread-makecurrent-1: skip
glx/glx-multithread-makecurrent-2: skip
glx/glx-multithread-makecurrent-3: skip
glx/glx-multithread-makecurrent-4: skip
glx/glx-query-drawable-glx_fbconfig_id-window: fail
glx/glx-swap-copy: fail
glx/glx-swap-event_async: skip
glx/glx-swap-event_event: skip

View file

@ -91,7 +91,6 @@ glx@glx-visuals-depth,Crash
glx@glx-visuals-depth -pixmap,Crash
glx@glx-visuals-stencil,Crash
glx@glx-visuals-stencil -pixmap,Crash
glx@glx-query-drawable-glx_fbconfig_id-window,Fail
glx@glx_arb_create_context_es2_profile@invalid opengl es version,Fail
glx@glx_arb_create_context_no_error@no error,Fail
glx@glx_ext_import_context@free context,Fail

View file

@ -656,7 +656,6 @@ glx@glx_ext_import_context@make current- single process,Fail
glx@glx_ext_import_context@query context info,Fail
glx@glx-make-current,Crash
glx@glx-multi-window-single-context,Fail
glx@glx-query-drawable-glx_fbconfig_id-window,Fail
glx@glx-swap-copy,Fail
glx@glx-swap-pixmap-bad,Fail
glx@glx-visuals-depth,Crash

View file

@ -38,6 +38,9 @@
#include <limits.h>
#include "glxextensions.h"
#include <X11/Xlib-xcb.h>
#include <xcb/xproto.h>
#ifdef GLX_USE_APPLEGL
#include <pthread.h>
#include "apple/apple_glx_drawable.h"
@ -387,6 +390,44 @@ __glXGetDrawableAttribute(Display * dpy, GLXDrawable drawable,
UnlockDisplay(dpy);
SyncHandle();
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
if (pdraw && attribute == GLX_FBCONFIG_ID && !found && priv && priv->screens != NULL) {
/* If we failed to lookup the GLX_FBCONFIG_ID, it may be because the drawable is
* a bare Window, so try differently by first figure out its visual, then GLX
* visual like driInferDrawableConfig does.
*/
xcb_get_window_attributes_cookie_t cookie = { 0 };
xcb_get_window_attributes_reply_t *attr = NULL;
xcb_connection_t *conn = XGetXCBConnection(dpy);
if (conn) {
cookie = xcb_get_window_attributes(conn, drawable);
attr = xcb_get_window_attributes_reply(conn, cookie, NULL);
if (attr) {
/* Find the Window's GLX Visual */
struct glx_config *conf = glx_config_find_visual(pdraw->psc->visuals, attr->visual);
free(attr);
if (conf && conf->screen >= 0 && conf->screen < ScreenCount(dpy)) {
/* Then find the GLXFBConfig of the GLX Visual */
struct glx_config *c;
for (c = priv->screens[conf->screen]->configs; c != NULL;
c = c->next) {
if (!c->visualID)
continue;
if (c->visualID == conf->visualID) {
*value = c->fbconfigID;
found = 1;
break;
}
}
}
}
}
}
#endif
return found;
}

View file

@ -13,7 +13,6 @@ glx@glx_ext_import_context@query context info,Fail
glx@glx-make-current,Crash
glx@glx-multithread-clearbuffer,Crash
glx@glx-multi-window-single-context,Fail
glx@glx-query-drawable-glx_fbconfig_id-window,Fail
glx@glx-swap-pixmap-bad,Fail
glx@glx-visuals-depth -pixmap,Crash
glx@glx-visuals-stencil -pixmap,Crash