From 0670631a12f659aa3a7927af7ed70158594e3f95 Mon Sep 17 00:00:00 2001 From: Xaver Hugl Date: Thu, 5 Sep 2024 16:20:12 +0200 Subject: [PATCH] backends/drm: when presentation with tearing+vrr fails, retry first with vrr only Tearing may not always work, and currently is guaranteed to not work when we try to enable VRR at the same time. VRR without tearing may still work though, so this commit makes KWin fall back to VRR-only presentation before giving up and using the basic vsync presentation mode instead. --- src/backends/drm/drm_output.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/backends/drm/drm_output.cpp b/src/backends/drm/drm_output.cpp index b2f84daff4..7c604c3a68 100644 --- a/src/backends/drm/drm_output.cpp +++ b/src/backends/drm/drm_output.cpp @@ -306,8 +306,13 @@ bool DrmOutput::present(const std::shared_ptr &frame) } else { m_pipeline->setPresentationMode(frame->presentationMode()); DrmPipeline::Error err = m_pipeline->present(frame); + if (err != DrmPipeline::Error::None && frame->presentationMode() == PresentationMode::AdaptiveAsync) { + // tearing can fail in various circumstances, but vrr shouldn't + m_pipeline->setPresentationMode(PresentationMode::AdaptiveSync); + err = m_pipeline->present(frame); + } if (err != DrmPipeline::Error::None && frame->presentationMode() != PresentationMode::VSync) { - // retry with a more basic presentation mode + // retry with the most basic presentation mode m_pipeline->setPresentationMode(PresentationMode::VSync); err = m_pipeline->present(frame); }