From ba3a70e8a804f1a60faef12838fd1d41fa37de3d Mon Sep 17 00:00:00 2001 From: Xaver Hugl Date: Fri, 27 Oct 2023 14:29:39 +0200 Subject: [PATCH] backends/drm: remove m_current It's not needed and just adds overhead --- src/backends/drm/drm_pipeline.cpp | 23 +++++------------------ src/backends/drm/drm_pipeline.h | 4 ---- src/backends/drm/drm_pipeline_legacy.cpp | 3 +-- 3 files changed, 6 insertions(+), 24 deletions(-) diff --git a/src/backends/drm/drm_pipeline.cpp b/src/backends/drm/drm_pipeline.cpp index f4d2669b8a..c24fa31c3a 100644 --- a/src/backends/drm/drm_pipeline.cpp +++ b/src/backends/drm/drm_pipeline.cpp @@ -94,7 +94,7 @@ DrmPipeline::Error DrmPipeline::present() if (m_pending.needsModesetProperties && !prepareAtomicModeset(primaryPlaneUpdate.get())) { return Error::InvalidArguments; } - atomicCommitSuccessful(); + m_next.needsModesetProperties = m_pending.needsModesetProperties = false; m_commitThread->addCommit(std::move(primaryPlaneUpdate)); return Error::None; } else { @@ -168,7 +168,9 @@ DrmPipeline::Error DrmPipeline::commitPipelinesAtomic(const QList qCCritical(KWIN_DRM) << "Atomic modeset commit failed!" << strerror(errno); return errnoToError(); } - std::for_each(pipelines.begin(), pipelines.end(), std::mem_fn(&DrmPipeline::atomicCommitSuccessful)); + for (const auto pipeline : pipelines) { + pipeline->m_next.needsModeset = pipeline->m_pending.needsModeset = false; + } commit->pageFlipped(std::chrono::steady_clock::now().time_since_epoch()); return Error::None; } @@ -375,23 +377,13 @@ DrmPipeline::Error DrmPipeline::errnoToError() } } -void DrmPipeline::atomicCommitSuccessful() -{ - m_pending.needsModeset = false; - m_pending.needsModesetProperties = false; - m_current = m_pending; -} - bool DrmPipeline::updateCursor() { - if (!m_pending.crtc) { + if (needsModeset() || !m_pending.crtc || !m_pending.active) { return false; } // explicitly check for the cursor plane and not for AMS, as we might not always have one if (m_pending.crtc->cursorPlane()) { - if (needsModeset() || !m_current.active) { - return false; - } // test the full state, to take pending commits into account auto fullState = std::make_unique(QList{this}); if (prepareAtomicPresentation(fullState.get()) != Error::None) { @@ -510,11 +502,6 @@ void DrmPipeline::resetModesetPresentPending() m_modesetPresentPending = false; } -DrmCrtc *DrmPipeline::currentCrtc() const -{ - return m_current.crtc; -} - DrmGammaRamp::DrmGammaRamp(DrmCrtc *crtc, const std::shared_ptr &transformation) : m_lut(transformation, crtc->gammaRampSize()) { diff --git a/src/backends/drm/drm_pipeline.h b/src/backends/drm/drm_pipeline.h index 9d34f4807d..e1d03788eb 100644 --- a/src/backends/drm/drm_pipeline.h +++ b/src/backends/drm/drm_pipeline.h @@ -81,7 +81,6 @@ public: bool updateCursor(); DrmConnector *connector() const; - DrmCrtc *currentCrtc() const; DrmGpu *gpu() const; enum class PageflipType { @@ -156,7 +155,6 @@ private: static Error commitPipelinesLegacy(const QList &pipelines, CommitMode mode); // atomic modesetting only - void atomicCommitSuccessful(); Error prepareAtomicCommit(DrmAtomicCommit *commit, CommitMode mode); bool prepareAtomicModeset(DrmAtomicCommit *commit); Error prepareAtomicPresentation(DrmAtomicCommit *commit); @@ -200,8 +198,6 @@ private: State m_pending; // the state that will be applied at the next real atomic commit State m_next; - // the state that is already committed - State m_current; std::unique_ptr m_commitThread; std::shared_ptr m_primaryLayer; diff --git a/src/backends/drm/drm_pipeline_legacy.cpp b/src/backends/drm/drm_pipeline_legacy.cpp index 47dc9b15d7..bede88e9ab 100644 --- a/src/backends/drm/drm_pipeline_legacy.cpp +++ b/src/backends/drm/drm_pipeline_legacy.cpp @@ -83,7 +83,6 @@ DrmPipeline::Error DrmPipeline::commitPipelinesLegacy(const QList } else { for (const auto &pipeline : pipelines) { pipeline->applyPendingChanges(); - pipeline->m_current = pipeline->m_pending; if (mode == CommitMode::CommitModeset && pipeline->activePending()) { pipeline->pageFlipped(std::chrono::steady_clock::now().time_since_epoch(), PageflipType::Normal); } @@ -117,7 +116,7 @@ DrmPipeline::Error DrmPipeline::applyPendingChangesLegacy() if (m_connector->scalingMode.isValid() && m_connector->scalingMode.hasEnum(DrmConnector::ScalingMode::None)) { m_connector->scalingMode.setEnumLegacy(DrmConnector::ScalingMode::None); } - if (m_pending.crtc != m_current.crtc || m_pending.mode != m_current.mode) { + if (m_pending.crtc != m_next.crtc || m_pending.mode != m_next.mode) { Error err = legacyModeset(); if (err != Error::None) { return err;