Bug 1478454 - [Linux/WebRender] Create glxContext with GLX visual chosen at nsWindow::Create(), r?jgilbert
We need to use the same visual for X drawable and glxContext,
otherwise we get BadMatch when we try to make the glxContext current.
The correct glx visual is already configured at nsWindow::Create()
so just use it if it also matches the frame buffer config.
MozReview-Commit-ID: 78IIfiwOnsf
--- a/gfx/gl/GLContextProviderGLX.cpp
+++ b/gfx/gl/GLContextProviderGLX.cpp
@@ -1007,38 +1007,48 @@ GLContextGLX::FindFBConfigForWindow(Disp
const VisualID windowVisualID = XVisualIDFromVisual(windowAttrs.visual);
#ifdef DEBUG
printf("[GLX] window %lx has VisualID 0x%lx\n", window, windowVisualID);
#endif
for (int i = 0; i < numConfigs; i++) {
int visid = X11None;
sGLXLibrary.fGetFBConfigAttrib(display, cfgs[i], LOCAL_GLX_VISUAL_ID, &visid);
- if (!visid) {
- continue;
+ if (visid) {
+ // WebRender compatible GLX visual is configured
+ // at nsWindow::Create() by GLContextGLX::FindVisual(),
+ // just reuse it here.
+ if (windowVisualID == static_cast<VisualID>(visid)) {
+ *out_config = cfgs[i];
+ *out_visid = visid;
+ return true;
+ }
}
- if (aWebRender || sGLXLibrary.IsATI()) {
+ }
+
+ // We don't have a frame buffer visual which matches the GLX visual
+ // from GLContextGLX::FindVisual(). Let's try to find a near one and hope
+ // we're not on NVIDIA (Bug 1478454) as it causes X11 BadMatch error there.
+ for (int i = 0; i < numConfigs; i++) {
+ int visid = X11None;
+ sGLXLibrary.fGetFBConfigAttrib(display, cfgs[i], LOCAL_GLX_VISUAL_ID, &visid);
+ if (visid) {
int depth;
Visual* visual;
FindVisualAndDepth(display, visid, &visual, &depth);
if (depth == windowAttrs.depth &&
AreCompatibleVisuals(windowAttrs.visual, visual)) {
*out_config = cfgs[i];
*out_visid = visid;
return true;
}
- } else {
- if (windowVisualID == static_cast<VisualID>(visid)) {
- *out_config = cfgs[i];
- *out_visid = visid;
- return true;
- }
}
}
+
NS_WARNING("[GLX] Couldn't find a FBConfig matching window visual");
return false;
}
static already_AddRefed<GLContextGLX>
CreateOffscreenPixmapContext(CreateContextFlags flags, const IntSize& size,
const SurfaceCaps& minCaps, nsACString* const out_failureId)
{