evan 2026.1.4
Evan
Loading...
Searching...
No Matches
evan::DesktopSwapchainImage Class Reference

A swapchain image implementation for desktop platforms using GLFW. More...

#include <headers/evan/glfw/DesktopSwapchainImage.hpp>

Inheritance diagram for evan::DesktopSwapchainImage:
Collaboration diagram for evan::DesktopSwapchainImage:

Public Member Functions

 DesktopSwapchainImage (const DeviceContext &deviceContext, GLFWwindow *window, VkRenderPass renderpass, VkSwapchainKHR oldSwapchain=VK_NULL_HANDLE)
 Constructs a DesktopSwapchainImage instance for a given device context, GLFW window, and render pass.
 
void destroy (VkDevice device) override
 Destroys the swapchain image and releases associated resources.
 
void fillPresentInfo (VkPresentInfoKHR &presentInfo) const override
 Fills the VkPresentInfoKHR structure with the necessary information for presenting the swapchain image.
 
- Public Member Functions inherited from evan::ASwapchainImage
VkFramebuffer getFramebuffer (uint32_t index) const
 Retrieves the Vulkan framebuffer associated with the swapchain image at the specified index.
 
VkExtent2D getExtent () const
 Retrieves the extent (width and height) of the swapchain images.
 
uint32_t getFramebufferCount () const
 Retrieves the number of framebuffers associated with the swapchain images.
 

Public Attributes

VkSwapchainKHR _swapchain = VK_NULL_HANDLE
 

Additional Inherited Members

- Static Public Member Functions inherited from evan::ASwapchainImage
static VkFormat findDepthFormat (VkPhysicalDevice physicalDevice)
 Finds a supported depth format for the swapchain context.
 
static VkFormat findSupportedFormat (VkPhysicalDevice physicalDevice, const std::vector< VkFormat > &candidates, VkImageTiling tiling, VkFormatFeatureFlags features)
 Finds a supported format from a list of candidates based on the specified tiling and features.
 
- Protected Member Functions inherited from evan::ASwapchainImage
void createImageViews (const ADeviceBackend &deviceBackend)
 Creates image views for the swapchain images.
 
void createColorResources (const ADeviceBackend &deviceBackend, VkSampleCountFlagBits msaaSamples)
 Creates a multisampled color attachment and its image view.
 
void createDepthResources (const DeviceContext &deviceContext, VkSampleCountFlagBits msaaSamples)
 Creates depth resources for the swapchain images.
 
void createFramebuffers (VkDevice logicalDevice, VkRenderPass renderPass, ColorAttachmentMode mode)
 Creates framebuffers for the swapchain images.
 
void createImages (VkDevice logicalDevice, VkSwapchainKHR swapchain)
 Creates the Vulkan images for the swapchain.
 
- Protected Attributes inherited from evan::ASwapchainImage
VkImage _depthImage = VK_NULL_HANDLE
 
VkImageView _depthView = VK_NULL_HANDLE
 
VkDeviceMemory _depthMemory = VK_NULL_HANDLE
 
VkImage _colorImage = VK_NULL_HANDLE
 
VkImageView _colorView = VK_NULL_HANDLE
 
VkDeviceMemory _colorMemory = VK_NULL_HANDLE
 
std::vector< VkImageView > _imageViews
 
VkExtent2D _extent = { 0, 0 }
 
VkFormat _format = VK_FORMAT_UNDEFINED
 
uint32_t _arrayLayers = 1
 The number of array layers of the swapchain and attachment images.
 
std::vector< VkImage > _images
 
std::vector< VkFramebuffer > _framebuffers
 

Detailed Description

A swapchain image implementation for desktop platforms using GLFW.

This class manages the creation and presentation of swapchain images for a GLFW window. It handles the selection of surface formats, present modes, and swap extents based on the capabilities of the physical device and the window properties.

The DesktopSwapchainImage class inherits from ASwapchainImage and implements the necessary functionality to create and manage a Vulkan swapchain for a desktop application. It provides methods to destroy the swapchain and fill presentation information for presenting images to the screen.

See also
ASwapchainImage

Definition at line 34 of file DesktopSwapchainImage.hpp.

Constructor & Destructor Documentation

◆ DesktopSwapchainImage()

evan::DesktopSwapchainImage::DesktopSwapchainImage ( const DeviceContext &  deviceContext,
GLFWwindow *  window,
VkRenderPass  renderpass,
VkSwapchainKHR  oldSwapchain = VK_NULL_HANDLE 
)

Constructs a DesktopSwapchainImage instance for a given device context, GLFW window, and render pass.

This constructor initializes the swapchain image by creating a Vulkan swapchain based on the provided device context, GLFW window, and render pass. It selects appropriate surface formats, present modes, and swap extents to ensure optimal performance and compatibility with the rendering pipeline.

Parameters
deviceContextThe device context containing the Vulkan device and related resources needed for swapchain creation.
windowThe GLFW window for which the swapchain image is being created. The window properties are used to determine the swap extent and other parameters for the swapchain.
renderpassThe Vulkan render pass that will be used with the swapchain images during rendering operations. The render pass defines the attachments and subpasses that will be used when rendering to the swapchain images.
oldSwapchainThe previous swapchain to retire when recreating, or VK_NULL_HANDLE for the initial creation.
Note
The constructor performs several steps to create the swapchain, including:
  • Querying the physical device for swapchain support details.
  • Choosing appropriate surface formats, present modes, and swap extents based on the capabilities of the physical device and the properties of the GLFW window.
  • Creating the Vulkan swapchain and associated image views for rendering.
  • Storing the swapchain handle for later use in presentation and cleanup operations.

Definition at line 17 of file DesktopSwapchainImage.cpp.

Here is the call graph for this function:

◆ ~DesktopSwapchainImage()

evan::DesktopSwapchainImage::~DesktopSwapchainImage ( )

Definition at line 139 of file DesktopSwapchainImage.cpp.

Member Function Documentation

◆ destroy()

void evan::DesktopSwapchainImage::destroy ( VkDevice  device)
overridevirtual

Destroys the swapchain image and releases associated resources.

This function overrides the pure virtual destroy method from ASwapchainImage to handle the specific logic for destroying the Vulkan swapchain and releasing any resources associated with it. It takes a Vulkan device as a parameter, which is used to perform the necessary cleanup operations for the swapchain.

Parameters
deviceThe Vulkan device used to perform the cleanup operations for the swapchain image. This device is typically obtained from the device context and is used to destroy the swapchain and release associated resources.
Note
This function should ensure that all resources related to the swapchain image are properly released when the image is no longer needed, preventing memory leaks and ensuring efficient resource management in the rendering system.

Implements evan::ASwapchainImage.

Definition at line 149 of file DesktopSwapchainImage.cpp.

◆ fillPresentInfo()

void evan::DesktopSwapchainImage::fillPresentInfo ( VkPresentInfoKHR &  presentInfo) const
overridevirtual

Fills the VkPresentInfoKHR structure with the necessary information for presenting the swapchain image.

This function overrides the pure virtual fillPresentInfo method from ASwapchainImage to populate the VkPresentInfoKHR structure with the appropriate information required for presenting the swapchain image to the screen. It takes a reference to a VkPresentInfoKHR structure as a parameter, which should be filled with the necessary details such as the swapchain, image index, and synchronization primitives.

Parameters
presentInfoA reference to a VkPresentInfoKHR structure that should be filled with the necessary information for presenting the swapchain image. This structure is used by the rendering system to present rendered frames using the swapchain images, and it must be correctly populated to ensure proper presentation behavior.
Note
This function should handle the specific logic for filling the presentation information for swapchain images in the context of the rendering system, ensuring that all required fields in the VkPresentInfoKHR structure are correctly set based on the swapchain and rendering pipeline configuration.

Implements evan::ASwapchainImage.

Definition at line 225 of file DesktopSwapchainImage.cpp.

Member Data Documentation

◆ _swapchain

VkSwapchainKHR evan::DesktopSwapchainImage::_swapchain = VK_NULL_HANDLE

The Vulkan swapchain associated with this swapchain image. The swapchain is created during the initialization of the DesktopSwapchainImage instance and is used for presenting rendered images to the screen. It is important to properly manage the lifecycle of the swapchain, ensuring that it is destroyed when no longer needed to release associated resources.

Definition at line 131 of file DesktopSwapchainImage.hpp.


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