diff options
| author | Ikalco <73481042+ikalco@users.noreply.github.com> | 2025-04-30 11:35:25 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-04-30 18:35:25 +0200 |
| commit | 2ee5118d7a4a59d3ccfaed305bfc05c79cea7637 (patch) | |
| tree | 7c113e64071edbc260060df7e60af9c915b3986a /src/protocols | |
| parent | 5d005f11fa218d26ed2cf6ce75cd9aac9c2c00e5 (diff) | |
render: properly release rendered buffers (#9807)
* cleanup eglSync
* properly release buffers in renderer
* add renderingDoneCallback and use it in screencopy
* use static constructor for CEGLSync
Diffstat (limited to 'src/protocols')
| -rw-r--r-- | src/protocols/DRMSyncobj.cpp | 6 | ||||
| -rw-r--r-- | src/protocols/Screencopy.cpp | 18 | ||||
| -rw-r--r-- | src/protocols/core/Compositor.cpp | 10 | ||||
| -rw-r--r-- | src/protocols/types/Buffer.cpp | 16 | ||||
| -rw-r--r-- | src/protocols/types/Buffer.hpp | 8 |
5 files changed, 21 insertions, 37 deletions
diff --git a/src/protocols/DRMSyncobj.cpp b/src/protocols/DRMSyncobj.cpp index 5d04d53f..48a80dcc 100644 --- a/src/protocols/DRMSyncobj.cpp +++ b/src/protocols/DRMSyncobj.cpp @@ -105,10 +105,8 @@ CDRMSyncobjSurfaceResource::CDRMSyncobjSurfaceResource(UP<CWpLinuxDrmSyncobjSurf surface->pending.acquire = pendingAcquire; pendingAcquire = {}; - surface->pending.buffer.release = pendingRelease; - pendingRelease = {}; - - surface->pending.buffer->syncReleaser = surface->pending.buffer.release.createSyncRelease(); + surface->pending.buffer->addReleasePoint(pendingRelease); + pendingRelease = {}; }); } diff --git a/src/protocols/Screencopy.cpp b/src/protocols/Screencopy.cpp index 3862dddd..6727bcf4 100644 --- a/src/protocols/Screencopy.cpp +++ b/src/protocols/Screencopy.cpp @@ -221,21 +221,11 @@ void CScreencopyFrame::copyDmabuf(std::function<void(bool)> callback) { } g_pHyprOpenGL->m_RenderData.blockScreenShader = true; - g_pHyprRenderer->endRender(); - auto explicitOptions = g_pHyprRenderer->getExplicitSyncSettings(pMonitor->output); - if (pMonitor->inTimeline && explicitOptions.explicitEnabled) { - if (pMonitor->inTimeline->addWaiter( - [callback, sync = pMonitor->eglSync]() { - LOGM(TRACE, "Copied frame via dma with explicit sync"); - callback(true); - }, - pMonitor->inTimelinePoint, 0)) - return; - // on explicit sync failure, fallthrough to immediate callback - } - LOGM(TRACE, "Copied frame via dma"); - callback(true); + g_pHyprRenderer->endRender([callback]() { + LOGM(TRACE, "Copied frame via dma"); + callback(true); + }); } bool CScreencopyFrame::copyShm() { diff --git a/src/protocols/core/Compositor.cpp b/src/protocols/core/Compositor.cpp index 23b14dd3..cf28b240 100644 --- a/src/protocols/core/Compositor.cpp +++ b/src/protocols/core/Compositor.cpp @@ -7,7 +7,6 @@ #include "Subcompositor.hpp" #include "../Viewporter.hpp" #include "../../helpers/Monitor.hpp" -#include "../../helpers/sync/SyncReleaser.hpp" #include "../PresentationTime.hpp" #include "../DRMSyncobj.hpp" #include "../types/DMABuffer.hpp" @@ -518,8 +517,7 @@ void CWLSurfaceResource::commitState(SSurfaceState& state) { nullptr); } - // release the buffer if it's synchronous (SHM) as update() has done everything thats needed - // so we can let the app know we're done. + // release the buffer if it's synchronous (SHM) as updateSynchronousTexture() has copied the buffer data to a GPU tex // if it doesn't have a role, we can't release it yet, in case it gets turned into a cursor. if (current.buffer && current.buffer->isSynchronous() && role->role() != SURFACE_ROLE_UNASSIGNED) dropCurrentBuffer(); @@ -572,12 +570,6 @@ void CWLSurfaceResource::presentFeedback(const Time::steady_tp& when, PHLMONITOR else FEEDBACK->presented(); PROTO::presentation->queueData(FEEDBACK); - - if (!pMonitor || !pMonitor->inTimeline || !syncobj) - return; - - // attach explicit sync - g_pHyprRenderer->explicitPresented.emplace_back(self.lock()); } CWLCompositorResource::CWLCompositorResource(SP<CWlCompositor> resource_) : resource(resource_) { diff --git a/src/protocols/types/Buffer.cpp b/src/protocols/types/Buffer.cpp index 22745c06..73155c29 100644 --- a/src/protocols/types/Buffer.cpp +++ b/src/protocols/types/Buffer.cpp @@ -7,6 +7,7 @@ IHLBuffer::~IHLBuffer() { void IHLBuffer::sendRelease() { resource->sendRelease(); + syncReleasers.clear(); } void IHLBuffer::lock() { @@ -18,10 +19,8 @@ void IHLBuffer::unlock() { ASSERT(nLocks >= 0); - if (nLocks == 0) { + if (nLocks == 0) sendRelease(); - syncReleaser.reset(); - } } bool IHLBuffer::locked() { @@ -40,11 +39,17 @@ void IHLBuffer::onBackendRelease(const std::function<void()>& fn) { }); } +void IHLBuffer::addReleasePoint(CDRMSyncPointState& point) { + ASSERT(locked()); + if (point) + syncReleasers.emplace_back(point.createSyncRelease()); +} + CHLBufferReference::CHLBufferReference() : buffer(nullptr) { ; } -CHLBufferReference::CHLBufferReference(const CHLBufferReference& other) : release(other.release), buffer(other.buffer) { +CHLBufferReference::CHLBufferReference(const CHLBufferReference& other) : buffer(other.buffer) { if (buffer) buffer->lock(); } @@ -64,8 +69,7 @@ CHLBufferReference& CHLBufferReference::operator=(const CHLBufferReference& othe other.buffer->lock(); if (buffer) buffer->unlock(); - buffer = other.buffer; - release = other.release; + buffer = other.buffer; return *this; } diff --git a/src/protocols/types/Buffer.hpp b/src/protocols/types/Buffer.hpp index 1bf7583c..e4821ac0 100644 --- a/src/protocols/types/Buffer.hpp +++ b/src/protocols/types/Buffer.hpp @@ -24,11 +24,12 @@ class IHLBuffer : public Aquamarine::IBuffer { virtual bool locked(); void onBackendRelease(const std::function<void()>& fn); + void addReleasePoint(CDRMSyncPointState& point); SP<CTexture> texture; bool opaque = false; SP<CWLBufferResource> resource; - UP<CSyncReleaser> syncReleaser; + std::vector<UP<CSyncReleaser>> syncReleasers; struct { CHyprSignalListener backendRelease; @@ -57,8 +58,7 @@ class CHLBufferReference { operator bool() const; // unlock and drop the buffer without sending release - void drop(); + void drop(); - CDRMSyncPointState release; - SP<IHLBuffer> buffer; + SP<IHLBuffer> buffer; }; |
