drm backend: choose correct EGL config with mesa-18
Do not blindly select first EGL config from returned list, but choose the one that matches GBM surfaces, that will be created later. GBM surfaces are created with GBM_FORMAT_XRGB8888 format, so choose the config that matches it. With wrong format EglGbmBackend::resetOutput() will later fail with error EGL_BAD_MATCH. Test Plan: Compile, run startplasmacompositor. Verify that OpenGL compositing is used, either by kwin debug console, or by kwin support information. Reviewers: graesslin, davidedmundson, #kwin, #plasma_on_wayland, bshah Reviewed By: davidedmundson Subscribers: zzag, kwin, #kwin Tags: #kwin, #plasma_on_wayland Differential Revision: https://phabricator.kde.org/D11758
This commit is contained in:
parent
de8e2517e2
commit
0ccecbc427
1 changed files with 31 additions and 7 deletions
|
@ -243,17 +243,41 @@ bool EglGbmBackend::initBufferConfigs()
|
|||
|
||||
EGLint count;
|
||||
EGLConfig configs[1024];
|
||||
if (eglChooseConfig(eglDisplay(), config_attribs, configs, 1, &count) == EGL_FALSE) {
|
||||
if (!eglChooseConfig(eglDisplay(), config_attribs, configs, sizeof(configs)/sizeof(EGLConfig), &count)) {
|
||||
qCCritical(KWIN_DRM) << "choose config failed";
|
||||
return false;
|
||||
}
|
||||
if (count != 1) {
|
||||
qCCritical(KWIN_DRM) << "choose config did not return a config" << count;
|
||||
return false;
|
||||
}
|
||||
setConfig(configs[0]);
|
||||
|
||||
return true;
|
||||
qCDebug(KWIN_DRM) << "EGL buffer configs count:" << count;
|
||||
|
||||
// loop through all configs, chosing the first one that has suitable format
|
||||
for (EGLint i = 0; i < count; i++) {
|
||||
EGLint gbmFormat;
|
||||
// query some configuration parameters, to show in debug log
|
||||
eglGetConfigAttrib(eglDisplay(), configs[i], EGL_NATIVE_VISUAL_ID, &gbmFormat);
|
||||
|
||||
if (KWIN_DRM().isDebugEnabled()) {
|
||||
// GBM formats are declared as FOURCC code (integer from ASCII chars, so use this fact)
|
||||
char gbmFormatStr[sizeof(EGLint) + 1] = {0};
|
||||
memcpy(gbmFormatStr, &gbmFormat, sizeof(EGLint));
|
||||
// query number of bits for color channel
|
||||
EGLint blueSize, redSize, greenSize, alphaSize;
|
||||
eglGetConfigAttrib(eglDisplay(), configs[i], EGL_RED_SIZE, &redSize);
|
||||
eglGetConfigAttrib(eglDisplay(), configs[i], EGL_GREEN_SIZE, &greenSize);
|
||||
eglGetConfigAttrib(eglDisplay(), configs[i], EGL_BLUE_SIZE, &blueSize);
|
||||
eglGetConfigAttrib(eglDisplay(), configs[i], EGL_ALPHA_SIZE, &alphaSize);
|
||||
qCDebug(KWIN_DRM) << " EGL config #" << i << " has GBM FOURCC format:" << gbmFormatStr
|
||||
<< "; color sizes (RGBA order):" << redSize << greenSize << blueSize << alphaSize;
|
||||
}
|
||||
|
||||
if ((gbmFormat == GBM_FORMAT_XRGB8888) || (gbmFormat == GBM_FORMAT_ARGB8888)) {
|
||||
setConfig(configs[i]);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
qCCritical(KWIN_DRM) << "choose EGL config did not return a suitable config" << count;
|
||||
return false;
|
||||
}
|
||||
|
||||
void EglGbmBackend::present()
|
||||
|
|
Loading…
Reference in a new issue