Skip to content

Commit f19af6b

Browse files
committed
remove syncReleaser and properly release buffers in renderer
1 parent 059c759 commit f19af6b

File tree

12 files changed

+80
-207
lines changed

12 files changed

+80
-207
lines changed

src/helpers/Monitor.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#include "../macros.hpp"
44
#include "math/Math.hpp"
55
#include "../protocols/ColorManagement.hpp"
6-
#include "sync/SyncReleaser.hpp"
76
#include "../Compositor.hpp"
87
#include "../config/ConfigValue.hpp"
98
#include "../protocols/GammaControl.hpp"

src/helpers/Monitor.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,7 @@ class CMonitor {
140140

141141
// explicit sync
142142
SP<CSyncTimeline> inTimeline;
143-
Hyprutils::OS::CFileDescriptor inFence;
144-
SP<CEGLSync> eglSync;
143+
Hyprutils::OS::CFileDescriptor inFence; // TODO: remove when aq uses CFileDescriptor
145144
uint64_t inTimelinePoint = 0;
146145

147146
PHLMONITORREF self;

src/helpers/sync/SyncReleaser.cpp

Lines changed: 0 additions & 65 deletions
This file was deleted.

src/helpers/sync/SyncReleaser.hpp

Lines changed: 0 additions & 34 deletions
This file was deleted.

src/protocols/DRMSyncobj.cpp

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,27 +19,23 @@ WP<CSyncTimeline> CDRMSyncPointState::timeline() {
1919
return m_timeline;
2020
}
2121

22-
UP<CSyncReleaser> CDRMSyncPointState::createSyncRelease() {
23-
if (m_releaseTaken)
24-
Debug::log(ERR, "CDRMSyncPointState: creating a sync releaser on an already created SyncRelease");
25-
26-
m_releaseTaken = true;
27-
return makeUnique<CSyncReleaser>(m_timeline, m_point);
28-
}
29-
3022
bool CDRMSyncPointState::addWaiter(const std::function<void()>& waiter) {
31-
m_acquireCommitted = true;
3223
return m_timeline->addWaiter(waiter, m_point, 0u);
3324
}
3425

35-
bool CDRMSyncPointState::comitted() {
36-
return m_acquireCommitted;
26+
bool CDRMSyncPointState::syncImported() {
27+
return m_imported;
3728
}
3829

39-
CFileDescriptor CDRMSyncPointState::exportAsFD() {
30+
CFileDescriptor CDRMSyncPointState::exportSyncFD() {
4031
return m_timeline->exportAsSyncFileFD(m_point);
4132
}
4233

34+
bool CDRMSyncPointState::importSyncFD(CFileDescriptor& fd) {
35+
m_imported = true;
36+
return m_timeline->importFromSyncFileFD(m_point, fd);
37+
}
38+
4339
void CDRMSyncPointState::signal() {
4440
m_timeline->signal(m_point);
4541
}
@@ -105,10 +101,8 @@ CDRMSyncobjSurfaceResource::CDRMSyncobjSurfaceResource(UP<CWpLinuxDrmSyncobjSurf
105101
surface->pending.acquire = pendingAcquire;
106102
pendingAcquire = {};
107103

108-
surface->pending.buffer.release = pendingRelease;
109-
pendingRelease = {};
110-
111-
surface->pending.buffer->syncReleaser = surface->pending.buffer.release.createSyncRelease();
104+
surface->pending.buffer->addReleasePoint(pendingRelease);
105+
pendingRelease = {};
112106
});
113107
}
114108

src/protocols/DRMSyncobj.hpp

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
#include <vector>
44
#include "WaylandProtocol.hpp"
5-
#include "../helpers/sync/SyncReleaser.hpp"
65
#include "linux-drm-syncobj-v1.hpp"
76
#include "../helpers/signal/Signal.hpp"
87
#include <hyprutils/os/FileDescriptor.hpp>
@@ -17,23 +16,22 @@ class CDRMSyncPointState {
1716
CDRMSyncPointState(SP<CSyncTimeline> timeline_, uint64_t point_);
1817
~CDRMSyncPointState() = default;
1918

20-
const uint64_t& point();
21-
WP<CSyncTimeline> timeline();
22-
Hyprutils::Memory::CUniquePointer<CSyncReleaser> createSyncRelease();
23-
bool addWaiter(const std::function<void()>& waiter);
24-
bool comitted();
25-
Hyprutils::OS::CFileDescriptor exportAsFD();
26-
void signal();
19+
const uint64_t& point();
20+
WP<CSyncTimeline> timeline();
21+
bool addWaiter(const std::function<void()>& waiter);
22+
bool syncImported();
23+
Hyprutils::OS::CFileDescriptor exportSyncFD();
24+
bool importSyncFD(Hyprutils::OS::CFileDescriptor& fd);
25+
void signal();
2726

2827
operator bool() const {
2928
return m_timeline;
3029
}
3130

3231
private:
33-
SP<CSyncTimeline> m_timeline = {};
34-
uint64_t m_point = 0;
35-
bool m_acquireCommitted = false;
36-
bool m_releaseTaken = false;
32+
SP<CSyncTimeline> m_timeline = {};
33+
uint64_t m_point = 0;
34+
bool m_imported = false;
3735
};
3836

3937
class CDRMSyncobjSurfaceResource {

src/protocols/core/Compositor.cpp

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#include "Subcompositor.hpp"
88
#include "../Viewporter.hpp"
99
#include "../../helpers/Monitor.hpp"
10-
#include "../../helpers/sync/SyncReleaser.hpp"
1110
#include "../PresentationTime.hpp"
1211
#include "../DRMSyncobj.hpp"
1312
#include "../types/DMABuffer.hpp"
@@ -520,8 +519,7 @@ void CWLSurfaceResource::commitState(SSurfaceState& state) {
520519
nullptr);
521520
}
522521

523-
// release the buffer if it's synchronous (SHM) as update() has done everything thats needed
524-
// so we can let the app know we're done.
522+
// release the buffer if it's synchronous (SHM) as updateSynchronousTexture() has copied the buffer data to a GPU tex
525523
// if it doesn't have a role, we can't release it yet, in case it gets turned into a cursor.
526524
if (current.buffer && current.buffer->isSynchronous() && role->role() != SURFACE_ROLE_UNASSIGNED)
527525
dropCurrentBuffer();
@@ -574,12 +572,6 @@ void CWLSurfaceResource::presentFeedback(timespec* when, PHLMONITOR pMonitor, bo
574572
else
575573
FEEDBACK->presented();
576574
PROTO::presentation->queueData(FEEDBACK);
577-
578-
if (!pMonitor || !pMonitor->inTimeline || !syncobj)
579-
return;
580-
581-
// attach explicit sync
582-
g_pHyprRenderer->explicitPresented.emplace_back(self.lock());
583575
}
584576

585577
CWLCompositorResource::CWLCompositorResource(SP<CWlCompositor> resource_) : resource(resource_) {

src/protocols/types/Buffer.cpp

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "Buffer.hpp"
2+
#include "../DRMSyncobj.hpp"
23

34
IHLBuffer::~IHLBuffer() {
45
if (locked() && resource)
@@ -7,6 +8,11 @@ IHLBuffer::~IHLBuffer() {
78

89
void IHLBuffer::sendRelease() {
910
resource->sendRelease();
11+
for (auto& point : releasePoints) {
12+
if (point && !point.syncImported())
13+
point.signal();
14+
}
15+
releasePoints.clear();
1016
}
1117

1218
void IHLBuffer::lock() {
@@ -18,10 +24,8 @@ void IHLBuffer::unlock() {
1824

1925
ASSERT(nLocks >= 0);
2026

21-
if (nLocks == 0) {
27+
if (nLocks == 0)
2228
sendRelease();
23-
syncReleaser.reset();
24-
}
2529
}
2630

2731
bool IHLBuffer::locked() {
@@ -40,11 +44,17 @@ void IHLBuffer::onBackendRelease(const std::function<void()>& fn) {
4044
});
4145
}
4246

47+
void IHLBuffer::addReleasePoint(const CDRMSyncPointState& point) {
48+
ASSERT(locked());
49+
if (point)
50+
releasePoints.emplace_back(point);
51+
}
52+
4353
CHLBufferReference::CHLBufferReference() : buffer(nullptr) {
4454
;
4555
}
4656

47-
CHLBufferReference::CHLBufferReference(const CHLBufferReference& other) : release(other.release), buffer(other.buffer) {
57+
CHLBufferReference::CHLBufferReference(const CHLBufferReference& other) : buffer(other.buffer) {
4858
if (buffer)
4959
buffer->lock();
5060
}
@@ -64,8 +74,7 @@ CHLBufferReference& CHLBufferReference::operator=(const CHLBufferReference& othe
6474
other.buffer->lock();
6575
if (buffer)
6676
buffer->unlock();
67-
buffer = other.buffer;
68-
release = other.release;
77+
buffer = other.buffer;
6978
return *this;
7079
}
7180

src/protocols/types/Buffer.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,12 @@ class IHLBuffer : public Aquamarine::IBuffer {
2424
virtual bool locked();
2525

2626
void onBackendRelease(const std::function<void()>& fn);
27+
void addReleasePoint(const CDRMSyncPointState& point);
2728

2829
SP<CTexture> texture;
2930
bool opaque = false;
3031
SP<CWLBufferResource> resource;
31-
UP<CSyncReleaser> syncReleaser;
32+
std::vector<CDRMSyncPointState> releasePoints;
3233

3334
struct {
3435
CHyprSignalListener backendRelease;
@@ -57,8 +58,7 @@ class CHLBufferReference {
5758
operator bool() const;
5859

5960
// unlock and drop the buffer without sending release
60-
void drop();
61+
void drop();
6162

62-
CDRMSyncPointState release;
63-
SP<IHLBuffer> buffer;
63+
SP<IHLBuffer> buffer;
6464
};

0 commit comments

Comments
 (0)