From 40df1f771c281d11c0b67569bd7a061a3c102994 Mon Sep 17 00:00:00 2001 From: Tom Englund Date: Sat, 22 Feb 2025 20:36:03 +0100 Subject: [PATCH 3/3] syncobj: remove early buffer release remove early buffer release config that previously tried to workaround flickers while it was more of an syncobj issue, it also cant be used since the buffer really is used for release point syncing in the renderer later. and use std::move instead of std::exchange to avoid a local temporar copy being created inside std::exchange. --- src/config/ConfigDescriptions.hpp | 6 ------ src/config/ConfigManager.cpp | 1 - src/protocols/DRMSyncobj.cpp | 12 ++++++++---- src/protocols/core/Compositor.cpp | 17 +++-------------- 4 files changed, 11 insertions(+), 25 deletions(-) diff --git a/src/config/ConfigDescriptions.hpp b/src/config/ConfigDescriptions.hpp index 4e591fa8107..f7e647b2b2f 100644 --- a/src/config/ConfigDescriptions.hpp +++ b/src/config/ConfigDescriptions.hpp @@ -1348,12 +1348,6 @@ inline static const std::vector CONFIG_OPTIONS = { .type = CONFIG_OPTION_INT, .data = SConfigOptionDescription::SRangeData{2, 0, 2}, }, - SConfigOptionDescription{ - .value = "render:allow_early_buffer_release", - .description = "Allow early buffer release event. Fixes stuttering and missing frames for some apps. May cause graphical glitches and memory leaks in others", - .type = CONFIG_OPTION_BOOL, - .data = SConfigOptionDescription::SBoolData{true}, - }, /* * cursor: diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index 9b547ffbb75..277098f5260 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -664,7 +664,6 @@ CConfigManager::CConfigManager() { m_pConfig->addConfigValue("render:expand_undersized_textures", Hyprlang::INT{1}); m_pConfig->addConfigValue("render:xp_mode", Hyprlang::INT{0}); m_pConfig->addConfigValue("render:ctm_animation", Hyprlang::INT{2}); - m_pConfig->addConfigValue("render:allow_early_buffer_release", Hyprlang::INT{1}); m_pConfig->addConfigValue("ecosystem:no_update_news", Hyprlang::INT{0}); m_pConfig->addConfigValue("ecosystem:no_donation_nag", Hyprlang::INT{0}); diff --git a/src/protocols/DRMSyncobj.cpp b/src/protocols/DRMSyncobj.cpp index af2fadfaa7d..0e8b4cb47fe 100644 --- a/src/protocols/DRMSyncobj.cpp +++ b/src/protocols/DRMSyncobj.cpp @@ -88,11 +88,15 @@ CDRMSyncobjSurfaceResource::CDRMSyncobjSurfaceResource(UPevents.roleCommit.registerListener([this](std::any d) { - if (pendingAcquire.resource) - acquire = std::exchange(pendingAcquire, {}); + if (pendingAcquire.resource) { + acquire = std::move(pendingAcquire); + pendingAcquire = {}; + } - if (pendingRelease.resource) - release = std::exchange(pendingRelease, {}); + if (pendingRelease.resource) { + release = std::move(pendingRelease); + pendingRelease = {}; + } }); } diff --git a/src/protocols/core/Compositor.cpp b/src/protocols/core/Compositor.cpp index 0dddf8b42c1..e3297da8a44 100644 --- a/src/protocols/core/Compositor.cpp +++ b/src/protocols/core/Compositor.cpp @@ -11,7 +11,6 @@ #include "../PresentationTime.hpp" #include "../DRMSyncobj.hpp" #include "../../render/Renderer.hpp" -#include "config/ConfigValue.hpp" #include class CDefaultSurfaceRole : public ISurfaceRole { @@ -422,14 +421,12 @@ void CWLSurfaceResource::commitPendingState() { if (stateLocked && syncobj) return; - static auto PDROP = CConfigValue("render:allow_early_buffer_release"); - auto const previousBuffer = current.buffer; - current = pending; + auto const previousBuffer = current.buffer; + current = pending; pending.damage.clear(); pending.bufferDamage.clear(); pending.newBuffer = false; - if (!*PDROP) - dropPendingBuffer(); // at this point current.buffer holds the same SP and we don't use pending anymore + dropPendingBuffer(); // at this point current.buffer holds the same SP and we don't use pending anymore events.roleCommit.emit(); @@ -447,14 +444,6 @@ void CWLSurfaceResource::commitPendingState() { // TODO: don't update the entire texture if (role->role() == SURFACE_ROLE_CURSOR && !DAMAGE.empty()) updateCursorShm(DAMAGE); - - // release the buffer if it's synchronous as update() has done everything thats needed - // so we can let the app know we're done. - // Some clients aren't ready to receive a release this early. Should be fine to release it on the next commitPendingState. - if (current.buffer->buffer->isSynchronous() && *PDROP) { - dropCurrentBuffer(); - dropPendingBuffer(); // at this point current.buffer holds the same SP and we don't use pending anymore - } } // TODO: we should _accumulate_ and not replace above if sync