Manages Vulkan swapchain resources. More...
#include <SwapchainManager.hpp>
Public Member Functions | |
| VulkanSwapchainManager (VulkanContext &context, SDL_Window *window) | |
| Constructor for VulkanSwapchainManager. | |
| ~VulkanSwapchainManager () | |
| Simple destructor. | |
| void | createSwapchain () |
| Creates or recreates the swapchain. | |
| void | cleanupSwapchain () |
| Cleans up swapchain resources. | |
| void | cleanupSyncObjects () |
| Cleans up synchronization objects. | |
| void | recreateSwapchain () |
| Recreates the swapchain. | |
| void | setVSync (bool enabled) |
| Sets the vsync enabled state. | |
Private Member Functions | |
| void | createImageViews () |
| Helper function to create image views for swapchain images. | |
| void | createCommandPool () |
| Helper function to create command pool for swapchain creation. | |
| void | createCommandBuffers () |
| Helper function to create command buffers for swapchain creation. | |
| void | createSyncObjects () |
| Helper function to create synchronization objects for swapchain creation. | |
| void | createDepthResources () |
| Helper function to create depth resources for swapchain creation. | |
| void | createLowResResources () |
| Helper function to create low resolution resources for low res rendering. | |
| void | cleanupLowResResources () |
| Helper function to cleanup low resolution resources, since low res resources can be changed without changing window resiolution. | |
| VkSurfaceFormatKHR | chooseSwapSurfaceFormat (const std::vector< VkSurfaceFormatKHR > &availableFormats) |
| Helper function choosing SwapSurfaceFormat based on hardware capabilities. | |
| VkPresentModeKHR | chooseSwapPresentMode (const std::vector< VkPresentModeKHR > &availablePresentModes) |
| Helper function choosing SwapPresentMode based on hardware capabilities. | |
| VkExtent2D | chooseSwapExtent (const VkSurfaceCapabilitiesKHR &capabilities) |
| Helper function choosing SwapExtent based on hardware capabilities. | |
| VkFormat | findDepthFormat () |
| Helper function to find depth format based on hardware capabilities. | |
Private Attributes | |
| VulkanContext & | m_r_context |
| SDL_Window * | m_p_window |
| bool | m_vsyncEnabled = false |
Manages Vulkan swapchain resources.
Definition at line 21 of file SwapchainManager.hpp.
| vex::VulkanSwapchainManager::VulkanSwapchainManager | ( | VulkanContext & | context, |
| SDL_Window * | window ) |
Constructor for VulkanSwapchainManager.
| VulkanContext& | context - Context to store swapchain images/views. |
| SDL_Window* | window - Window to query surface capabilities from. |
Definition at line 12 of file SwapchainManager.cpp.
| vex::VulkanSwapchainManager::~VulkanSwapchainManager | ( | ) |
Simple destructor.
Definition at line 15 of file SwapchainManager.cpp.
|
private |
Helper function choosing SwapExtent based on hardware capabilities.
| const | VkSurfaceCapabilitiesKHR& capabilities |
Definition at line 639 of file SwapchainManager.cpp.
|
private |
Helper function choosing SwapPresentMode based on hardware capabilities.
| const | std::vector<VkPresentModeKHR>& availablePresentModes |
Definition at line 623 of file SwapchainManager.cpp.
|
private |
Helper function choosing SwapSurfaceFormat based on hardware capabilities.
| const | std::vector<VkSurfaceFormatKHR>& availableFormats |
Definition at line 608 of file SwapchainManager.cpp.
|
private |
Helper function to cleanup low resolution resources, since low res resources can be changed without changing window resiolution.
Definition at line 463 of file SwapchainManager.cpp.
| void vex::VulkanSwapchainManager::cleanupSwapchain | ( | ) |
Cleans up swapchain resources.
Destroys image views, depth buffers, framebuffers, and the swapchain itself.
Definition at line 527 of file SwapchainManager.cpp.
| void vex::VulkanSwapchainManager::cleanupSyncObjects | ( | ) |
Cleans up synchronization objects.
Destroys Semaphores (ImageAvailable/RenderFinished) and Fences (InFlight).
Definition at line 551 of file SwapchainManager.cpp.
|
private |
Helper function to create command buffers for swapchain creation.
Definition at line 259 of file SwapchainManager.cpp.
|
private |
Helper function to create command pool for swapchain creation.
Definition at line 228 of file SwapchainManager.cpp.
|
private |
Helper function to create depth resources for swapchain creation.
Definition at line 146 of file SwapchainManager.cpp.
|
private |
Helper function to create image views for swapchain images.
Definition at line 200 of file SwapchainManager.cpp.
|
private |
Helper function to create low resolution resources for low res rendering.
Definition at line 328 of file SwapchainManager.cpp.
| void vex::VulkanSwapchainManager::createSwapchain | ( | ) |
Creates or recreates the swapchain.
Selects surface format, present mode (FIFO/Mailbox), and extent. Creates Swapchain, Image Views, Depth Resources, and Low-Res offscreen resources.
Definition at line 20 of file SwapchainManager.cpp.
|
private |
Helper function to create synchronization objects for swapchain creation.
Definition at line 281 of file SwapchainManager.cpp.
|
private |
Helper function to find depth format based on hardware capabilities.
Definition at line 665 of file SwapchainManager.cpp.
| void vex::VulkanSwapchainManager::recreateSwapchain | ( | ) |
Recreates the swapchain.
Calls cleanupSwapchain followed by createSwapchain. Typically called on window resize.
Definition at line 575 of file SwapchainManager.cpp.
| void vex::VulkanSwapchainManager::setVSync | ( | bool | enabled | ) |
Sets the vsync enabled state.
Stores the preference. Effect takes place on next createSwapchain call (usually triggered via Interface).
| bool | enabled - True for VSync (FIFO), False for Uncapped (Immediate/Mailbox). |
Definition at line 619 of file SwapchainManager.cpp.
|
private |
Definition at line 94 of file SwapchainManager.hpp.
|
private |
Definition at line 93 of file SwapchainManager.hpp.
|
private |
Definition at line 95 of file SwapchainManager.hpp.