summaryrefslogtreecommitdiff
path: root/src/helpers/sync/SyncTimeline.hpp
diff options
context:
space:
mode:
authorVaxry <43317083+vaxerski@users.noreply.github.com>2024-07-21 13:09:54 +0200
committerGitHub <noreply@github.com>2024-07-21 13:09:54 +0200
commit016da234d0e852de3ef20eb2e89ac58d2a85f6e7 (patch)
tree496085987176551b0794fffc069877d44943e2f1 /src/helpers/sync/SyncTimeline.hpp
parentf642fb97df5c69267a03452533de383ff8023570 (diff)
Core: Move to aquamarine (#6608)
Moves Hyprland from wlroots to aquamarine for the backend. --------- Signed-off-by: Vaxry <vaxry@vaxry.net> Co-authored-by: Mihai Fufezan <mihai@fufexan.net> Co-authored-by: Jan Beich <jbeich@FreeBSD.org> Co-authored-by: vaxerski <vaxerski@users.noreply.github.com> Co-authored-by: UjinT34 <41110182+UjinT34@users.noreply.github.com> Co-authored-by: Tom Englund <tomenglund26@gmail.com> Co-authored-by: Ikalco <73481042+ikalco@users.noreply.github.com> Co-authored-by: diniamo <diniamo53@gmail.com>
Diffstat (limited to 'src/helpers/sync/SyncTimeline.hpp')
-rw-r--r--src/helpers/sync/SyncTimeline.hpp47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/helpers/sync/SyncTimeline.hpp b/src/helpers/sync/SyncTimeline.hpp
new file mode 100644
index 00000000..3d868a95
--- /dev/null
+++ b/src/helpers/sync/SyncTimeline.hpp
@@ -0,0 +1,47 @@
+#pragma once
+
+#include <cstdint>
+#include <optional>
+#include <vector>
+#include <functional>
+#include "../memory/Memory.hpp"
+
+/*
+ Hyprland synchronization timelines are based on the wlroots' ones, which
+ are based on Vk timeline semaphores: https://www.khronos.org/blog/vulkan-timeline-semaphores
+*/
+
+struct wl_event_source;
+
+class CSyncTimeline {
+ public:
+ static SP<CSyncTimeline> create(int drmFD_);
+ static SP<CSyncTimeline> create(int drmFD_, int drmSyncobjFD);
+ ~CSyncTimeline();
+
+ struct SWaiter {
+ std::function<void()> fn;
+ wl_event_source* source = nullptr;
+ WP<CSyncTimeline> timeline;
+ };
+
+ // check if the timeline point has been signaled
+ // flags: DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT or DRM_SYNCOBJ_WAIT_FLAGS_WAIT_AVAILABLE
+ // std::nullopt on fail
+ std::optional<bool> check(uint64_t point, uint32_t flags);
+
+ bool addWaiter(const std::function<void()>& waiter, uint64_t point, uint32_t flags);
+ void removeWaiter(SWaiter*);
+ int exportAsSyncFileFD(uint64_t src);
+ bool importFromSyncFileFD(uint64_t dst, int fd);
+ bool transfer(SP<CSyncTimeline> from, uint64_t fromPoint, uint64_t toPoint);
+
+ int drmFD = -1;
+ uint32_t handle = 0;
+ WP<CSyncTimeline> self;
+
+ private:
+ CSyncTimeline() = default;
+
+ std::vector<SP<SWaiter>> waiters;
+};