Lysa  0.0
Lysa 3D Engine
AsyncQueue Class Reference

Detailed Description

A lightweight background submission system used by Lysa to build and submit GPU command lists asynchronously. It owns a worker thread that drains a queue of recorded commands and submits them to the appropriate Vireo submit queue (transfer or graphic), allowing asset uploads and simple GPU work to happen without stalling the main thread.

Typical usage:

  • Call beginCommand() to acquire a command list for a specific CommandType.
  • Record GPU work (e.g., copies, barriers) on the returned command list.
  • Call endCommand() to enqueue the work; optionally set immediate=true to trigger an immediate submit when appropriate.
  • The internal worker thread will batch and submit pending commands.

Thread-safety:

  • Public methods are thread-safe unless otherwise specified. Internals are protected via mutexes. Commands and temporary buffers are tracked per command list to avoid premature destruction.

Classes

struct  Command
 

Public Member Functions

 AsyncQueue (const std::shared_ptr< vireo::Vireo > &vireo, const std::shared_ptr< vireo::SubmitQueue > &transferQueue, const std::shared_ptr< vireo::SubmitQueue > &graphicQueue)
 
void cleanup ()
 
Command beginCommand (vireo::CommandType commandType, const std::source_location &location=std::source_location::current ())
 
void endCommand (const Command &command, bool immediate=false)
 
void submitCommands ()
 
std::shared_ptr< vireo::Buffer > createBuffer (const Command &command, vireo::BufferType type, size_t instanceSize, uint32 instanceCount)
 
 AsyncQueue (const AsyncQueue &) = delete
 
AsyncQueue & operator= (const AsyncQueue &) = delete
 

Constructor & Destructor Documentation

AsyncQueue ( const std::shared_ptr< vireo::Vireo > &  vireo,
const std::shared_ptr< vireo::SubmitQueue > &  transferQueue,
const std::shared_ptr< vireo::SubmitQueue > &  graphicQueue 
)

Construct an asynchronous queue manager bound to Vireo and two submit queues (transfer and graphic).

AsyncQueue ( const AsyncQueue &  )
delete

Member Function Documentation

Command beginCommand ( vireo::CommandType  commandType,
const std::source_location &  location = std::source_location::current () 
)

Acquire a command for the specified queue type and begin recording on its command list. The source_location is captured by default for debugging purposes.

void cleanup ( )

Release background resources and flush outstanding commands. Safe to call during application shutdown.

std::shared_ptr<vireo::Buffer> createBuffer ( const Command command,
vireo::BufferType  type,
size_t  instanceSize,
uint32  instanceCount 
)

Create a buffer that is tracked alongside the provided command so the resource remains alive until the GPU work referencing it has been submitted. Useful for transient staging buffers.

void endCommand ( const Command command,
bool  immediate = false 
)

Finish recording and enqueue the command for submission. If immediate is true, the queue may attempt to submit pending commands right away.

AsyncQueue& operator= ( const AsyncQueue &  )
delete
void submitCommands ( )

Trigger submission of all pending commands. Usually invoked by the engine tick; the background thread will also submit when woken.