From e64f60ce086cf2983e44b2815922c9fdd73e5d2b Mon Sep 17 00:00:00 2001 From: Weng Xuetian Date: Wed, 19 Jan 2022 15:43:09 -0800 Subject: [PATCH] Fix force xrgb 8888 19c471405e7eb4b6026db24d776d205125dbc013 introduced a regression if there are two gbm backend and the backend fail to choose drm format. This fix does two things: 1. Current buffer format should not be reset after create new buffer, otherwise current.format may just be empty after resetOutput. 2. force xrgb 8888 need to be set on the primary backend. BUG: 448790 --- src/backends/drm/egl_gbm_backend.cpp | 8 +++++++- src/backends/drm/egl_gbm_backend.h | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/backends/drm/egl_gbm_backend.cpp b/src/backends/drm/egl_gbm_backend.cpp index 895e7b5a10..c159281ad2 100644 --- a/src/backends/drm/egl_gbm_backend.cpp +++ b/src/backends/drm/egl_gbm_backend.cpp @@ -155,7 +155,6 @@ bool EglGbmBackend::resetOutput(Output &output) qCCritical(KWIN_DRM) << "Could not find a suitable format for output" << output.output; return false; } - output.current.format = gbmFormat.value(); uint32_t format = gbmFormat.value().drmFormat; QVector modifiers = output.output->supportedModifiers(format); const QSize size = output.output->bufferSize(); @@ -193,6 +192,7 @@ bool EglGbmBackend::resetOutput(Output &output) cleanupRenderData(output.old); output.old = output.current; output.current = {}; + output.current.format = gbmFormat.value(); output.current.gbmSurface = gbmSurface; if (!output.output->needsSoftwareTransformation()) { @@ -349,6 +349,7 @@ QSharedPointer EglGbmBackend::importFramebuffer(Output &output, const qCWarning(KWIN_DRM) << "all imports failed on output" << output.output; // try again with XRGB8888, the most universally supported basic format output.forceXrgb8888 = true; + renderingBackend()->setForceXrgb8888(output.output); return nullptr; } @@ -862,6 +863,11 @@ bool EglGbmBackend::prefer10bpc() const return !ok || preferred == 30; } +void EglGbmBackend::setForceXrgb8888(DrmAbstractOutput *output) { + auto &o = m_outputs[output]; + o.forceXrgb8888 = true; +} + bool operator==(const GbmFormat &lhs, const GbmFormat &rhs) { return lhs.drmFormat == rhs.drmFormat; diff --git a/src/backends/drm/egl_gbm_backend.h b/src/backends/drm/egl_gbm_backend.h index f24b57ef10..5b4773e861 100644 --- a/src/backends/drm/egl_gbm_backend.h +++ b/src/backends/drm/egl_gbm_backend.h @@ -141,6 +141,8 @@ private: static EglGbmBackend *renderingBackend(); + void setForceXrgb8888(DrmAbstractOutput *output); + friend class EglGbmTexture; };