Handles creation, extent negotiation, rendering passes, and framebuffer generation for Vulkan Swapchains.
More...
#include <VulkanSwapChain.hpp>
|
| | VulkanSwapchain ()=default |
| | Construct a new Vulkan Swapchain object.
|
| | ~VulkanSwapchain () |
| | Destroy the Vulkan Swapchain object and release swapchain structures.
|
| void | initialize (VkDevice device, VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, uint32_t graphicsQueueFamily) |
| | Sets up parameters, selects formats, builds KHR swapchain, views, render pass and framebuffers.
|
| void | cleanup () |
| | Safely destroys framebuffers, render pass, image views, and swapchain handles.
|
| VkFormat | getImageFormat () const |
| | Gets selected swapchain format.
|
| VkExtent2D | getExtent () const |
| | Gets resolution extent details.
|
| const std::vector< VkFramebuffer > & | getFramebuffers () const |
| | Gets active framebuffers list.
|
| VkRenderPass | getRenderPass () const |
| | Gets default render pass for swapchain buffers.
|
| VkSwapchainKHR | getSwapchain () const |
| | Gets raw KHR swapchain.
|
|
| void | createSwapchain (uint32_t graphicsQueueFamily) |
| | Establishes the KHR swapchain handle.
|
| void | createImageViews () |
| | Creates image views for each swapchain image.
|
| void | createRenderPass () |
| | Configures render pass layouts.
|
| void | createFramebuffers () |
| | Creates framebuffers linking image views to the render pass.
|
| void | createDepthResources () |
| | Creates depth buffers and views.
|
| VkFormat | findDepthFormat () |
| | Helper to query and select best depth format.
|
| VkFormat | findSupportedFormat (const std::vector< VkFormat > &candidates, VkImageTiling tiling, VkFormatFeatureFlags features) |
| | Helper to find supported depth formats.
|
| uint32_t | findMemoryType (uint32_t typeFilter, VkMemoryPropertyFlags properties) |
| | Helper to query suitable GPU memory index.
|
| VkSurfaceFormatKHR | chooseSurfaceFormat (const std::vector< VkSurfaceFormatKHR > &formats) |
| | Selects optimal color format and color space.
|
| VkPresentModeKHR | choosePresentMode (const std::vector< VkPresentModeKHR > &modes) |
| | Selects optimal presentation mode (e.g. Mailbox or FIFO).
|
| VkExtent2D | chooseExtent (const VkSurfaceCapabilitiesKHR &capabilities) |
| | Resolves swapchain resolution boundaries against hardware limits.
|
|
| VkDevice | device = VK_NULL_HANDLE |
| | Reference to logical device.
|
| VkPhysicalDevice | physicalDevice = VK_NULL_HANDLE |
| | Reference to physical device.
|
| VkSurfaceKHR | surface = VK_NULL_HANDLE |
| | Reference to presentation surface.
|
| VkSwapchainKHR | swapchain = VK_NULL_HANDLE |
| | Raw swapchain handle.
|
| std::vector< VkImage > | images |
| | Retrieved swapchain images.
|
| std::vector< VkImageView > | imageViews |
| | image views wrapping swapchain images.
|
| std::vector< VkFramebuffer > | framebuffers |
| | framebuffers wrapping image views.
|
| VkFormat | imageFormat {} |
| | image format of swapchain buffers.
|
| VkExtent2D | extent {} |
| | image extent (resolution) of swapchain buffers.
|
| VkRenderPass | renderPass = VK_NULL_HANDLE |
| | Render pass used for frame clearing and drawing.
|
| VkImage | depthImage = VK_NULL_HANDLE |
| | GPU depth image allocation handle.
|
| VkDeviceMemory | depthImageMemory = VK_NULL_HANDLE |
| | GPU depth memory handle.
|
| VkImageView | depthImageView = VK_NULL_HANDLE |
| | Depth image view wrapper.
|
| VkFormat | depthFormat = VK_FORMAT_D32_SFLOAT |
| | Selected depth format.
|
Handles creation, extent negotiation, rendering passes, and framebuffer generation for Vulkan Swapchains.
◆ VulkanSwapchain()
| VulkanSwapchain::VulkanSwapchain |
( |
| ) |
|
|
default |
Construct a new Vulkan Swapchain object.
◆ ~VulkanSwapchain()
| VulkanSwapchain::~VulkanSwapchain |
( |
| ) |
|
Destroy the Vulkan Swapchain object and release swapchain structures.
Destroy the Vulkan Swapchain:: Vulkan Swapchain object.
◆ chooseExtent()
| VkExtent2D VulkanSwapchain::chooseExtent |
( |
const VkSurfaceCapabilitiesKHR & | capabilities | ) |
|
|
private |
Resolves swapchain resolution boundaries against hardware limits.
Adjusts resolution bounds matching capabilities.
- Parameters
-
| capabilities | Surface capabilities. |
- Returns
- Optimal swapchain extent.
- Parameters
-
| capabilities | Surface capabilities. |
- Returns
- Frame buffer extent.
◆ choosePresentMode()
| VkPresentModeKHR VulkanSwapchain::choosePresentMode |
( |
const std::vector< VkPresentModeKHR > & | modes | ) |
|
|
private |
Selects optimal presentation mode (e.g. Mailbox or FIFO).
Chooses presentation mode (prioritizes Mailbox, defaults to FIFO).
- Parameters
-
| modes | List of supported modes. |
- Returns
- Ideal present mode.
- Parameters
-
| modes | Available present modes. |
- Returns
- Present mode.
◆ chooseSurfaceFormat()
| VkSurfaceFormatKHR VulkanSwapchain::chooseSurfaceFormat |
( |
const std::vector< VkSurfaceFormatKHR > & | formats | ) |
|
|
private |
Selects optimal color format and color space.
- Parameters
-
| formats | List of supported formats. |
- Returns
- Ideal surface format.
- Parameters
-
| formats | List of supported formats. |
- Returns
- Surface format.
◆ cleanup()
| void VulkanSwapchain::cleanup |
( |
| ) |
|
Safely destroys framebuffers, render pass, image views, and swapchain handles.
Destroys framebuffers, render pass, image views, and swapchain handles.
◆ createDepthResources()
| void VulkanSwapchain::createDepthResources |
( |
| ) |
|
|
private |
Creates depth buffers and views.
◆ createFramebuffers()
| void VulkanSwapchain::createFramebuffers |
( |
| ) |
|
|
private |
Creates framebuffers linking image views to the render pass.
Instantiates framebuffers binding image views to the render pass.
◆ createImageViews()
| void VulkanSwapchain::createImageViews |
( |
| ) |
|
|
private |
Creates image views for each swapchain image.
Wraps swapchain images into VkImageView descriptors.
◆ createRenderPass()
| void VulkanSwapchain::createRenderPass |
( |
| ) |
|
|
private |
Configures render pass layouts.
Configures layouts and subpass parameters, creating the default render pass.
◆ createSwapchain()
| void VulkanSwapchain::createSwapchain |
( |
uint32_t | graphicsQueueFamily | ) |
|
|
private |
Establishes the KHR swapchain handle.
Checks capabilities and creates swapchain object.
- Parameters
-
| graphicsQueueFamily | Queue family index. |
| graphicsQueueFamily | Graphics queue family index. |
◆ findDepthFormat()
| VkFormat VulkanSwapchain::findDepthFormat |
( |
| ) |
|
|
private |
Helper to query and select best depth format.
◆ findMemoryType()
| uint32_t VulkanSwapchain::findMemoryType |
( |
uint32_t | typeFilter, |
|
|
VkMemoryPropertyFlags | properties ) |
|
private |
Helper to query suitable GPU memory index.
◆ findSupportedFormat()
| VkFormat VulkanSwapchain::findSupportedFormat |
( |
const std::vector< VkFormat > & | candidates, |
|
|
VkImageTiling | tiling, |
|
|
VkFormatFeatureFlags | features ) |
|
private |
Helper to find supported depth formats.
◆ getExtent()
| VkExtent2D VulkanSwapchain::getExtent |
( |
| ) |
const |
|
inline |
Gets resolution extent details.
- Returns
- VkExtent2D.
◆ getFramebuffers()
| const std::vector< VkFramebuffer > & VulkanSwapchain::getFramebuffers |
( |
| ) |
const |
|
inline |
Gets active framebuffers list.
- Returns
- Vector of framebuffer handles.
◆ getImageFormat()
| VkFormat VulkanSwapchain::getImageFormat |
( |
| ) |
const |
|
inline |
Gets selected swapchain format.
- Returns
- VkFormat.
◆ getRenderPass()
| VkRenderPass VulkanSwapchain::getRenderPass |
( |
| ) |
const |
|
inline |
Gets default render pass for swapchain buffers.
- Returns
- VkRenderPass.
◆ getSwapchain()
| VkSwapchainKHR VulkanSwapchain::getSwapchain |
( |
| ) |
const |
|
inline |
Gets raw KHR swapchain.
- Returns
- VkSwapchainKHR.
◆ initialize()
| void VulkanSwapchain::initialize |
( |
VkDevice | dev, |
|
|
VkPhysicalDevice | phys, |
|
|
VkSurfaceKHR | surf, |
|
|
uint32_t | queueFamily ) |
Sets up parameters, selects formats, builds KHR swapchain, views, render pass and framebuffers.
Binds references and initializes swapchain creation.
- Parameters
-
| device | Vulkan logical device context. |
| physicalDevice | Vulkan physical device. |
| surface | Presentation surface context. |
| graphicsQueueFamily | Target graphics family index. |
| dev | Logical device context. |
| phys | Physical device. |
| surf | Presentation surface context. |
| queueFamily | Graphics queue family index. |
◆ depthFormat
| VkFormat VulkanSwapchain::depthFormat = VK_FORMAT_D32_SFLOAT |
|
private |
◆ depthImage
| VkImage VulkanSwapchain::depthImage = VK_NULL_HANDLE |
|
private |
GPU depth image allocation handle.
◆ depthImageMemory
| VkDeviceMemory VulkanSwapchain::depthImageMemory = VK_NULL_HANDLE |
|
private |
◆ depthImageView
| VkImageView VulkanSwapchain::depthImageView = VK_NULL_HANDLE |
|
private |
Depth image view wrapper.
◆ device
| VkDevice VulkanSwapchain::device = VK_NULL_HANDLE |
|
private |
Reference to logical device.
◆ extent
| VkExtent2D VulkanSwapchain::extent {} |
|
private |
image extent (resolution) of swapchain buffers.
◆ framebuffers
| std::vector<VkFramebuffer> VulkanSwapchain::framebuffers |
|
private |
framebuffers wrapping image views.
◆ imageFormat
| VkFormat VulkanSwapchain::imageFormat {} |
|
private |
image format of swapchain buffers.
◆ images
| std::vector<VkImage> VulkanSwapchain::images |
|
private |
Retrieved swapchain images.
◆ imageViews
| std::vector<VkImageView> VulkanSwapchain::imageViews |
|
private |
image views wrapping swapchain images.
◆ physicalDevice
| VkPhysicalDevice VulkanSwapchain::physicalDevice = VK_NULL_HANDLE |
|
private |
Reference to physical device.
◆ renderPass
| VkRenderPass VulkanSwapchain::renderPass = VK_NULL_HANDLE |
|
private |
Render pass used for frame clearing and drawing.
◆ surface
| VkSurfaceKHR VulkanSwapchain::surface = VK_NULL_HANDLE |
|
private |
Reference to presentation surface.
◆ swapchain
| VkSwapchainKHR VulkanSwapchain::swapchain = VK_NULL_HANDLE |
|
private |
The documentation for this class was generated from the following files: