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

--HG--
extra : rebase_source : 5ddfc0f94abafc7a1441eea095e546568bc31596
This commit is contained in:
Martin Stransky 2018-08-03 16:20:09 +02:00
parent 68a73fd046
commit 8b68257be5

View File

@ -1012,10 +1012,25 @@ GLContextGLX::FindFBConfigForWindow(Display* display, int screen, Window window,
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);
@ -1025,15 +1040,10 @@ GLContextGLX::FindFBConfigForWindow(Display* display, int screen, Window window,
*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;
}