From 20d5f9bc6e8ae68a2272f322ef9109b18bede8ff Mon Sep 17 00:00:00 2001 From: Xaver Hugl Date: Mon, 22 Apr 2024 17:21:19 +0200 Subject: [PATCH] backends/drm: work around amdgpu bugs with DCC modifiers See https://gitlab.freedesktop.org/mesa/mesa/-/issues/10875 for details. The workaround can be disabled again with the KWIN_DRM_NO_DCC_WORKAROUND=1 environment variable --- src/backends/drm/drm_egl_layer_surface.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/backends/drm/drm_egl_layer_surface.cpp b/src/backends/drm/drm_egl_layer_surface.cpp index b211a859a4..6f231325a7 100644 --- a/src/backends/drm/drm_egl_layer_surface.cpp +++ b/src/backends/drm/drm_egl_layer_surface.cpp @@ -132,7 +132,15 @@ std::optional EglGbmLayerSurface::startRendering(cons if (requireAlpha && info->alphaBits == 0) { continue; } - m_surface->shadowSwapchain = EglSwapchain::create(m_eglBackend->drmDevice()->allocator(), m_eglBackend->openglContext(), m_surface->gbmSwapchain->size(), it.key(), it.value()); + auto mods = it.value(); + if (m_eglBackend->gpu()->isAmdgpu() && qEnvironmentVariableIntValue("KWIN_DRM_NO_DCC_WORKAROUND") == 0) { + // using modifiers with DCC here causes glitches on amdgpu: https://gitlab.freedesktop.org/mesa/mesa/-/issues/10875 + if (!mods.contains(DRM_FORMAT_MOD_LINEAR)) { + continue; + } + mods = {DRM_FORMAT_MOD_LINEAR}; + } + m_surface->shadowSwapchain = EglSwapchain::create(m_eglBackend->drmDevice()->allocator(), m_eglBackend->openglContext(), m_surface->gbmSwapchain->size(), it.key(), mods); if (m_surface->shadowSwapchain) { break; }