diff --git a/plugins/platforms/drm/egl_gbm_backend.cpp b/plugins/platforms/drm/egl_gbm_backend.cpp --- a/plugins/platforms/drm/egl_gbm_backend.cpp +++ b/plugins/platforms/drm/egl_gbm_backend.cpp @@ -258,17 +258,39 @@ 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, blueSize, redSize, greenSize, alphaSize; + // query some configuration parameters, to show in debug log + eglGetConfigAttrib(eglDisplay(), configs[i], EGL_NATIVE_VISUAL_ID, &gbmFormat); + // number of bits for color channel + 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); + + // output debug info + // GBM formats are declared as FOURCC code (integer from ASCII chars, so use this fact) + char gbmFormatStr[8] = {0, 0, 0, 0, 0, 0, 0, 0}; + memcpy(gbmFormatStr, &gbmFormat, sizeof(EGLint)); + qCDebug(KWIN_DRM) << i << "th config GBM format:" << gbmFormatStr + << "; color sizes (RGBA order):" << redSize << greenSize << blueSize << alphaSize; + + if ((gbmFormat == GBM_FORMAT_XRGB8888) || (gbmFormat == GBM_FORMAT_ARGB8888)) { + setConfig(configs[i]); + return true; + } } - setConfig(configs[0]); - return true; + qCCritical(KWIN_DRM) << "choose EGL config did not return a suitable config" << count; + return false; } void EglGbmBackend::present()