Ream v0.1.0-1
C++ graphics library for Linux
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | List of all members
RDRMTimeline Class Reference

A DRM synchronization object (syncobj) timeline for explicit synchronization. More...

#include <RDRMTimeline.h>

+ Inheritance diagram for RDRMTimeline:

Public Types

using Callback = std::function< void(RDRMTimeline *timeline)>
 Callback type invoked by waitAsync() when a point condition is met.
 

Public Member Functions

CZSpFd exportTimeline () const noexcept
 Exports the whole timeline syncobj as a file descriptor.
 
CZSpFd exportSyncFile (UInt64 point) const noexcept
 Exports the fence at a given timeline point as a sync_file file descriptor.
 
bool importSyncFile (int fd, UInt64 point, CZOwn own) noexcept
 Imports a sync_file fence into a given timeline point.
 
bool transferPoint (UInt64 srcPoint, std::shared_ptr< RDRMTimeline > dst, UInt64 dstPoint) noexcept
 Copies the fence at a source point of this timeline to a point of another timeline.
 
int waitSync (UInt64 point, UInt32 flags, Int64 timeoutNs=0) noexcept
 Synchronously waits for a timeline point.
 
std::shared_ptr< CZEventSource > waitAsync (UInt64 point, UInt32 flags, Callback callback) noexcept
 Asynchronously waits for a timeline point via an eventfd-backed event source.
 
bool signalPoint (UInt64 point) noexcept
 Immediately signals a timeline point.
 
std::shared_ptr< RCorecore () const noexcept
 Returns the internal shared reference to the core instance.
 
RDevicedevice () const noexcept
 Returns the DRM device this timeline belongs to.
 
UInt32 handle () const noexcept
 Returns the DRM syncobj handle backing this timeline.
 
 ~RDRMTimeline () noexcept
 Destroys the underlying DRM syncobj.
 
- Public Member Functions inherited from RObject
 RObject ()=default
 Constructs a default RObject.
 

Static Public Member Functions

static std::shared_ptr< RDRMTimelineMake (RDevice *device=nullptr) noexcept
 Creates a new empty timeline syncobj.
 
static std::shared_ptr< RDRMTimelineImport (int timelineFd, CZOwn own, RDevice *device=nullptr) noexcept
 Imports a timeline from an exported syncobj file descriptor.
 

Detailed Description

A DRM synchronization object (syncobj) timeline for explicit synchronization.

Wraps a DRM timeline syncobj, which associates fences with monotonically increasing 64-bit timeline points. Timelines are used for explicit GPU/display synchronization: a producer signals a point once its work completes, and consumers wait on that point before accessing the shared buffer.

A timeline is bound to a specific DRM device, which must advertise the Timeline capability. Timelines can be exported/imported as file descriptors for sharing across processes, and individual points can be exported to or imported from sync_file file descriptors to interoperate with implicit-sync APIs.

Use Make() to create a new timeline, or Import() to adopt an exported one.

Member Typedef Documentation

◆ Callback

using Callback = std::function<void(RDRMTimeline *timeline)>

Callback type invoked by waitAsync() when a point condition is met.

Parameters
timelineThe timeline that triggered the callback.

Constructor & Destructor Documentation

◆ ~RDRMTimeline()

~RDRMTimeline ( )
noexcept

Destroys the underlying DRM syncobj.

Member Function Documentation

◆ Make()

static std::shared_ptr< RDRMTimeline > Make ( RDevice device = nullptr)
staticnoexcept

Creates a new empty timeline syncobj.

Parameters
deviceThe DRM device to create the timeline on. If nullptr, RCore::mainDevice() is used. The device must support the Timeline capability.
Returns
A shared pointer to the created timeline, or nullptr on failure.

◆ Import()

static std::shared_ptr< RDRMTimeline > Import ( int  timelineFd,
CZOwn  own,
RDevice device = nullptr 
)
staticnoexcept

Imports a timeline from an exported syncobj file descriptor.

Parameters
timelineFdA file descriptor previously produced by exportTimeline().
ownCZOwn::Own to close timelineFd before returning (in all cases), or CZOwn::Borrow to leave it open for the caller to manage.
deviceThe DRM device to import onto. If nullptr, RCore::mainDevice() is used. The device must support the Timeline capability.
Returns
A shared pointer to the imported timeline, or nullptr on failure.

◆ exportTimeline()

CZSpFd exportTimeline ( ) const
noexcept

Exports the whole timeline syncobj as a file descriptor.

The returned descriptor can be shared and re-imported via Import().

Returns
A valid CZSpFd on success, or an empty/invalid CZSpFd on failure.

◆ exportSyncFile()

CZSpFd exportSyncFile ( UInt64  point) const
noexcept

Exports the fence at a given timeline point as a sync_file file descriptor.

Parameters
pointThe timeline point whose fence should be exported.
Returns
A valid CZSpFd wrapping the sync_file on success, or an empty/invalid CZSpFd on failure.

◆ importSyncFile()

bool importSyncFile ( int  fd,
UInt64  point,
CZOwn  own 
)
noexcept

Imports a sync_file fence into a given timeline point.

Parameters
fdA sync_file file descriptor.
pointThe timeline point to associate the imported fence with.
ownCZOwn::Own to close fd before returning (in all cases), or CZOwn::Borrow to leave it open for the caller to manage.
Returns
true on success, false on failure.

◆ transferPoint()

bool transferPoint ( UInt64  srcPoint,
std::shared_ptr< RDRMTimeline dst,
UInt64  dstPoint 
)
noexcept

Copies the fence at a source point of this timeline to a point of another timeline.

Parameters
srcPointThe source point on this timeline.
dstThe destination timeline, which must belong to the same device as this one.
dstPointThe destination point on dst.
Returns
true on success, false if dst is null, belongs to a different device, or the transfer fails.

◆ waitSync()

int waitSync ( UInt64  point,
UInt32  flags,
Int64  timeoutNs = 0 
)
noexcept

Synchronously waits for a timeline point.

Parameters
pointThe timeline point to wait on.
flagsDRM syncobj wait flags (e.g. DRM_SYNCOBJ_WAIT_FLAGS_WAIT_AVAILABLE to wait for a fence to become available rather than signalled).
timeoutNsAbsolute/relative timeout in nanoseconds as accepted by the DRM syncobj timeline wait (0 for an immediate poll).
Returns
1 if the point was satisfied, 0 on timeout, or -1 on error.

◆ waitAsync()

std::shared_ptr< CZEventSource > waitAsync ( UInt64  point,
UInt32  flags,
Callback  callback 
)
noexcept

Asynchronously waits for a timeline point via an eventfd-backed event source.

Registers an eventfd with the DRM syncobj and returns a CZEventSource that invokes callback once the point condition is met. Keep the returned event source alive for as long as the wait should remain active.

Parameters
pointThe timeline point to wait on.
flagsZero to wait for the point to be signalled, or DRM_SYNCOBJ_WAIT_FLAGS_WAIT_AVAILABLE to wait for a fence to be available for the point.
callbackThe callback to invoke; must not be null.
Returns
A shared pointer to the event source, or nullptr on failure (including a null callback).

◆ signalPoint()

bool signalPoint ( UInt64  point)
noexcept

Immediately signals a timeline point.

Parameters
pointThe timeline point to signal.
Returns
true on success, false on failure.

◆ core()

std::shared_ptr< RCore > core ( ) const
inlinenoexcept

Returns the internal shared reference to the core instance.

This ensures the current RCore instance stays alive while the timeline exists.

◆ device()

RDevice * device ( ) const
inlinenoexcept

Returns the DRM device this timeline belongs to.

◆ handle()

UInt32 handle ( ) const
inlinenoexcept

Returns the DRM syncobj handle backing this timeline.