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

Vulkan RSync represented by a sync_file fd. More...

#include <RVKSync.h>

+ Inheritance diagram for RVKSync:

Public Member Functions

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< RVKSyncMake (RVKDevice *device) noexcept
 Captures all queue work submitted so far on device as a sync.
 
static std::shared_ptr< RVKSyncFromExternal (int fd, RVKDevice *device) noexcept
 Wraps an existing sync_file fd as a sync on device.
 
- 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

Vulkan RSync represented by a sync_file fd.

Like the GL backend's Android-native-fence approach, the durable representation is a sync_file fd (poll()able and freely dup-able). A VkSemaphore is only used transiently to mint the fd (Make: empty submit signals a SYNC_FD-exportable semaphore, then export) or to consume it (gpuWait: import into the waiter's next submission). An fd of -1 means the sync is already signaled.

Member Function Documentation

◆ Make()

static std::shared_ptr< RVKSync > Make ( RVKDevice device)
staticnoexcept

Captures all queue work submitted so far on device as a sync.

Performs an empty submit that signals a SYNC_FD-exportable semaphore, then exports it as a sync_file fd. If SYNC_FD export is unavailable, returns an already-signaled (no-op) sync.

◆ FromExternal()

static std::shared_ptr< RVKSync > FromExternal ( int  fd,
RVKDevice device 
)
staticnoexcept

Wraps an existing sync_file fd as a sync on device.

Takes ownership of fd even on failure (per the RSync contract).

◆ 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.