summaryrefslogtreecommitdiff
path: root/src/syncobject.hpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/syncobject.hpp67
1 files changed, 57 insertions, 10 deletions
diff --git a/src/syncobject.hpp b/src/syncobject.hpp
index cf30078..6221753 100644
--- a/src/syncobject.hpp
+++ b/src/syncobject.hpp
@@ -63,10 +63,11 @@ namespace drm {
/// Import a sync file (DRM fence) into the sync object
///
/// @param syncfile_fd File descriptor to import
+ /// @param point Timeline point to export for timeline sync objects
/// @param close Close the file descriptor after import (regardless of success)
/// @throws drm::ioctl::Exception on failure
///
- void importSyncFile(int syncfile_fd, bool close = true) const;
+ void importSyncFile(int syncfile_fd, uint64_t point = 0, bool close = true) const;
///
/// Export a sync file from the DRM fence within the sync object
@@ -74,19 +75,48 @@ namespace drm {
/// Any subsequent modifications to the sync object are not applied to
/// the exported sync file.
///
+ /// @param point Timeline point to export for timeline sync objects
/// @throws drm::ioctl::Exception on failure
/// @returns Exported file descriptor
///
- [[nodiscard]] int exportSyncFile() const;
+ [[nodiscard]] int exportSyncFile(uint64_t point = 0) const;
+
+ ///
+ /// Register an eventfd to be signaled by a sync object
+ ///
+ /// @param eventfd_fd File descriptor to signal
+ /// @param point Timeline point to signal for timeline sync objects
+ /// @param waitAvailable Only wait for a fence to be available, as opposed to signaled.
+ /// @throws drm::ioctl::Exception on failure
+ ///
+ void registerEventFd(int eventfd_fd, uint64_t point = 0, bool waitAvailable = false) const;
+
+ ///
+ /// Copy a DRM fence into another sync object
+ ///
+ /// @param dstObject Destination sync object handle
+ /// @param srcPoint Timeline point to copy from
+ /// @param dstPoint Timeline point to copy into
+ /// @throws drm::ioctl::Exception on failure
+ ///
+ void transfer(uint32_t dstObject, uint64_t srcPoint = 0, uint64_t dstPoint = 0) const;
///
/// Emplace signaled fences into a list of sync objects
///
+ /// When not using timeline sync objects, pass an empty list of timeline points.
+ ///
/// @param fd DRM node file descriptor
/// @param objects List of sync object handles
+ /// @param points List of timeline points to signal for each sync object
/// @throws drm::ioctl::Exception on failure
+ /// @throws std::invalid_argument invalid points size
///
- static void signal(int fd, const std::vector<uint32_t>& objects);
+ static void signal(
+ int fd,
+ const std::vector<uint32_t>& objects,
+ const std::vector<uint64_t>& points = {}
+ );
///
/// Remove the DRM fence from a list of sync objects
@@ -97,16 +127,11 @@ namespace drm {
///
static void reset(int fd, const std::vector<uint32_t>& objects);
- /// How to handle empty sync objects when waiting
- enum class EmptyFlags {
- /// Return -EINVAL if any sync object is empty
- Throw,
- /// Block until a fen
- };
-
///
/// Wait for a list of sync objects to be signaled
///
+ /// When not using timeline sync objects, pass an empty list of timeline points.
+ ///
/// If waitEmpty or waitAvailable is not set, any empty sync object will result in
/// an error.
///
@@ -116,18 +141,21 @@ namespace drm {
///
/// @param fd DRM node file descriptor
/// @param objects List of sync object handles
+ /// @param points List of timeline points to wait on for each sync object
/// @param timeout Absolute timeout in nanoseconds, or zero for polling
/// @param waitAll Wait for all sync objects, as opposed to a single one
/// @param waitEmpty Wait for sync objects, which do not yet have a fence emplaced
/// @param waitAvailable Only wait for a fence to be available, as opposed to signaled.
/// @param deadlineHint Set a CLOCK_MONOTONIC deadline hint in nanoseconds on all fences
/// @throws drm::ioctl::Exception on failure
+ /// @throws std::invalid_argument invalid points size
/// @return Handle which was signaled first, when waitAll is false.
///
[[nodiscard]]
static uint32_t wait(
int fd,
const std::vector<uint32_t>& objects,
+ const std::vector<uint64_t>& points = {},
int64_t timeout = 0,
bool waitAll = false,
bool waitEmpty = false,
@@ -135,6 +163,24 @@ namespace drm {
std::optional<uint64_t> deadlineHint = std::nullopt
);
+ ///
+ /// Query the timeline points of a list of sync objects
+ ///
+ /// This should only be used with timeline sync objects.
+ ///
+ /// @param fd DRM node file descriptor
+ /// @param objects List of sync object handles
+ /// @param lastSubmitted Query the last submitted instead of signaled point.
+ /// @throws drm::ioctl::Exception on failure
+ /// @returns List of timeline points
+ ///
+ [[nodiscard]]
+ static std::vector<uint64_t> query(
+ int fd,
+ const std::vector<uint32_t>& objects,
+ bool lastSubmitted = false
+ );
+
// Into handle
operator uint32_t() const { return this->m_handle; }
@@ -175,4 +221,5 @@ namespace drm {
void destruct() noexcept;
};
+
}