18#ifndef INCLUDED_RENDERER_BACKEND_VULKAN_SWAPCHAIN
19#define INCLUDED_RENDERER_BACKEND_VULKAN_SWAPCHAIN
27#include <glad/vulkan.h>
31#include <unordered_map>
74 void Present(VkSemaphore submitDone, VkQueue queue);
85 static std::unique_ptr<CSwapChain>
Create(
87 const uint32_t queueFamilyIndex, VkQueue queue,
88 const char* name, VkSurfaceKHR surface,
89 int surfaceDrawableWidth,
int surfaceDrawableHeight,
90 const bool vsync, std::unique_ptr<ISwapChain> oldSwapChain);
Represents a texture object.
Definition: TextureManager.h:271
IFramebuffer stores attachments which should be used by backend as rendering destinations.
Definition: IFramebuffer.h:87
Definition: ISwapChain.h:33
A simple helper class to decouple command buffers rotation from frames presenting.
Definition: RingCommandContext.h:53
A helper class to batch VkQueueSubmit calls and track VkCommandBuffer usages properly.
Definition: SubmitScheduler.h:46
static constexpr SubmitHandle INVALID_SUBMIT_HANDLE
Definition: SubmitScheduler.h:49
uint32_t SubmitHandle
Definition: SubmitScheduler.h:48
Definition: SwapChain.h:49
bool m_IsValid
Definition: SwapChain.h:98
std::vector< FrameObject > m_FrameObjects
Definition: SwapChain.h:120
IDevice * GetDevice() override
Definition: SwapChain.cpp:348
~CSwapChain() override
Definition: SwapChain.cpp:322
bool m_DebugWaitIdleAfterPresent
Definition: SwapChain.h:167
std::unique_ptr< CTexture > m_DepthTexture
Definition: SwapChain.h:105
uint32_t m_FrameID
Definition: SwapChain.h:108
VkSwapchainKHR GetVkSwapchain()
Definition: SwapChain.h:67
VkQueue m_Queue
Definition: SwapChain.h:96
IFramebuffer * GetCurrentBackbuffer(const AttachmentLoadOp colorAttachmentLoadOp, const AttachmentStoreOp colorAttachmentStoreOp, const AttachmentLoadOp depthStencilAttachmentLoadOp, const AttachmentStoreOp depthStencilAttachmentStoreOp) override
Returns a framebuffer for the current backbuffer with the required attachment operations.
Definition: SwapChain.cpp:512
CTexture * GetDepthTexture()
Definition: SwapChain.h:80
CDevice * m_Device
Definition: SwapChain.h:94
bool m_DebugWaitIdleBeforeAcquire
Definition: SwapChain.h:165
bool IsValid() const override
Definition: SwapChain.h:55
std::unique_ptr< CRingCommandContext > m_AcquireCommandContext
Definition: SwapChain.h:162
CTexture * GetOrCreateBackbufferReadbackTexture()
Definition: SwapChain.cpp:553
std::vector< VkImage > m_Images
Definition: SwapChain.h:103
CSubmitScheduler * m_SubmitScheduler
Definition: SwapChain.h:95
void SubmitCommandsAfterAcquireNextImage(CRingCommandContext &commandContext)
Definition: SwapChain.cpp:446
std::vector< SwapChainBackbuffer > m_Backbuffers
Definition: SwapChain.h:158
VkSwapchainKHR m_SwapChain
Definition: SwapChain.h:99
bool AcquireNextBackbuffer() override
Acquires a backbuffer for rendering a frame.
Definition: SwapChain.cpp:353
bool m_DebugWaitIdleBeforePresent
Definition: SwapChain.h:166
VkFormat m_ImageFormat
Definition: SwapChain.h:106
std::unique_ptr< CTexture > m_BackbufferReadbackTexture
Definition: SwapChain.h:160
bool AcquireNextImage()
Definition: SwapChain.cpp:422
std::vector< VkSemaphore > m_SubmitSemaphores
Definition: SwapChain.h:136
void SubmitCommandsBeforePresent(CRingCommandContext &commandContext)
Definition: SwapChain.cpp:470
std::vector< std::unique_ptr< CTexture > > m_Textures
Definition: SwapChain.h:104
CTexture * GetCurrentBackbufferTexture()
Definition: SwapChain.cpp:547
void Present() override
Presents the backbuffer to the swapchain queue to be flipped on a screen.
Definition: SwapChain.cpp:380
static std::unique_ptr< CSwapChain > Create(CDevice *device, CSubmitScheduler *submitScheduler, const uint32_t queueFamilyIndex, VkQueue queue, const char *name, VkSurfaceKHR surface, int surfaceDrawableWidth, int surfaceDrawableHeight, const bool vsync, std::unique_ptr< ISwapChain > oldSwapChain)
Definition: SwapChain.cpp:55
uint32_t m_CurrentImageIndex
Definition: SwapChain.h:101
std::unique_ptr< CRingCommandContext > m_PresentCommandContext
Definition: SwapChain.h:163
Definition: Buffer.cpp:37
AttachmentStoreOp
Store operation is set for each attachment, what should be done with its content on EndFramebufferPas...
Definition: IFramebuffer.h:54
Backend
Definition: Backend.h:28
AttachmentLoadOp
Load operation is set for each attachment, what should be done with its content on BeginFramebufferPa...
Definition: IFramebuffer.h:39
Definition: Canvas2D.h:30
Definition: SwapChain.h:115
CSubmitScheduler::SubmitHandle submitHandle
Definition: SwapChain.h:118
VkSemaphore acquireImageSemaphore
Definition: SwapChain.h:116
Definition: SwapChain.h:144
size_t operator()(const BackbufferKey &key) const
Definition: SwapChain.cpp:406
Definition: SwapChain.h:139
SwapChainBackbuffer & operator=(SwapChainBackbuffer &&other)
SwapChainBackbuffer(const SwapChainBackbuffer &)=delete
SwapChainBackbuffer & operator=(const SwapChainBackbuffer &)=delete
std::unordered_map< BackbufferKey, std::unique_ptr< CFramebuffer >, BackbufferKeyHash > backbuffers
Definition: SwapChain.h:148
SwapChainBackbuffer(SwapChainBackbuffer &&other)
std::tuple< AttachmentLoadOp, AttachmentStoreOp, AttachmentLoadOp, AttachmentStoreOp > BackbufferKey
Definition: SwapChain.h:142
pthread_key_t key
Definition: wpthread.cpp:141