VEX Engine
Retro looking game engine made in vulkan mostly because i wanted to understand it better.
Loading...
Searching...
No Matches
vex::VulkanSwapchainManager Class Reference

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

VulkanContextm_r_context
SDL_Window * m_p_window
bool m_vsyncEnabled = false

Detailed Description

Manages Vulkan swapchain resources.

Definition at line 21 of file SwapchainManager.hpp.

Constructor & Destructor Documentation

◆ VulkanSwapchainManager()

vex::VulkanSwapchainManager::VulkanSwapchainManager ( VulkanContext & context,
SDL_Window * window )

Constructor for VulkanSwapchainManager.

Parameters
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.

◆ ~VulkanSwapchainManager()

vex::VulkanSwapchainManager::~VulkanSwapchainManager ( )

Simple destructor.

Definition at line 15 of file SwapchainManager.cpp.

Member Function Documentation

◆ chooseSwapExtent()

VkExtent2D vex::VulkanSwapchainManager::chooseSwapExtent ( const VkSurfaceCapabilitiesKHR & capabilities)
private

Helper function choosing SwapExtent based on hardware capabilities.

Parameters
constVkSurfaceCapabilitiesKHR& capabilities
Returns
VkExtent2D.

Definition at line 639 of file SwapchainManager.cpp.

◆ chooseSwapPresentMode()

VkPresentModeKHR vex::VulkanSwapchainManager::chooseSwapPresentMode ( const std::vector< VkPresentModeKHR > & availablePresentModes)
private

Helper function choosing SwapPresentMode based on hardware capabilities.

Parameters
conststd::vector<VkPresentModeKHR>& availablePresentModes
Returns
VkPresentModeKHR.

Definition at line 623 of file SwapchainManager.cpp.

◆ chooseSwapSurfaceFormat()

VkSurfaceFormatKHR vex::VulkanSwapchainManager::chooseSwapSurfaceFormat ( const std::vector< VkSurfaceFormatKHR > & availableFormats)
private

Helper function choosing SwapSurfaceFormat based on hardware capabilities.

Parameters
conststd::vector<VkSurfaceFormatKHR>& availableFormats
Returns
VkSurfaceFormatKHR.

Definition at line 608 of file SwapchainManager.cpp.

◆ cleanupLowResResources()

void vex::VulkanSwapchainManager::cleanupLowResResources ( )
private

Helper function to cleanup low resolution resources, since low res resources can be changed without changing window resiolution.

See also
ResolutionManager

Definition at line 463 of file SwapchainManager.cpp.

◆ cleanupSwapchain()

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.

◆ cleanupSyncObjects()

void vex::VulkanSwapchainManager::cleanupSyncObjects ( )

Cleans up synchronization objects.

Destroys Semaphores (ImageAvailable/RenderFinished) and Fences (InFlight).

Definition at line 551 of file SwapchainManager.cpp.

◆ createCommandBuffers()

void vex::VulkanSwapchainManager::createCommandBuffers ( )
private

Helper function to create command buffers for swapchain creation.

Definition at line 259 of file SwapchainManager.cpp.

◆ createCommandPool()

void vex::VulkanSwapchainManager::createCommandPool ( )
private

Helper function to create command pool for swapchain creation.

Definition at line 228 of file SwapchainManager.cpp.

◆ createDepthResources()

void vex::VulkanSwapchainManager::createDepthResources ( )
private

Helper function to create depth resources for swapchain creation.

Definition at line 146 of file SwapchainManager.cpp.

◆ createImageViews()

void vex::VulkanSwapchainManager::createImageViews ( )
private

Helper function to create image views for swapchain images.

Definition at line 200 of file SwapchainManager.cpp.

◆ createLowResResources()

void vex::VulkanSwapchainManager::createLowResResources ( )
private

Helper function to create low resolution resources for low res rendering.

Definition at line 328 of file SwapchainManager.cpp.

◆ createSwapchain()

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.

◆ createSyncObjects()

void vex::VulkanSwapchainManager::createSyncObjects ( )
private

Helper function to create synchronization objects for swapchain creation.

Definition at line 281 of file SwapchainManager.cpp.

◆ findDepthFormat()

VkFormat vex::VulkanSwapchainManager::findDepthFormat ( )
private

Helper function to find depth format based on hardware capabilities.

Returns
VkFormat.

Definition at line 665 of file SwapchainManager.cpp.

◆ recreateSwapchain()

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.

◆ setVSync()

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).

Parameters
boolenabled - True for VSync (FIFO), False for Uncapped (Immediate/Mailbox).

Definition at line 619 of file SwapchainManager.cpp.

Member Data Documentation

◆ m_p_window

SDL_Window* vex::VulkanSwapchainManager::m_p_window
private

Definition at line 94 of file SwapchainManager.hpp.

◆ m_r_context

VulkanContext& vex::VulkanSwapchainManager::m_r_context
private

Definition at line 93 of file SwapchainManager.hpp.

◆ m_vsyncEnabled

bool vex::VulkanSwapchainManager::m_vsyncEnabled = false
private

Definition at line 95 of file SwapchainManager.hpp.


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