aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorVaxry <[email protected]>2024-08-02 15:12:05 +0200
committerVaxry <[email protected]>2024-08-03 18:23:44 +0200
commit4a555deae199b4abd965c6a043bd22517c6e10bd (patch)
tree169030556b7abbd1ed3d6940446ce865c8a0c279
parent4bc2df6ea3de8e456e75d0ace42f12b918629883 (diff)
downloadHyprland-4a555deae199b4abd965c6a043bd22517c6e10bd.tar.gz
Hyprland-4a555deae199b4abd965c6a043bd22517c6e10bd.zip
stuf
-rw-r--r--src/helpers/Monitor.cpp17
-rw-r--r--src/protocols/types/Buffer.cpp25
-rw-r--r--src/protocols/types/Buffer.hpp7
-rw-r--r--src/protocols/types/WLBuffer.cpp4
-rw-r--r--src/protocols/types/WLBuffer.hpp1
-rw-r--r--src/render/Renderer.hpp1
6 files changed, 21 insertions, 34 deletions
diff --git a/src/helpers/Monitor.cpp b/src/helpers/Monitor.cpp
index f2a73d1f..cdadd1cd 100644
--- a/src/helpers/Monitor.cpp
+++ b/src/helpers/Monitor.cpp
@@ -8,6 +8,7 @@
#include "../protocols/LayerShell.hpp"
#include "../protocols/PresentationTime.hpp"
#include "../protocols/DRMLease.hpp"
+#include "../protocols/DRMSyncobj.hpp"
#include "../protocols/core/Output.hpp"
#include "../managers/PointerManager.hpp"
#include "../protocols/core/Compositor.hpp"
@@ -817,6 +818,11 @@ bool CMonitor::attemptDirectScanout() {
if (!state.test())
return false;
+ // wait for the implicit fence if present
+ const bool DOEXPLICIT = PSURFACE->syncobj && PSURFACE->syncobj->acquireTimeline && PSURFACE->syncobj->acquireTimeline->timeline;
+ if (DOEXPLICIT)
+ g_pHyprOpenGL->waitForTimelinePoint(PSURFACE->syncobj->acquireTimeline->timeline, PSURFACE->syncobj->acquirePoint);
+
timespec now;
clock_gettime(CLOCK_MONOTONIC, &now);
Debug::log(TRACE, "presentFeedback for DS");
@@ -824,11 +830,20 @@ bool CMonitor::attemptDirectScanout() {
output->state->addDamage(CBox{{}, vecPixelSize});
- if (state.commit()) {
+ if (output->commit()) {
if (lastScanout.expired()) {
lastScanout = PCANDIDATE;
Debug::log(LOG, "Entered a direct scanout to {:x}: \"{}\"", (uintptr_t)PCANDIDATE.get(), PCANDIDATE->m_szTitle);
}
+
+ // delay explicit sync feedback until kms release of the buffer
+ if (DOEXPLICIT) {
+ PSURFACE->current.buffer->buffer->hlEvents.backendRelease2 = PSURFACE->current.buffer->buffer->events.backendRelease.registerListener([PSURFACE](std::any d) {
+ const bool DOEXPLICIT = PSURFACE->syncobj && PSURFACE->syncobj->releaseTimeline && PSURFACE->syncobj->releaseTimeline->timeline;
+ if (DOEXPLICIT)
+ PSURFACE->syncobj->releaseTimeline->timeline->signal(PSURFACE->syncobj->releasePoint);
+ });
+ }
} else {
lastScanout.reset();
return false;
diff --git a/src/protocols/types/Buffer.cpp b/src/protocols/types/Buffer.cpp
index 40f2eaf8..ea12f017 100644
--- a/src/protocols/types/Buffer.cpp
+++ b/src/protocols/types/Buffer.cpp
@@ -9,11 +9,6 @@ void IHLBuffer::sendRelease() {
resource->sendRelease();
}
-void IHLBuffer::sendReleaseWithSurface(SP<CWLSurfaceResource> surf) {
- if (resource && resource->good())
- resource->sendReleaseWithSurface(surf);
-}
-
void IHLBuffer::lock() {
nLocks++;
}
@@ -27,26 +22,13 @@ void IHLBuffer::unlock() {
sendRelease();
}
-void IHLBuffer::unlockWithSurface(SP<CWLSurfaceResource> surf) {
- nLocks--;
-
- ASSERT(nLocks >= 0);
-
- if (nLocks == 0)
- sendReleaseWithSurface(surf);
-}
-
bool IHLBuffer::locked() {
return nLocks > 0;
}
void IHLBuffer::unlockOnBufferRelease(WP<CWLSurfaceResource> surf) {
- unlockSurface = surf;
hlEvents.backendRelease = events.backendRelease.registerListener([this](std::any data) {
- if (unlockSurface.expired())
- unlock();
- else
- unlockWithSurface(unlockSurface.lock());
+ unlock();
hlEvents.backendRelease.reset();
});
}
@@ -59,8 +41,5 @@ CHLBufferReference::~CHLBufferReference() {
if (buffer.expired())
return;
- if (surface)
- buffer->unlockWithSurface(surface.lock());
- else
- buffer->unlock();
+ buffer->unlock();
}
diff --git a/src/protocols/types/Buffer.hpp b/src/protocols/types/Buffer.hpp
index d2157181..2f7711cb 100644
--- a/src/protocols/types/Buffer.hpp
+++ b/src/protocols/types/Buffer.hpp
@@ -15,10 +15,8 @@ class IHLBuffer : public Aquamarine::IBuffer {
virtual bool isSynchronous() = 0; // whether the updates to this buffer are synchronous, aka happen over cpu
virtual bool good() = 0;
virtual void sendRelease();
- virtual void sendReleaseWithSurface(SP<CWLSurfaceResource>);
virtual void lock();
virtual void unlock();
- virtual void unlockWithSurface(SP<CWLSurfaceResource> surf);
virtual bool locked();
void unlockOnBufferRelease(WP<CWLSurfaceResource> surf /* optional */);
@@ -29,12 +27,11 @@ class IHLBuffer : public Aquamarine::IBuffer {
struct {
CHyprSignalListener backendRelease;
+ CHyprSignalListener backendRelease2; // for explicit ds
} hlEvents;
private:
- int nLocks = 0;
-
- WP<CWLSurfaceResource> unlockSurface;
+ int nLocks = 0;
};
// for ref-counting. Releases in ~dtor
diff --git a/src/protocols/types/WLBuffer.cpp b/src/protocols/types/WLBuffer.cpp
index 1a991943..eb7d1fde 100644
--- a/src/protocols/types/WLBuffer.cpp
+++ b/src/protocols/types/WLBuffer.cpp
@@ -32,10 +32,6 @@ void CWLBufferResource::sendRelease() {
resource->sendRelease();
}
-void CWLBufferResource::sendReleaseWithSurface(SP<CWLSurfaceResource> surf) {
- sendRelease();
-}
-
wl_resource* CWLBufferResource::getResource() {
return resource->resource();
}
diff --git a/src/protocols/types/WLBuffer.hpp b/src/protocols/types/WLBuffer.hpp
index 59512128..787abe1f 100644
--- a/src/protocols/types/WLBuffer.hpp
+++ b/src/protocols/types/WLBuffer.hpp
@@ -17,7 +17,6 @@ class CWLBufferResource {
bool good();
void sendRelease();
- void sendReleaseWithSurface(SP<CWLSurfaceResource>);
wl_resource* getResource();
WP<IHLBuffer> buffer;
diff --git a/src/render/Renderer.hpp b/src/render/Renderer.hpp
index a9397cac..844f4700 100644
--- a/src/render/Renderer.hpp
+++ b/src/render/Renderer.hpp
@@ -142,6 +142,7 @@ class CHyprRenderer {
friend class CToplevelExportFrame;
friend class CInputManager;
friend class CPointerManager;
+ friend class CMonitor;
};
inline std::unique_ptr<CHyprRenderer> g_pHyprRenderer;