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

GPU/CPU synchronization fence. More...

#include <RSync.h>

+ Inheritance diagram for RSync:

Public Member Functions

virtual bool gpuWait (RDevice *waiter=nullptr) const noexcept=0
 Inserts a GPU-side wait on this fence.
 
virtual int cpuWait (int timeoutMs=-1) const noexcept=0
 Blocks the calling thread until the fence is signaled.
 
virtual CZSpFd fd () const noexcept=0
 Exports this fence as a sync_file file descriptor.
 
bool isExternal () const noexcept
 Whether this sync was imported via FromExternal().
 
RDevicedevice () const noexcept
 Returns the device this sync is associated with.
 
- Public Member Functions inherited from RObject
 RObject ()=default
 Constructs a default RObject.
 

Static Public Member Functions

static std::shared_ptr< RSyncFromExternal (int fd, RDevice *device=nullptr) noexcept
 Imports an external sync_file fence.
 
static std::shared_ptr< RSyncMake (RDevice *device=nullptr) noexcept
 Creates a new sync fence.
 

Detailed Description

GPU/CPU synchronization fence.

RSync represents a point in a device's command stream, backed by a sync_file fence. It lets consumers wait for prior GPU work to complete before reading or overwriting a resource, without stalling unnecessarily.

A sync can be waited on the GPU (gpuWait(), inserting a dependency into a device's next submission) or on the CPU (cpuWait()). Because it is expressed as a sync_file fd, it can be exported and imported (fd(), RSync::FromExternal()) to interoperate with other devices, clients, and DRM sync objects. Images publish their read/write syncs automatically as rendering proceeds.

Member Function Documentation

◆ FromExternal()

static std::shared_ptr< RSync > FromExternal ( int  fd,
RDevice device = nullptr 
)
staticnoexcept

Imports an external sync_file fence.

Parameters
fdA sync_file file descriptor. Ownership is taken even on failure.
deviceDevice to associate the sync with. If nullptr, the main device is used.
Returns
A shared pointer to the new RSync, or nullptr on failure.

◆ Make()

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

Creates a new sync fence.

Parameters
deviceDevice to create the sync on. If nullptr, the main device is used.
Returns
A shared pointer to the new RSync, or nullptr on failure.

◆ gpuWait()

virtual bool gpuWait ( RDevice waiter = nullptr) const
pure virtualnoexcept

Inserts a GPU-side wait on this fence.

Non-blocking. Makes the waiter's next submission depend on this fence being signaled.

Parameters
waiterDevice that must wait. If nullptr, the main device is used.
Returns
true on success or if the fence is already signaled, false otherwise.

Implemented in RGLSync, and RVKSync.

◆ cpuWait()

virtual int cpuWait ( int  timeoutMs = -1) const
pure virtualnoexcept

Blocks the calling thread until the fence is signaled.

Parameters
timeoutMsTimeout in milliseconds; -1 waits indefinitely.
Returns
1 if signaled (or already signaled), 0 on timeout, -1 on error.

Implemented in RGLSync, and RVKSync.

◆ fd()

virtual CZSpFd fd ( ) const
pure virtualnoexcept

Exports this fence as a sync_file file descriptor.

Returns
A file descriptor wrapper, invalid (-1) on error.

Implemented in RGLSync, and RVKSync.

◆ isExternal()

bool isExternal ( ) const
inlinenoexcept

Whether this sync was imported via FromExternal().

Returns
true if created with FromExternal(), false otherwise.

◆ device()

RDevice * device ( ) const
inlinenoexcept

Returns the device this sync is associated with.