From 52c1155b26ba8bf21a1955a3846c4f2553558c29 Mon Sep 17 00:00:00 2001 From: Xaver Hugl Date: Fri, 8 Apr 2022 17:37:48 +0200 Subject: [PATCH] backends/drm: prevent calling frameFailed multiple times per present --- src/backends/drm/drm_output.cpp | 7 ++++--- src/backends/drm/drm_pipeline.cpp | 10 ++++++---- src/backends/drm/drm_pipeline.h | 1 + 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/backends/drm/drm_output.cpp b/src/backends/drm/drm_output.cpp index 5a9243a662..48f60e77ef 100644 --- a/src/backends/drm/drm_output.cpp +++ b/src/backends/drm/drm_output.cpp @@ -320,14 +320,15 @@ bool DrmOutput::present() setVrrPolicy(RenderLoop::VrrPolicy::Never); } } - if (m_pipeline->present()) { + bool modeset = gpu()->needsModeset(); + if (modeset ? m_pipeline->maybeModeset() : m_pipeline->present()) { Q_EMIT outputChange(m_pipeline->pending.layer->currentDamage()); return true; - } else { + } else if (!modeset) { qCWarning(KWIN_DRM) << "Presentation failed!" << strerror(errno); frameFailed(); - return false; } + return false; } int DrmOutput::gammaRampSize() const diff --git a/src/backends/drm/drm_pipeline.cpp b/src/backends/drm/drm_pipeline.cpp index 4c4bff5d71..fc314c663b 100644 --- a/src/backends/drm/drm_pipeline.cpp +++ b/src/backends/drm/drm_pipeline.cpp @@ -61,10 +61,6 @@ bool DrmPipeline::testScanout() bool DrmPipeline::present() { Q_ASSERT(pending.crtc); - if (gpu()->needsModeset()) { - m_modesetPresentPending = true; - return gpu()->maybeModeset(); - } if (gpu()->atomicModeSetting()) { return commitPipelines({this}, CommitMode::Commit); } else { @@ -79,6 +75,12 @@ bool DrmPipeline::present() return true; } +bool DrmPipeline::maybeModeset() +{ + m_modesetPresentPending = true; + return gpu()->maybeModeset(); +} + bool DrmPipeline::commitPipelines(const QVector &pipelines, CommitMode mode, const QVector &unusedObjects) { Q_ASSERT(!pipelines.isEmpty()); diff --git a/src/backends/drm/drm_pipeline.h b/src/backends/drm/drm_pipeline.h index 7f2065d752..11783de44a 100644 --- a/src/backends/drm/drm_pipeline.h +++ b/src/backends/drm/drm_pipeline.h @@ -63,6 +63,7 @@ public: */ bool present(); bool testScanout(); + bool maybeModeset(); bool needsModeset() const; void applyPendingChanges();