backends/drm: remove m_current

It's not needed and just adds overhead
This commit is contained in:
Xaver Hugl 2023-10-27 14:29:39 +02:00
parent ff2bc0798f
commit ba3a70e8a8
3 changed files with 6 additions and 24 deletions

View file

@ -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<DrmPipeline *>
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<DrmAtomicCommit>(QList<DrmPipeline *>{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<ColorTransformation> &transformation)
: m_lut(transformation, crtc->gammaRampSize())
{

View file

@ -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<DrmPipeline *> &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<DrmCommitThread> m_commitThread;
std::shared_ptr<DrmPipelineLayer> m_primaryLayer;

View file

@ -83,7 +83,6 @@ DrmPipeline::Error DrmPipeline::commitPipelinesLegacy(const QList<DrmPipeline *>
} 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;