Foray Library
rapid prototyping framework for crossplatform development of vulkan hardware ray tracing applications
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | List of all members
foray::base::InFlightFrame Class Reference

Wraps synchronization primitives and command buffers for an inflight frame. More...

#include <foray_inflightframe.hpp>

Public Member Functions

void Create (core::Context *context, uint32_t auxCommandBufferCount=0)
 
void Destroy ()
 
virtual ~InFlightFrame ()
 
ESwapchainInteractResult AcquireSwapchainImage ()
 Acquires next swapchain image and stores the resulting index in mSwapchainImageIndex.
 
ESwapchainInteractResult Present ()
 Presents the previously acquired image. The primary command buffer must have been submitted prior to this call!
 
void ClearSwapchainImage (VkCommandBuffer cmdBuffer, core::ImageLayoutCache &imgLayoutCache)
 Writes vkCmdClearColorImage cmd to the primary command buffer for the acquired image.
 
void PrepareSwapchainImageForPresent (VkCommandBuffer cmdBuffer, core::ImageLayoutCache &imgLayoutCache)
 Adds a Pipeline barrier transitioning the swapchain image into present layout and assuring all writes to it have finished.
 
bool HasFinishedExecution ()
 Non-blocking check wether the frame has been finished execution.
 
void WaitForExecutionFinished ()
 Blocks the current thread until the frame has finished execution.
 
void ResetFence ()
 Resets the frames host synchronization fence.
 
void SubmitAll ()
 Submits all command buffers by getting all VkSubmitInfo2{} structures from DeviceSyncCommandBuffer::WriteToSubmitInfo(...) and submitting them in a single vkQueueSubmit2(...) call.
 
core::DeviceSyncCommandBufferGetAuxiliaryCommandBuffer (uint32_t index)
 Get an auxiliary command buffer.
 
core::DeviceSyncCommandBufferGetPrimaryCommandBuffer ()
 Get primary command buffer.
 
core::DeviceSyncCommandBufferGetCommandBuffer (CmdBufferIndex index)
 Get a command buffer.
 
const core::DeviceSyncCommandBufferGetAuxiliaryCommandBuffer (uint32_t index) const
 Get an auxiliary command buffer.
 
const core::DeviceSyncCommandBufferGetPrimaryCommandBuffer () const
 Get primary command buffer.
 
const core::DeviceSyncCommandBufferGetCommandBuffer (CmdBufferIndex index) const
 Get a command buffer.
 

Protected Attributes

core::ContextmContext = nullptr
 
std::vector< std::unique_ptr< core::DeviceSyncCommandBuffer > > mAuxiliaryCommandBuffers
 Auxiliary command buffers.
 
core::DeviceSyncCommandBuffer mPrimaryCommandBuffer
 Primary command buffer.
 
VkSemaphore mSwapchainImageReady = nullptr
 Semaphore signalled by the device when the swapchain image becomes ready.
 
VkSemaphore mPrimaryCompletedSemaphore = nullptr
 Semaphore signalled by the primary command buffer when execution has finished.
 
VkFence mPrimaryCompletedFence = nullptr
 Fence signalled after the primary / all command buffers have finished execution.
 
uint32_t mSwapchainImageIndex = 0
 

Detailed Description

Wraps synchronization primitives and command buffers for an inflight frame.

USAGE (SINGLE CMD BUFFER PER FRAME):

USAGE (MULTIPLE)

Constructor & Destructor Documentation

◆ ~InFlightFrame()

virtual foray::base::InFlightFrame::~InFlightFrame ( )
inlinevirtual

Member Function Documentation

◆ AcquireSwapchainImage()

ESwapchainInteractResult foray::base::InFlightFrame::AcquireSwapchainImage ( )

Acquires next swapchain image and stores the resulting index in mSwapchainImageIndex.

Returns
If result is Resized, the swapchain must be resized immediately

◆ ClearSwapchainImage()

void foray::base::InFlightFrame::ClearSwapchainImage ( VkCommandBuffer  cmdBuffer,
core::ImageLayoutCache imgLayoutCache 
)

Writes vkCmdClearColorImage cmd to the primary command buffer for the acquired image.

◆ Create()

void foray::base::InFlightFrame::Create ( core::Context context,
uint32_t  auxCommandBufferCount = 0 
)

◆ Destroy()

void foray::base::InFlightFrame::Destroy ( )

◆ GetAuxiliaryCommandBuffer() [1/2]

core::DeviceSyncCommandBuffer & foray::base::InFlightFrame::GetAuxiliaryCommandBuffer ( uint32_t  index)

Get an auxiliary command buffer.

Parameters
indexCommand buffer index to return

◆ GetAuxiliaryCommandBuffer() [2/2]

const core::DeviceSyncCommandBuffer & foray::base::InFlightFrame::GetAuxiliaryCommandBuffer ( uint32_t  index) const

Get an auxiliary command buffer.

Parameters
indexCommand buffer index to return

◆ GetCommandBuffer() [1/2]

core::DeviceSyncCommandBuffer & foray::base::InFlightFrame::GetCommandBuffer ( CmdBufferIndex  index)

Get a command buffer.

Parameters
indexIf PRIMARY_COMMAND_BUFFER, the primary is returned. Auxiliary command buffer index otherwise

◆ GetCommandBuffer() [2/2]

const core::DeviceSyncCommandBuffer & foray::base::InFlightFrame::GetCommandBuffer ( CmdBufferIndex  index) const

Get a command buffer.

Parameters
indexIf PRIMARY_COMMAND_BUFFER, the primary is returned. Auxiliary command buffer index otherwise

◆ GetPrimaryCommandBuffer() [1/2]

core::DeviceSyncCommandBuffer & foray::base::InFlightFrame::GetPrimaryCommandBuffer ( )

Get primary command buffer.

◆ GetPrimaryCommandBuffer() [2/2]

const core::DeviceSyncCommandBuffer & foray::base::InFlightFrame::GetPrimaryCommandBuffer ( ) const

Get primary command buffer.

◆ HasFinishedExecution()

bool foray::base::InFlightFrame::HasFinishedExecution ( )

Non-blocking check wether the frame has been finished execution.

◆ PrepareSwapchainImageForPresent()

void foray::base::InFlightFrame::PrepareSwapchainImageForPresent ( VkCommandBuffer  cmdBuffer,
core::ImageLayoutCache imgLayoutCache 
)

Adds a Pipeline barrier transitioning the swapchain image into present layout and assuring all writes to it have finished.

◆ Present()

ESwapchainInteractResult foray::base::InFlightFrame::Present ( )

Presents the previously acquired image. The primary command buffer must have been submitted prior to this call!

Returns
If result is Resized, the swapchain must be resized

◆ ResetFence()

void foray::base::InFlightFrame::ResetFence ( )

Resets the frames host synchronization fence.

◆ SubmitAll()

void foray::base::InFlightFrame::SubmitAll ( )

Submits all command buffers by getting all VkSubmitInfo2{} structures from DeviceSyncCommandBuffer::WriteToSubmitInfo(...) and submitting them in a single vkQueueSubmit2(...) call.

◆ WaitForExecutionFinished()

void foray::base::InFlightFrame::WaitForExecutionFinished ( )

Blocks the current thread until the frame has finished execution.

Member Data Documentation

◆ mAuxiliaryCommandBuffers

std::vector<std::unique_ptr<core::DeviceSyncCommandBuffer> > foray::base::InFlightFrame::mAuxiliaryCommandBuffers
protected

Auxiliary command buffers.

◆ mContext

core::Context* foray::base::InFlightFrame::mContext = nullptr
protected

◆ mPrimaryCommandBuffer

core::DeviceSyncCommandBuffer foray::base::InFlightFrame::mPrimaryCommandBuffer
protected

Primary command buffer.

◆ mPrimaryCompletedFence

VkFence foray::base::InFlightFrame::mPrimaryCompletedFence = nullptr
protected

Fence signalled after the primary / all command buffers have finished execution.

◆ mPrimaryCompletedSemaphore

VkSemaphore foray::base::InFlightFrame::mPrimaryCompletedSemaphore = nullptr
protected

Semaphore signalled by the primary command buffer when execution has finished.

◆ mSwapchainImageIndex

uint32_t foray::base::InFlightFrame::mSwapchainImageIndex = 0
protected

◆ mSwapchainImageReady

VkSemaphore foray::base::InFlightFrame::mSwapchainImageReady = nullptr
protected

Semaphore signalled by the device when the swapchain image becomes ready.


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