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
RGLSync Class Referencefinal

OpenGL backend implementation of RSync. More...

#include <RGLSync.h>

+ Inheritance diagram for RGLSync:

Public Member Functions

 ~RGLSync () noexcept
 Destroys the underlying EGL sync object.
 
RGLDevicedevice () const noexcept
 Returns the device this sync belongs to as an RGLDevice.
 
bool gpuWait (RDevice *waiter=nullptr) const noexcept override
 Inserts a GPU-side wait on this fence.
 
int cpuWait (int timeoutMs=-1) const noexcept override
 Blocks the calling thread until the fence is signaled.
 
CZSpFd fd () const noexcept override
 Exports this fence as a sync_file file descriptor.
 
- Public Member Functions inherited from RSync
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< RGLSyncFromExternal (int fd, RGLDevice *device=nullptr) noexcept
 Creates a sync by importing an external sync_file fence.
 
static std::shared_ptr< RGLSyncMake (RGLDevice *device=nullptr) noexcept
 Creates a sync marking the current point in the device's GL command stream.
 
- Static Public Member Functions inherited from RSync
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

OpenGL backend implementation of RSync.

Wraps an EGL fence sync object (EGLSyncKHR). It is either created for the current point in a device's GL command stream (Make(), preferring a native-fence sync so it can be exported as a sync_file fd) or imported from an external fence fd (FromExternal()). Waits are performed via the device's EGL sync procs; cross-device GPU waits go through fd export/import.

Constructor & Destructor Documentation

◆ ~RGLSync()

~RGLSync ( )
noexcept

Destroys the underlying EGL sync object.

Member Function Documentation

◆ FromExternal()

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

Creates a sync by importing an external sync_file fence.

Takes ownership of the fd even on failure. Requires the device's SyncImport capability.

Parameters
fdThe fence file descriptor to import.
deviceTarget device, or nullptr for the main device.
Returns
The new sync, or nullptr on failure.

◆ Make()

static std::shared_ptr< RGLSync > Make ( RGLDevice device = nullptr)
staticnoexcept

Creates a sync marking the current point in the device's GL command stream.

Requires the device's SyncCPU capability; prefers a native-fence sync (exportable to an fd) when SyncExport is available, otherwise falls back to a plain EGL fence.

Parameters
deviceTarget device, or nullptr for the main device.
Returns
The new sync, or nullptr on failure.

◆ device()

RGLDevice * device ( ) const
inlinenoexcept

Returns the device this sync belongs to as an RGLDevice.

◆ gpuWait()

bool gpuWait ( RDevice waiter = nullptr) const
overridevirtualnoexcept

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.

Implements RSync.

◆ cpuWait()

int cpuWait ( int  timeoutMs = -1) const
overridevirtualnoexcept

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.

Implements RSync.

◆ fd()

CZSpFd fd ( ) const
overridevirtualnoexcept

Exports this fence as a sync_file file descriptor.

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

Implements RSync.