Foray Library
rapid prototyping framework for crossplatform development of vulkan hardware ray tracing applications
Loading...
Searching...
No Matches
foray_inflightframe.hpp
Go to the documentation of this file.
1#pragma once
2#include "../core/foray_commandbuffer.hpp"
3#include "../core/foray_core_declares.hpp"
4#include <vector>
5
6namespace foray::base {
7
10 {
12 Nominal,
15 };
16
17 using CmdBufferIndex = int32_t;
18 static const CmdBufferIndex PRIMARY_COMMAND_BUFFER = -1;
19
32 {
33 public:
34 void Create(core::Context* context, uint32_t auxCommandBufferCount = 0);
35 void Destroy();
36
37 inline virtual ~InFlightFrame() { Destroy(); }
38
45
47 void ClearSwapchainImage(VkCommandBuffer cmdBuffer, core::ImageLayoutCache& imgLayoutCache);
49 void PrepareSwapchainImageForPresent(VkCommandBuffer cmdBuffer, core::ImageLayoutCache& imgLayoutCache);
50
56 void ResetFence();
57
60 void SubmitAll();
61
78
79 FORAY_GETTER_V(SwapchainImageIndex)
80 FORAY_GETTER_V(SwapchainImageReady)
81 FORAY_GETTER_V(PrimaryCompletedSemaphore)
82 FORAY_GETTER_V(PrimaryCompletedFence)
83
84 protected:
86
88 std::vector<std::unique_ptr<core::DeviceSyncCommandBuffer>> mAuxiliaryCommandBuffers;
92 VkSemaphore mSwapchainImageReady = nullptr;
94 VkSemaphore mPrimaryCompletedSemaphore = nullptr;
96 VkFence mPrimaryCompletedFence = nullptr;
97
99 };
100} // namespace foray::base
Wraps synchronization primitives and command buffers for an inflight frame.
Definition foray_inflightframe.hpp:32
VkSemaphore mSwapchainImageReady
Semaphore signalled by the device when the swapchain image becomes ready.
Definition foray_inflightframe.hpp:92
void WaitForExecutionFinished()
Blocks the current thread until the frame has finished execution.
VkSemaphore mPrimaryCompletedSemaphore
Semaphore signalled by the primary command buffer when execution has finished.
Definition foray_inflightframe.hpp:94
const core::DeviceSyncCommandBuffer & GetAuxiliaryCommandBuffer(uint32_t index) const
Get an auxiliary command buffer.
const core::DeviceSyncCommandBuffer & GetPrimaryCommandBuffer() const
Get primary command buffer.
ESwapchainInteractResult AcquireSwapchainImage()
Acquires next swapchain image and stores the resulting index in mSwapchainImageIndex.
virtual ~InFlightFrame()
Definition foray_inflightframe.hpp:37
ESwapchainInteractResult Present()
Presents the previously acquired image. The primary command buffer must have been submitted prior to ...
bool HasFinishedExecution()
Non-blocking check wether the frame has been finished execution.
std::vector< std::unique_ptr< core::DeviceSyncCommandBuffer > > mAuxiliaryCommandBuffers
Auxiliary command buffers.
Definition foray_inflightframe.hpp:88
core::DeviceSyncCommandBuffer & GetPrimaryCommandBuffer()
Get primary command buffer.
core::Context * mContext
Definition foray_inflightframe.hpp:85
core::DeviceSyncCommandBuffer & GetCommandBuffer(CmdBufferIndex index)
Get a command buffer.
void SubmitAll()
Submits all command buffers by getting all VkSubmitInfo2{} structures from DeviceSyncCommandBuffer::W...
uint32_t mSwapchainImageIndex
Definition foray_inflightframe.hpp:98
void ResetFence()
Resets the frames host synchronization fence.
void PrepareSwapchainImageForPresent(VkCommandBuffer cmdBuffer, core::ImageLayoutCache &imgLayoutCache)
Adds a Pipeline barrier transitioning the swapchain image into present layout and assuring all writes...
VkFence mPrimaryCompletedFence
Fence signalled after the primary / all command buffers have finished execution.
Definition foray_inflightframe.hpp:96
core::DeviceSyncCommandBuffer & GetAuxiliaryCommandBuffer(uint32_t index)
Get an auxiliary command buffer.
void ClearSwapchainImage(VkCommandBuffer cmdBuffer, core::ImageLayoutCache &imgLayoutCache)
Writes vkCmdClearColorImage cmd to the primary command buffer for the acquired image.
const core::DeviceSyncCommandBuffer & GetCommandBuffer(CmdBufferIndex index) const
Get a command buffer.
core::DeviceSyncCommandBuffer mPrimaryCommandBuffer
Primary command buffer.
Definition foray_inflightframe.hpp:90
void Create(core::Context *context, uint32_t auxCommandBufferCount=0)
Extension of the commandbuffer wrapper for device and/or host synchronized command buffer execution.
Definition foray_commandbuffer.hpp:90
Tracks ImageLayouts over the course of a frame rendering process.
Definition foray_imagelayoutcache.hpp:13
#define FORAY_GETTER_V(member)
Return value.
Definition foray_basics.hpp:39
Definition foray_base_declares.hpp:3
ESwapchainInteractResult
Result of swapchain interaction (AcquireImage or Present)
Definition foray_inflightframe.hpp:10
@ Resized
The interaction indicated that the swapchain should be resized.
@ Nominal
The interaction resulted nominally.
int32_t CmdBufferIndex
Definition foray_inflightframe.hpp:17
Non owning context object.
Definition foray_context.hpp:16