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

Vulkan backend implementation of RDevice. More...

#include <RVKDevice.h>

+ Inheritance diagram for RVKDevice:

Public Member Functions

void wait () noexcept override
 Blocks until the device has finished all pending work.
 
sk_sp< GrDirectContext > skContext () const noexcept
 Returns the calling thread's Skia (Ganesh) Vulkan context.
 
std::mutex & queueMutex () const noexcept
 Serializes access to the shared VkQueue.
 
UInt32 findMemoryType (UInt32 typeBits, VkMemoryPropertyFlags props) const noexcept
 Selects a memory type index satisfying the given requirements and property flags.
 
bool immediateSubmit (const std::function< void(VkCommandBuffer)> &record) const noexcept
 Records and synchronously submits a one-shot command buffer on the graphics queue.
 
bool submitCommand (VkCommandBuffer cmd) const noexcept
 Submits an already-recorded command buffer, consuming pending waits, and blocks until it completes. Used by RVKPainter::flush.
 
bool submitCommandAsync (VkCommandBuffer cmd, VkFence fence, std::vector< VkSemaphore > &ownedWaitsOut, VkSemaphore signal=VK_NULL_HANDLE) const noexcept
 Submits an already-recorded command buffer signalling fence, consuming pending waits, WITHOUT blocking. The caller tracks completion via fence (typically pairing with deferDestroy() so CPU/GPU can pipeline). Used by RVKPainter::flush.
 
void deferDestroy (VkFence fence, std::function< void()> cleanup) const noexcept
 Registers a cleanup to run once fence is signalled (deferred/GPU-safe destruction).
 
void queueWait (VkSemaphore semaphore, bool owned) const noexcept
 Queues a semaphore for the next queue submission to wait on.
 
bool submitSignal (VkSemaphore semaphore, VkFence fence) const noexcept
 Empty queue submission that signals semaphore (and optional fence) after all prior queue work.
 
- Public Member Functions inherited from RDevice
 ~RDevice () noexcept
 Destructor.
 
int drmFd () const noexcept
 Returns the primary DRM file descriptor.
 
int drmFdReadOnly () const noexcept
 Returns the read-only DRM file descriptor.
 
void * drmUserData () const noexcept
 Returns the user data associated with the DRM device.
 
dev_t id () const noexcept
 Returns the device id (dev_t) of the DRM node.
 
const std::string & drmNode () const noexcept
 Returns the path of the DRM node.
 
const std::string & drmDriverName () const noexcept
 Returns the DRM driver name.
 
RDriver drmDriver () const noexcept
 Returns the detected DRM driver.
 
RCorecore () const noexcept
 Returns the RCore instance that owns this device.
 
RGLDeviceasGL () noexcept
 Attempts to cast this device to an RGLDevice.
 
RRSDeviceasRS () noexcept
 Attempts to cast this device to an RRSDevice.
 
RVKDeviceasVK () noexcept
 Attempts to cast this device to an RVKDevice.
 
const Capscaps () const noexcept
 Returns the capabilities of this device.
 
- Public Member Functions inherited from RObject
 RObject ()=default
 Constructs a default RObject.
 

Additional Inherited Members

- Public Attributes inherited from RDevice
CZLogger log { RLog }
 Logger for messages related to this device.
 

Detailed Description

Vulkan backend implementation of RDevice.

Wraps a single VkPhysicalDevice/VkDevice and its graphics queue, and owns the resources shared across the backend: the painter pipeline cache, per-thread Skia (Ganesh) contexts, a queue mutex serializing submissions, and a fence-tracked deferred-destruction queue enabling asynchronous, non-blocking command submission.

Obtained by downcasting an RDevice via RDevice::asVK().

Member Function Documentation

◆ wait()

void wait ( )
overridevirtualnoexcept

Blocks until the device has finished all pending work.

Implements RDevice.

◆ skContext()

sk_sp< GrDirectContext > skContext ( ) const
noexcept

Returns the calling thread's Skia (Ganesh) Vulkan context.

GrDirectContext is not thread-safe, so a separate context is lazily created per thread, all sharing this device's VkDevice/VkQueue and memory allocator.

◆ queueMutex()

std::mutex & queueMutex ( ) const
inlinenoexcept

Serializes access to the shared VkQueue.

VkQueue submission and vkDeviceWaitIdle require external synchronization.

◆ findMemoryType()

UInt32 findMemoryType ( UInt32  typeBits,
VkMemoryPropertyFlags  props 
) const
noexcept

Selects a memory type index satisfying the given requirements and property flags.

Returns
The memory type index, or UINT32_MAX if none matches.

◆ immediateSubmit()

bool immediateSubmit ( const std::function< void(VkCommandBuffer)> &  record) const
noexcept

Records and synchronously submits a one-shot command buffer on the graphics queue.

Serialized via queueMutex() and blocks until the GPU finishes (fence wait). Used for pixel uploads/downloads and layout transitions.

Returns
true on success.

◆ submitCommand()

bool submitCommand ( VkCommandBuffer  cmd) const
noexcept

Submits an already-recorded command buffer, consuming pending waits, and blocks until it completes. Used by RVKPainter::flush.

◆ submitCommandAsync()

bool submitCommandAsync ( VkCommandBuffer  cmd,
VkFence  fence,
std::vector< VkSemaphore > &  ownedWaitsOut,
VkSemaphore  signal = VK_NULL_HANDLE 
) const
noexcept

Submits an already-recorded command buffer signalling fence, consuming pending waits, WITHOUT blocking. The caller tracks completion via fence (typically pairing with deferDestroy() so CPU/GPU can pipeline). Used by RVKPainter::flush.

Owned pending-wait semaphores consumed by this submission are appended to ownedWaitsOut; the caller must destroy them once fence signals (e.g. inside its deferDestroy cleanup).

If signal is not VK_NULL_HANDLE it is signalled on completion (e.g. a swapchain present semaphore that vkQueuePresentKHR waits on), so present need not block the CPU.

◆ deferDestroy()

void deferDestroy ( VkFence  fence,
std::function< void()>  cleanup 
) const
noexcept

Registers a cleanup to run once fence is signalled (deferred/GPU-safe destruction).

The fence is destroyed after the cleanup runs. Drained by clearGarbage() (called by the compositor each frame) and fully flushed at device destruction.

◆ queueWait()

void queueWait ( VkSemaphore  semaphore,
bool  owned 
) const
noexcept

Queues a semaphore for the next queue submission to wait on.

Used by RVKSync::gpuWait so that subsequent GPU work on this device waits for the sync. If owned is true the semaphore is destroyed once consumed by a submission.

◆ submitSignal()

bool submitSignal ( VkSemaphore  semaphore,
VkFence  fence 
) const
noexcept

Empty queue submission that signals semaphore (and optional fence) after all prior queue work.

Backs RVKSync::Make (captures "all previously submitted work on this device").