Vulkan Schnee 0.0.1
High-performance rendering engine
Loading...
Searching...
No Matches
EngineCore::QueueSubmitBuilder Class Reference

Fluent builder for queue submissions with timeline and binary semaphores. More...

#include <QueueSubmitBuilder.h>

Collaboration diagram for EngineCore::QueueSubmitBuilder:

Public Member Functions

 QueueSubmitBuilder (const TimelineSynchronizer &sync, uint64_t frameNumber)
 Constructs a submit builder.
QueueSubmitBuilderwaitFor (PipelineStage stage, VkPipelineStageFlags2 waitStages, uint64_t frameNumber)
 Adds a timeline wait for a specific frame's stage (GPU-GPU sync)
QueueSubmitBuilderwaitForCurrent (PipelineStage stage, VkPipelineStageFlags2 waitStages)
 Convenience: wait for same frame's earlier stage.
QueueSubmitBuilderwaitForPrevious (PipelineStage stage, VkPipelineStageFlags2 waitStages)
 Convenience: wait for previous frame's stage.
QueueSubmitBuilderwaitForResourceReuse (PipelineStage stage, VkPipelineStageFlags2 waitStages)
 Convenience: wait for resource reuse (frames-in-flight pattern)
QueueSubmitBuilderwaitForBinary (VkSemaphore semaphore, VkPipelineStageFlags2 waitStages)
 Adds a binary semaphore wait (for swapchain acquire, etc.)
QueueSubmitBuildersignalStage (PipelineStage stage)
 Signals the timeline semaphore at a specific stage.
QueueSubmitBuildersignalBinary (VkSemaphore semaphore)
 Signals a binary semaphore at completion (for present)
QueueSubmitBuilderwithCommandBuffer (VkCommandBuffer cmdBuffer)
 Adds a command buffer to be executed.
QueueSubmitBuilderwithCommandBuffers (const std::vector< VkCommandBuffer > &cmdBuffers)
 Adds multiple command buffers to be executed.
VkResult submit (VkQueue queue, VkFence fence=VK_NULL_HANDLE)
 Builds and submits to the specified queue.
uint64_t getLastSignalValue () const
 Gets the signal value for the last stage added Useful for debugging or for CPU-side waits.

Private Attributes

const TimelineSynchronizersync_
uint64_t frameNumber_
uint64_t lastSignalValue_ = 0
std::vector< VkSemaphoreSubmitInfo > waitInfos_
std::vector< VkSemaphoreSubmitInfo > signalInfos_
std::vector< VkCommandBufferSubmitInfo > cmdBufferInfos_

Detailed Description

Fluent builder for queue submissions with timeline and binary semaphores.

Provides a clean API for constructing VkSubmitInfo2 structures with proper synchronization between pipeline stages. Supports both timeline semaphores (for GPU-GPU sync) and binary semaphores (for swapchain/present operations).

Example usage:

QueueSubmitBuilder(timelineSync, frameNumber)
VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT)
.withCommandBuffer(computeCommandBuffer)
.submit(context->getComputeQueue());
QueueSubmitBuilder(const TimelineSynchronizer &sync, uint64_t frameNumber)
Constructs a submit builder.
Date
2026-01-14
Author
Konstantin Passig

Definition at line 31 of file QueueSubmitBuilder.h.

Constructor & Destructor Documentation

◆ QueueSubmitBuilder()

EngineCore::QueueSubmitBuilder::QueueSubmitBuilder ( const TimelineSynchronizer & sync,
uint64_t frameNumber )
explicit

Constructs a submit builder.

Parameters
syncThe timeline synchronizer for value computation
frameNumberThe current frame number

Definition at line 6 of file QueueSubmitBuilder.cpp.

References frameNumber_, and sync_.

Referenced by signalBinary(), signalStage(), waitFor(), waitForBinary(), waitForCurrent(), waitForPrevious(), waitForResourceReuse(), withCommandBuffer(), and withCommandBuffers().

Here is the caller graph for this function:

Member Function Documentation

◆ getLastSignalValue()

uint64_t EngineCore::QueueSubmitBuilder::getLastSignalValue ( ) const
inlinenodiscard

Gets the signal value for the last stage added Useful for debugging or for CPU-side waits.

Returns
The last signaled timeline value, or 0 if none

Definition at line 148 of file QueueSubmitBuilder.h.

References lastSignalValue_.

◆ signalBinary()

QueueSubmitBuilder & EngineCore::QueueSubmitBuilder::signalBinary ( VkSemaphore semaphore)

Signals a binary semaphore at completion (for present)

Parameters
semaphoreThe binary semaphore to signal
Returns
Reference to this builder for chaining

Definition at line 111 of file QueueSubmitBuilder.cpp.

References QueueSubmitBuilder(), and signalInfos_.

Referenced by EngineCore::Renderer::submitGraphics().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ signalStage()

QueueSubmitBuilder & EngineCore::QueueSubmitBuilder::signalStage ( PipelineStage stage)

Signals the timeline semaphore at a specific stage.

Parameters
stageThe pipeline stage being completed
Returns
Reference to this builder for chaining

Definition at line 94 of file QueueSubmitBuilder.cpp.

References frameNumber_, lastSignalValue_, QueueSubmitBuilder(), signalInfos_, and sync_.

Referenced by EngineCore::Renderer::submitGraphics(), EngineCore::Renderer::submitInitialTransfers(), and EngineCore::Renderer::submitTransfer().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ submit()

VkResult EngineCore::QueueSubmitBuilder::submit ( VkQueue queue,
VkFence fence = VK_NULL_HANDLE )

Builds and submits to the specified queue.

Parameters
queueThe queue to submit to
fenceOptional fence to signal on completion
Returns
VK_SUCCESS on success, or an error code

Definition at line 150 of file QueueSubmitBuilder.cpp.

References cmdBufferInfos_, signalInfos_, and waitInfos_.

Referenced by EngineCore::Renderer::submitGraphics(), EngineCore::Renderer::submitInitialTransfers(), and EngineCore::Renderer::submitTransfer().

Here is the caller graph for this function:

◆ waitFor()

QueueSubmitBuilder & EngineCore::QueueSubmitBuilder::waitFor ( PipelineStage stage,
VkPipelineStageFlags2 waitStages,
uint64_t frameNumber )

Adds a timeline wait for a specific frame's stage (GPU-GPU sync)

Parameters
stageThe pipeline stage to wait for
waitStagesThe Vulkan pipeline stages that need to wait
frameNumberWhich frame's stage to wait for
Returns
Reference to this builder for chaining

Definition at line 12 of file QueueSubmitBuilder.cpp.

References QueueSubmitBuilder(), sync_, and waitInfos_.

Referenced by waitForCurrent().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ waitForBinary()

QueueSubmitBuilder & EngineCore::QueueSubmitBuilder::waitForBinary ( VkSemaphore semaphore,
VkPipelineStageFlags2 waitStages )

Adds a binary semaphore wait (for swapchain acquire, etc.)

Parameters
semaphoreThe binary semaphore to wait on
waitStagesThe Vulkan pipeline stages that need to wait
Returns
Reference to this builder for chaining

Definition at line 76 of file QueueSubmitBuilder.cpp.

References QueueSubmitBuilder(), and waitInfos_.

Referenced by EngineCore::Renderer::submitGraphics().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ waitForCurrent()

QueueSubmitBuilder & EngineCore::QueueSubmitBuilder::waitForCurrent ( PipelineStage stage,
VkPipelineStageFlags2 waitStages )

Convenience: wait for same frame's earlier stage.

Parameters
stageThe pipeline stage to wait for
waitStagesThe Vulkan pipeline stages that need to wait
Returns
Reference to this builder for chaining

Definition at line 31 of file QueueSubmitBuilder.cpp.

References frameNumber_, QueueSubmitBuilder(), and waitFor().

Referenced by EngineCore::Renderer::submitGraphics().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ waitForPrevious()

QueueSubmitBuilder & EngineCore::QueueSubmitBuilder::waitForPrevious ( PipelineStage stage,
VkPipelineStageFlags2 waitStages )

Convenience: wait for previous frame's stage.

Parameters
stageThe pipeline stage to wait for
waitStagesThe Vulkan pipeline stages that need to wait
Returns
Reference to this builder for chaining

Definition at line 38 of file QueueSubmitBuilder.cpp.

References frameNumber_, QueueSubmitBuilder(), sync_, and waitInfos_.

Referenced by EngineCore::Renderer::submitGraphics().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ waitForResourceReuse()

QueueSubmitBuilder & EngineCore::QueueSubmitBuilder::waitForResourceReuse ( PipelineStage stage,
VkPipelineStageFlags2 waitStages )

Convenience: wait for resource reuse (frames-in-flight pattern)

Waits for the frame that last used this resource slot.

Parameters
stageThe pipeline stage to wait for
waitStagesThe Vulkan pipeline stages that need to wait
Returns
Reference to this builder for chaining

Definition at line 57 of file QueueSubmitBuilder.cpp.

References frameNumber_, QueueSubmitBuilder(), sync_, and waitInfos_.

Referenced by EngineCore::Renderer::submitTransfer().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ withCommandBuffer()

QueueSubmitBuilder & EngineCore::QueueSubmitBuilder::withCommandBuffer ( VkCommandBuffer cmdBuffer)

Adds a command buffer to be executed.

Parameters
cmdBufferThe command buffer to execute
Returns
Reference to this builder for chaining

Definition at line 127 of file QueueSubmitBuilder.cpp.

References cmdBufferInfos_, and QueueSubmitBuilder().

Referenced by EngineCore::Renderer::submitGraphics(), EngineCore::Renderer::submitInitialTransfers(), EngineCore::Renderer::submitTransfer(), and withCommandBuffers().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ withCommandBuffers()

QueueSubmitBuilder & EngineCore::QueueSubmitBuilder::withCommandBuffers ( const std::vector< VkCommandBuffer > & cmdBuffers)

Adds multiple command buffers to be executed.

Parameters
cmdBuffersThe command buffers to execute
Returns
Reference to this builder for chaining

Definition at line 141 of file QueueSubmitBuilder.cpp.

References QueueSubmitBuilder(), and withCommandBuffer().

Here is the call graph for this function:

Member Data Documentation

◆ cmdBufferInfos_

std::vector<VkCommandBufferSubmitInfo> EngineCore::QueueSubmitBuilder::cmdBufferInfos_
private

Definition at line 157 of file QueueSubmitBuilder.h.

Referenced by submit(), and withCommandBuffer().

◆ frameNumber_

uint64_t EngineCore::QueueSubmitBuilder::frameNumber_
private

◆ lastSignalValue_

uint64_t EngineCore::QueueSubmitBuilder::lastSignalValue_ = 0
private

Definition at line 153 of file QueueSubmitBuilder.h.

Referenced by getLastSignalValue(), and signalStage().

◆ signalInfos_

std::vector<VkSemaphoreSubmitInfo> EngineCore::QueueSubmitBuilder::signalInfos_
private

Definition at line 156 of file QueueSubmitBuilder.h.

Referenced by signalBinary(), signalStage(), and submit().

◆ sync_

const TimelineSynchronizer& EngineCore::QueueSubmitBuilder::sync_
private

◆ waitInfos_

std::vector<VkSemaphoreSubmitInfo> EngineCore::QueueSubmitBuilder::waitInfos_
private

The documentation for this class was generated from the following files: