From aa0c2157e888f24873a0f1fca396e4fce0f79c84 Mon Sep 17 00:00:00 2001 From: Vaxry Date: Tue, 25 Jun 2024 20:30:00 +0200 Subject: [PATCH] drm: adjust drmfb storage --- include/aquamarine/backend/DRM.hpp | 4 ++-- src/backend/drm/DRM.cpp | 21 +++++++++++++-------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/include/aquamarine/backend/DRM.hpp b/include/aquamarine/backend/DRM.hpp index 2f1f4ae..02dddba 100644 --- a/include/aquamarine/backend/DRM.hpp +++ b/include/aquamarine/backend/DRM.hpp @@ -54,7 +54,7 @@ namespace Aquamarine { struct SDRMLayer { // we expect the consumers to use double-buffering, so we keep the 2 last FBs around. If any of these goes out of // scope, the DRM FB will be destroyed, but the IBuffer will stay, as long as it's ref'd somewhere. - Hyprutils::Memory::CSharedPointer front /* currently displaying */, back; + Hyprutils::Memory::CSharedPointer front /* currently displaying */, back /* submitted */, last /* keep just in case */; Hyprutils::Memory::CWeakPointer backend; }; @@ -65,7 +65,7 @@ namespace Aquamarine { uint32_t id = 0; uint32_t initialID = 0; - Hyprutils::Memory::CSharedPointer front /* currently displaying */, back /* submitted */; + Hyprutils::Memory::CSharedPointer front /* currently displaying */, back /* submitted */, last /* keep just in case */; Hyprutils::Memory::CWeakPointer backend; Hyprutils::Memory::CWeakPointer self; std::vector formats; diff --git a/src/backend/drm/DRM.cpp b/src/backend/drm/DRM.cpp index 7eafd5f..596ce21 100644 --- a/src/backend/drm/DRM.cpp +++ b/src/backend/drm/DRM.cpp @@ -894,12 +894,9 @@ bool Aquamarine::SDRMConnector::commitState(const SDRMConnectorCommitData& data) } void Aquamarine::SDRMConnector::applyCommit(const SDRMConnectorCommitData& data) { - crtc->primary->back = crtc->primary->front; - crtc->primary->front = data.mainFB; - if (crtc->cursor) { - crtc->cursor->back = crtc->cursor->front; - crtc->cursor->front = data.cursorFB; - } + crtc->primary->back = data.mainFB; + if (crtc->cursor) + crtc->cursor->back = data.cursorFB; pendingCursorFB.reset(); @@ -912,7 +909,12 @@ void Aquamarine::SDRMConnector::rollbackCommit(const SDRMConnectorCommitData& da } void Aquamarine::SDRMConnector::onPresent() { - ; + crtc->primary->last = crtc->primary->front; + crtc->primary->front = crtc->primary->back; + if (crtc->cursor) { + crtc->cursor->last = crtc->cursor->front; + crtc->cursor->front = crtc->cursor->back; + } } Aquamarine::CDRMOutput::~CDRMOutput() { @@ -1004,11 +1006,14 @@ bool Aquamarine::CDRMOutput::commitState(bool onlyTest) { auto buf = STATE.buffer; // try to find the buffer in its layer if (connector->crtc->primary->back && connector->crtc->primary->back->buffer == buf) { - backend->backend->log(AQ_LOG_TRACE, "drm: CRTC's back buffer matches committed :D"); + backend->backend->log(AQ_LOG_TRACE, "drm: CRTC's back buffer matches committed"); drmFB = connector->crtc->primary->back; } else if (connector->crtc->primary->front && connector->crtc->primary->front->buffer == buf) { backend->backend->log(AQ_LOG_TRACE, "drm: CRTC's front buffer matches committed"); drmFB = connector->crtc->primary->front; + } else if (connector->crtc->primary->last && connector->crtc->primary->last->buffer == buf) { + backend->backend->log(AQ_LOG_TRACE, "drm: CRTC's last buffer matches committed :D"); // best case scenario and what is expected + drmFB = connector->crtc->primary->last; } if (!drmFB)