Update debian/patches/sync.patch

This commit is contained in:
ferreo 2025-02-23 15:43:48 +01:00
parent 84ef735568
commit 91754bd944

View File

@ -430,316 +430,4 @@ index a5d3d7c001a..e6e03b99773 100644
return;
}
From e156ace712a9dbe04b9a8759072c92f291507881 Mon Sep 17 00:00:00 2001
From: Tom Englund <tomenglund26@gmail.com>
Date: Sat, 22 Feb 2025 19:52:49 +0100
Subject: [PATCH 2/3] syncobj: lets optimize it further
lets use unique_pointers all over, add defaulted destructors and make
fromResource directly check existing timelines instead of C style
casting and return a WP from that. instead of moving the releasepoint
vector lets swap it.
---
src/protocols/DRMSyncobj.cpp | 31 ++++++++++++++++++-------------
src/protocols/DRMSyncobj.hpp | 22 +++++++++++-----------
src/protocols/core/Compositor.cpp | 2 +-
3 files changed, 30 insertions(+), 25 deletions(-)
diff --git a/src/protocols/DRMSyncobj.cpp b/src/protocols/DRMSyncobj.cpp
index 63f0946b58c..af2fadfaa7d 100644
--- a/src/protocols/DRMSyncobj.cpp
+++ b/src/protocols/DRMSyncobj.cpp
@@ -8,7 +8,8 @@
#include <fcntl.h>
using namespace Hyprutils::OS;
-CDRMSyncobjSurfaceResource::CDRMSyncobjSurfaceResource(SP<CWpLinuxDrmSyncobjSurfaceV1> resource_, SP<CWLSurfaceResource> surface_) : surface(surface_), resource(resource_) {
+CDRMSyncobjSurfaceResource::CDRMSyncobjSurfaceResource(UP<CWpLinuxDrmSyncobjSurfaceV1>&& resource_, SP<CWLSurfaceResource> surface_) :
+ surface(surface_), resource(std::move(resource_)) {
if UNLIKELY (!good())
return;
@@ -107,7 +108,7 @@ bool CDRMSyncobjSurfaceResource::good() {
return resource->resource();
}
-CDRMSyncobjTimelineResource::CDRMSyncobjTimelineResource(SP<CWpLinuxDrmSyncobjTimelineV1> resource_, CFileDescriptor&& fd_) : fd(std::move(fd_)), resource(resource_) {
+CDRMSyncobjTimelineResource::CDRMSyncobjTimelineResource(UP<CWpLinuxDrmSyncobjTimelineV1>&& resource_, CFileDescriptor&& fd_) : fd(std::move(fd_)), resource(std::move(resource_)) {
if UNLIKELY (!good())
return;
@@ -124,16 +125,20 @@ CDRMSyncobjTimelineResource::CDRMSyncobjTimelineResource(SP<CWpLinuxDrmSyncobjTi
}
}
-SP<CDRMSyncobjTimelineResource> CDRMSyncobjTimelineResource::fromResource(wl_resource* res) {
- auto data = (CDRMSyncobjTimelineResource*)(((CWpLinuxDrmSyncobjTimelineV1*)wl_resource_get_user_data(res))->data());
- return data ? data->self.lock() : nullptr;
+WP<CDRMSyncobjTimelineResource> CDRMSyncobjTimelineResource::fromResource(wl_resource* res) {
+ for (const auto& t : PROTO::sync->m_vTimelines) {
+ if (t && t->resource && t->resource->resource() == res)
+ return t;
+ }
+
+ return {};
}
bool CDRMSyncobjTimelineResource::good() {
return resource->resource();
}
-CDRMSyncobjManagerResource::CDRMSyncobjManagerResource(SP<CWpLinuxDrmSyncobjManagerV1> resource_) : resource(resource_) {
+CDRMSyncobjManagerResource::CDRMSyncobjManagerResource(UP<CWpLinuxDrmSyncobjManagerV1>&& resource_) : resource(std::move(resource_)) {
if UNLIKELY (!good())
return;
@@ -157,28 +162,28 @@ CDRMSyncobjManagerResource::CDRMSyncobjManagerResource(SP<CWpLinuxDrmSyncobjMana
return;
}
- auto RESOURCE = makeShared<CDRMSyncobjSurfaceResource>(makeShared<CWpLinuxDrmSyncobjSurfaceV1>(resource->client(), resource->version(), id), SURF);
+ const auto& RESOURCE = PROTO::sync->m_vSurfaces.emplace_back(
+ makeUnique<CDRMSyncobjSurfaceResource>(makeUnique<CWpLinuxDrmSyncobjSurfaceV1>(resource->client(), resource->version(), id), SURF));
if UNLIKELY (!RESOURCE->good()) {
resource->noMemory();
+ PROTO::sync->m_vSurfaces.pop_back();
return;
}
- PROTO::sync->m_vSurfaces.emplace_back(RESOURCE);
SURF->syncobj = RESOURCE;
LOGM(LOG, "New linux_syncobj at {:x} for surface {:x}", (uintptr_t)RESOURCE.get(), (uintptr_t)SURF.get());
});
resource->setImportTimeline([this](CWpLinuxDrmSyncobjManagerV1* r, uint32_t id, int32_t fd) {
- auto RESOURCE = makeShared<CDRMSyncobjTimelineResource>(makeShared<CWpLinuxDrmSyncobjTimelineV1>(resource->client(), resource->version(), id), CFileDescriptor{fd});
+ const auto& RESOURCE = PROTO::sync->m_vTimelines.emplace_back(
+ makeUnique<CDRMSyncobjTimelineResource>(makeUnique<CWpLinuxDrmSyncobjTimelineV1>(resource->client(), resource->version(), id), CFileDescriptor{fd}));
if UNLIKELY (!RESOURCE->good()) {
resource->noMemory();
+ PROTO::sync->m_vTimelines.pop_back();
return;
}
- PROTO::sync->m_vTimelines.emplace_back(RESOURCE);
- RESOURCE->self = RESOURCE;
-
LOGM(LOG, "New linux_drm_timeline at {:x}", (uintptr_t)RESOURCE.get());
});
}
@@ -192,7 +197,7 @@ CDRMSyncobjProtocol::CDRMSyncobjProtocol(const wl_interface* iface, const int& v
}
void CDRMSyncobjProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) {
- const auto RESOURCE = m_vManagers.emplace_back(makeShared<CDRMSyncobjManagerResource>(makeShared<CWpLinuxDrmSyncobjManagerV1>(client, ver, id)));
+ const auto& RESOURCE = m_vManagers.emplace_back(makeUnique<CDRMSyncobjManagerResource>(makeUnique<CWpLinuxDrmSyncobjManagerV1>(client, ver, id)));
if UNLIKELY (!RESOURCE->good()) {
wl_client_post_no_memory(client);
diff --git a/src/protocols/DRMSyncobj.hpp b/src/protocols/DRMSyncobj.hpp
index 06a3def2565..af4ee3567bd 100644
--- a/src/protocols/DRMSyncobj.hpp
+++ b/src/protocols/DRMSyncobj.hpp
@@ -13,7 +13,7 @@ class CSyncTimeline;
class CDRMSyncobjSurfaceResource {
public:
- CDRMSyncobjSurfaceResource(SP<CWpLinuxDrmSyncobjSurfaceV1> resource_, SP<CWLSurfaceResource> surface_);
+ CDRMSyncobjSurfaceResource(UP<CWpLinuxDrmSyncobjSurfaceV1>&& resource_, SP<CWLSurfaceResource> surface_);
~CDRMSyncobjSurfaceResource();
bool good();
@@ -34,7 +34,7 @@ class CDRMSyncobjSurfaceResource {
std::vector<UP<CSyncReleaser>> releasePoints;
private:
- SP<CWpLinuxDrmSyncobjSurfaceV1> resource;
+ UP<CWpLinuxDrmSyncobjSurfaceV1> resource;
bool acquireWaiting = false;
struct {
@@ -45,33 +45,33 @@ class CDRMSyncobjSurfaceResource {
class CDRMSyncobjTimelineResource {
public:
- CDRMSyncobjTimelineResource(SP<CWpLinuxDrmSyncobjTimelineV1> resource_, Hyprutils::OS::CFileDescriptor&& fd_);
+ CDRMSyncobjTimelineResource(UP<CWpLinuxDrmSyncobjTimelineV1>&& resource_, Hyprutils::OS::CFileDescriptor&& fd_);
~CDRMSyncobjTimelineResource() = default;
- static SP<CDRMSyncobjTimelineResource> fromResource(wl_resource*);
+ static WP<CDRMSyncobjTimelineResource> fromResource(wl_resource*);
bool good();
- WP<CDRMSyncobjTimelineResource> self;
Hyprutils::OS::CFileDescriptor fd;
SP<CSyncTimeline> timeline;
private:
- SP<CWpLinuxDrmSyncobjTimelineV1> resource;
+ UP<CWpLinuxDrmSyncobjTimelineV1> resource;
};
class CDRMSyncobjManagerResource {
public:
- CDRMSyncobjManagerResource(SP<CWpLinuxDrmSyncobjManagerV1> resource_);
+ CDRMSyncobjManagerResource(UP<CWpLinuxDrmSyncobjManagerV1>&& resource_);
bool good();
private:
- SP<CWpLinuxDrmSyncobjManagerV1> resource;
+ UP<CWpLinuxDrmSyncobjManagerV1> resource;
};
class CDRMSyncobjProtocol : public IWaylandProtocol {
public:
CDRMSyncobjProtocol(const wl_interface* iface, const int& ver, const std::string& name);
+ ~CDRMSyncobjProtocol() = default;
virtual void bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id);
@@ -81,9 +81,9 @@ class CDRMSyncobjProtocol : public IWaylandProtocol {
void destroyResource(CDRMSyncobjSurfaceResource* resource);
//
- std::vector<SP<CDRMSyncobjManagerResource>> m_vManagers;
- std::vector<SP<CDRMSyncobjTimelineResource>> m_vTimelines;
- std::vector<SP<CDRMSyncobjSurfaceResource>> m_vSurfaces;
+ std::vector<UP<CDRMSyncobjManagerResource>> m_vManagers;
+ std::vector<UP<CDRMSyncobjTimelineResource>> m_vTimelines;
+ std::vector<UP<CDRMSyncobjSurfaceResource>> m_vSurfaces;
//
int drmFD = -1;
diff --git a/src/protocols/core/Compositor.cpp b/src/protocols/core/Compositor.cpp
index 87adaeae1be..0dddf8b42c1 100644
--- a/src/protocols/core/Compositor.cpp
+++ b/src/protocols/core/Compositor.cpp
@@ -434,7 +434,7 @@ void CWLSurfaceResource::commitPendingState() {
events.roleCommit.emit();
if (syncobj && syncobj->release.resource && syncobj->release.resource->timeline && current.buffer && current.buffer->buffer)
- current.buffer->releaser = std::move(syncobj->releasePoints);
+ current.buffer->releaser.swap(syncobj->releasePoints);
if (current.texture)
current.texture->m_eTransform = wlTransformToHyprutils(current.transform);
From 40df1f771c281d11c0b67569bd7a061a3c102994 Mon Sep 17 00:00:00 2001
From: Tom Englund <tomenglund26@gmail.com>
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<SConfigOptionDescription> 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(UP<CWpLinuxDrmSyncobjSurf
});
listeners.surfaceRoleCommit = surface->events.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 <cstring>
class CDefaultSurfaceRole : public ISurfaceRole {
@@ -422,14 +421,12 @@ void CWLSurfaceResource::commitPendingState() {
if (stateLocked && syncobj)
return;
- static auto PDROP = CConfigValue<Hyprlang::INT>("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