Commit d318cb3b authored by Alexey Min's avatar Alexey Min
Browse files

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:
parent b35939c9
......@@ -258,17 +258,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;
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)) {
return true;
return true;
qCCritical(KWIN_DRM) << "choose EGL config did not return a suitable config" << count;
return false;
void EglGbmBackend::present()
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment