diff options
| author | Vaxry <43317083+vaxerski@users.noreply.github.com> | 2024-08-06 14:52:19 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-08-06 15:52:19 +0200 |
| commit | 640d1618519d42dd592f7af5e9984ad52eb8b820 (patch) | |
| tree | f44a5b58822eb60e7fd2dfc3e18af9bba0ab2cb0 /src/helpers/sync | |
| parent | 0e86808e5912823f1c6bea1b6d5fcae297fc9f57 (diff) | |
renderer: Explicit sync fixes (#7151)
Enables explicit sync by default for most platforms
`misc:no_direct_scanout` -> `render:direct_scanout`
Diffstat (limited to 'src/helpers/sync')
| -rw-r--r-- | src/helpers/sync/SyncReleaser.cpp | 25 | ||||
| -rw-r--r-- | src/helpers/sync/SyncReleaser.hpp | 31 | ||||
| -rw-r--r-- | src/helpers/sync/SyncTimeline.cpp | 5 | ||||
| -rw-r--r-- | src/helpers/sync/SyncTimeline.hpp | 1 |
4 files changed, 62 insertions, 0 deletions
diff --git a/src/helpers/sync/SyncReleaser.cpp b/src/helpers/sync/SyncReleaser.cpp new file mode 100644 index 00000000..198495ab --- /dev/null +++ b/src/helpers/sync/SyncReleaser.cpp @@ -0,0 +1,25 @@ +#include "SyncReleaser.hpp" +#include "SyncTimeline.hpp" +#include "../../render/OpenGL.hpp" + +CSyncReleaser::CSyncReleaser(WP<CSyncTimeline> timeline_, uint64_t point_) : timeline(timeline_), point(point_) { + ; +} + +CSyncReleaser::~CSyncReleaser() { + if (timeline.expired()) + return; + + if (sync) + timeline->importFromSyncFileFD(point, sync->fd()); + else + timeline->signal(point); +} + +void CSyncReleaser::addReleaseSync(SP<CEGLSync> sync_) { + sync = sync_; +} + +void CSyncReleaser::drop() { + timeline.reset(); +}
\ No newline at end of file diff --git a/src/helpers/sync/SyncReleaser.hpp b/src/helpers/sync/SyncReleaser.hpp new file mode 100644 index 00000000..e21d2e34 --- /dev/null +++ b/src/helpers/sync/SyncReleaser.hpp @@ -0,0 +1,31 @@ +#pragma once + +#include <cstdint> +#include <optional> +#include <vector> +#include <functional> +#include "../memory/Memory.hpp" + +/* + A helper (inspired by KDE's KWin) that will release the timeline point in the dtor +*/ + +class CSyncTimeline; +class CEGLSync; + +class CSyncReleaser { + public: + CSyncReleaser(WP<CSyncTimeline> timeline_, uint64_t point_); + ~CSyncReleaser(); + + // drops the releaser, will never signal anymore + void drop(); + + // wait for this gpu job to finish before releasing + void addReleaseSync(SP<CEGLSync> sync); + + private: + WP<CSyncTimeline> timeline; + uint64_t point = 0; + SP<CEGLSync> sync; +}; diff --git a/src/helpers/sync/SyncTimeline.cpp b/src/helpers/sync/SyncTimeline.cpp index 352120ea..16b5bd92 100644 --- a/src/helpers/sync/SyncTimeline.cpp +++ b/src/helpers/sync/SyncTimeline.cpp @@ -188,3 +188,8 @@ bool CSyncTimeline::transfer(SP<CSyncTimeline> from, uint64_t fromPoint, uint64_ return true; } + +void CSyncTimeline::signal(uint64_t point) { + if (drmSyncobjTimelineSignal(drmFD, &handle, &point, 1)) + Debug::log(ERR, "CSyncTimeline::signal: drmSyncobjTimelineSignal failed"); +} diff --git a/src/helpers/sync/SyncTimeline.hpp b/src/helpers/sync/SyncTimeline.hpp index 3d868a95..88ad4921 100644 --- a/src/helpers/sync/SyncTimeline.hpp +++ b/src/helpers/sync/SyncTimeline.hpp @@ -35,6 +35,7 @@ class CSyncTimeline { int exportAsSyncFileFD(uint64_t src); bool importFromSyncFileFD(uint64_t dst, int fd); bool transfer(SP<CSyncTimeline> from, uint64_t fromPoint, uint64_t toPoint); + void signal(uint64_t point); int drmFD = -1; uint32_t handle = 0; |
