evan 2026.1.4
Evan
Loading...
Searching...
No Matches
evan::ASwapchainImage Class Referenceabstract

ASwapchainImage is a class that represents an image in the swapchain of the Evan engine. It serves as a base class for specific implementations of swapchain images that are compatible with different graphics APIs (e.g., DirectX, Vulkan, OpenGL). The ASwapchainImage class provides an interface for managing the properties and behavior of swapchain images, which are used to present rendered content to the screen. More...

#include <headers/evan/ASwapchainImage.hpp>

Inheritance diagram for evan::ASwapchainImage:
Collaboration diagram for evan::ASwapchainImage:

Public Member Functions

virtual void destroy (VkDevice device)=0
 Destroys the swapchain image and releases associated resources.
 
virtual void fillPresentInfo (VkPresentInfoKHR &presentInfo) const =0
 Fills the VkPresentInfoKHR structure with the necessary information for presenting the swapchain image.
 
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.
 

Static Public Member Functions

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

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

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

ASwapchainImage is a class that represents an image in the swapchain of the Evan engine. It serves as a base class for specific implementations of swapchain images that are compatible with different graphics APIs (e.g., DirectX, Vulkan, OpenGL). The ASwapchainImage class provides an interface for managing the properties and behavior of swapchain images, which are used to present rendered content to the screen.

Note
The ASwapchainImage class is designed to be inherited by specific implementations for different graphics APIs. It defines the necessary functions and properties that must be implemented by derived classes to ensure proper functionality of swapchain images within the Evan engine's rendering system.

Definition at line 39 of file ASwapchainImage.hpp.

Member Function Documentation

◆ createColorResources()

void evan::ASwapchainImage::createColorResources ( const ADeviceBackend &  deviceBackend,
VkSampleCountFlagBits  msaaSamples 
)
protected

Creates a multisampled color attachment and its image view.

Creates the color image, its image view and the memory backing it, which serve as the target of the rendering output. Only needed by ColorAttachmentMode::ResolveToSwapchain render passes: single-sampled attachments render directly into the swapchain image, which saves both the color image memory and the resolve bandwidth.

Parameters
deviceBackendA reference to the ADeviceBackend instance, which provides access to the Vulkan device and other resources needed for creating the color resources.
msaaSamplesThe number of samples for multisampling (MSAA) to be used in the color resources. This parameter is essential for configuring the color resources to support multisampling if required by the rendering system.
Here is the caller graph for this function:

◆ createDepthResources()

void evan::ASwapchainImage::createDepthResources ( const DeviceContext &  deviceContext,
VkSampleCountFlagBits  msaaSamples 
)
protected

Creates depth resources for the swapchain images.

This function creates the necessary depth resources for the swapchain images, including the depth image, its associated image view, and the memory allocation for the depth image

These resources are essential for depth testing during rendering operations, as they store depth information for each pixel. The function takes a DeviceContext as a parameter, which provides access to the Vulkan device and other resources needed for creating the depth resources.

Parameters
deviceContextA reference to the DeviceContext instance, which provides access to the Vulkan device and other resources needed for creating the depth resources. The DeviceContext should be properly initialized and should support the necessary features for depth buffering to ensure that the depth resources can be created successfully.
msaaSamplesThe number of samples for multisampling (MSAA) to be used by the depth resources.
Here is the caller graph for this function:

◆ createFramebuffers()

void evan::ASwapchainImage::createFramebuffers ( VkDevice  logicalDevice,
VkRenderPass  renderPass,
ColorAttachmentMode  mode 
)
protected

Creates framebuffers for the swapchain images.

This function creates the Vulkan framebuffers that are associated with the swapchain images. Framebuffers are used to define the render targets for rendering operations and are typically created by combining the color and depth image views. Each framebuffer corresponds to a specific swapchain image and is used during the rendering process to specify where the rendered output should be stored. The function takes the logical device and render pass as parameters, which are necessary for framebuffer creation.

Parameters
logicalDeviceThe Vulkan logical device used to create the framebuffers. This device should be properly initialized and should support the necessary features for framebuffer creation.
renderPassThe Vulkan render pass that defines the structure of the rendering operations. This render pass should be compatible with the attachments used in the framebuffers.
modeThe color attachment mode the render pass was created with. ColorAttachmentMode::ResolveToSwapchain references the multisampled color view, the depth view and the swapchain image view as the resolve target. The other modes reference the swapchain image view and the depth view only.
Here is the caller graph for this function:

◆ createImages()

void evan::ASwapchainImage::createImages ( VkDevice  logicalDevice,
VkSwapchainKHR  swapchain 
)
protected

Creates the Vulkan images for the swapchain.

This function is responsible for creating the Vulkan images that represent the swapchain images. These images are created as part of the swapchain and are used as the targets for rendering operations. The function takes the logical device and the swapchain as parameters, which are necessary for image creation. Implement this function to ensure that the Vulkan images for the swapchain are properly created and configured according to the requirements of the rendering system.

Parameters
logicalDeviceThe Vulkan logical device used to create the images for the swapchain. This device should be properly initialized and should support the necessary features for image creation.
swapchainThe Vulkan swapchain for which the images are being created. This swapchain should be properly initialized and should provide the necessary information for creating the images, such as the number of images, their format, and their extent.
Here is the caller graph for this function:

◆ createImageViews()

void evan::ASwapchainImage::createImageViews ( const ADeviceBackend &  deviceBackend)
protected

Creates image views for the swapchain images.

Parameters
deviceBackendA reference to the ADeviceBackend instance, which is used to create the image views. The ADeviceBackend provides the necessary Vulkan device and other resources required for image view creation.

This function iterates through the swapchain images and creates image views for each image. Image views are used to describe how the images should be accessed and are necessary for rendering operations. The created image views are stored in the _imageViews vector for later use in the rendering pipeline.

Here is the caller graph for this function:

◆ destroy()

virtual void evan::ASwapchainImage::destroy ( VkDevice  device)
pure virtual

Destroys the swapchain image and releases associated resources.

This pure virtual function must be implemented by derived classes to handle the destruction of the swapchain image and the release of any resources associated with it. The function takes a Vulkan device as a parameter, which is used to perform the necessary cleanup operations. Implement this function to ensure that all resources related to the swapchain image are properly released when the image is no longer needed.

Parameters
deviceThe Vulkan device used to perform the cleanup operations for the swapchain image.
Note
This function is pure virtual and must be implemented by derived classes to handle the specific logic for destroying swapchain images in the context of the rendering system.

Implemented in evan::DesktopSwapchainImage, and evan::XrSwapchainImage.

◆ fillPresentInfo()

virtual void evan::ASwapchainImage::fillPresentInfo ( VkPresentInfoKHR &  presentInfo) const
pure virtual

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

This pure virtual function must be implemented by derived classes to populate the VkPresentInfoKHR structure with the appropriate information required for presenting the swapchain image to the screen. The function 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. Implement this function to ensure that the rendering system can correctly present rendered frames using the swapchain images.

Parameters
presentInfoA reference to a VkPresentInfoKHR structure that should be filled with the necessary information for presenting the swapchain image.
Note
This function is pure virtual and must be implemented by derived classes to handle the specific logic for filling the presentation information for swapchain images in the context of the rendering system.

Implemented in evan::DesktopSwapchainImage, and evan::XrSwapchainImage.

◆ findDepthFormat()

static VkFormat evan::ASwapchainImage::findDepthFormat ( VkPhysicalDevice  physicalDevice)
static

Finds a supported depth format for the swapchain context.

This function is responsible for finding a supported depth format that can be used in the swapchain context for depth buffering. The function takes a Vulkan physical device as a parameter and queries the available formats to determine which one is suitable for depth buffering based on the requirements of the rendering system. Implement this function to ensure that a compatible depth format is selected for use in the swapchain context, which is essential for proper depth testing and rendering of 3D scenes.

Parameters
physicalDeviceThe Vulkan physical device used to query the available formats for depth buffering. This device should be properly initialized and should support the necessary features for depth buffering to ensure that a suitable depth format can be found.
Returns
The selected VkFormat that is supported for depth buffering in the swapchain context. This format should be compatible with the rendering operations and provide optimal performance for depth testing in 3D scenes.

◆ findSupportedFormat()

static VkFormat evan::ASwapchainImage::findSupportedFormat ( VkPhysicalDevice  physicalDevice,
const std::vector< VkFormat > &  candidates,
VkImageTiling  tiling,
VkFormatFeatureFlags  features 
)
static

Finds a supported format from a list of candidates based on the specified tiling and features.

This function is responsible for finding a supported format from a list of candidate formats based on the specified tiling and feature requirements. The function takes a Vulkan physical device, a vector of candidate VkFormat values, the desired VkImageTiling, and the required VkFormatFeatureFlags as parameters. It queries the Vulkan physical device to determine which of the candidate formats is supported with the specified tiling and features, and returns the first suitable format found. Implement this function to ensure that a compatible format is selected for use in the swapchain context or other rendering operations that require specific format support.

Parameters
physicalDeviceThe Vulkan physical device used to query the available formats and their support for the specified tiling and feature requirements. This device should be properly initialized and should support the necessary features to ensure that a suitable format can be found.
candidatesA vector of candidate VkFormat values that should be evaluated to determine which format is supported with the specified tiling and features. These candidates should be chosen based on the requirements of the rendering system and the capabilities of the Vulkan physical device.
tilingThe desired VkImageTiling that the selected format should support. This parameter specifies the tiling arrangement for images using the selected format and should be chosen based on the intended usage of the images in the rendering system.
featuresThe required VkFormatFeatureFlags that the selected format should support. This parameter specifies the features that the format must support, such as sampling, filtering, or rendering capabilities, and should be chosen based on the specific requirements of the rendering operations that will utilize the selected format.
Returns
The selected VkFormat that is supported with the specified tiling and features from the list of candidates. This format should be compatible with the rendering operations and provide optimal performance for the intended usage in the swapchain context or other rendering operations.

◆ getExtent()

VkExtent2D evan::ASwapchainImage::getExtent ( ) const

Retrieves the extent (width and height) of the swapchain images.

This function returns the extent of the swapchain images, which defines the width and height of the images in pixels. The extent is typically determined based on the surface capabilities and the desired resolution for rendering. Implement this function to provide access to the extent of the swapchain images, which is essential for configuring the rendering pipeline and ensuring that rendered content is correctly sized for presentation.

Returns
The extent of the swapchain images, represented as a VkExtent2D structure containing the width and height in pixels.

◆ getFramebuffer()

VkFramebuffer evan::ASwapchainImage::getFramebuffer ( uint32_t  index) const

Retrieves the Vulkan framebuffer associated with the swapchain image at the specified index.

This function returns the Vulkan framebuffer that is associated with the swapchain image at the given index. The framebuffer is used as a render target during rendering operations and is typically created by combining the color and depth image views. Implement this function to provide access to the framebuffer for the specified swapchain image, which is essential for rendering operations that target that image.

Parameters
indexThe index of the swapchain image for which to retrieve the framebuffer.
Returns
The Vulkan framebuffer associated with the swapchain image at the specified index.

◆ getFramebufferCount()

uint32_t evan::ASwapchainImage::getFramebufferCount ( ) const

Retrieves the number of framebuffers associated with the swapchain images.

This function returns the number of framebuffers that are associated with the swapchain images. Each framebuffer corresponds to a specific swapchain image and is used during the rendering process to specify where the rendered output should be stored. Implement this function to provide access to the count of framebuffers, which is essential for managing rendering operations and ensuring that the correct number of framebuffers is available for rendering to the swapchain images.

Returns
The number of framebuffers associated with the swapchain images.

Member Data Documentation

◆ _arrayLayers

uint32_t evan::ASwapchainImage::_arrayLayers = 1
protected

The number of array layers of the swapchain and attachment images.

1 for plain 2D images. Multiview swapchains have one layer per view, and their image views, color, depth and framebuffer resources all cover the same layer count.

Definition at line 416 of file ASwapchainImage.hpp.

◆ _colorImage

VkImage evan::ASwapchainImage::_colorImage = VK_NULL_HANDLE
protected

The color image, which is used to store the rendered color output that will be presented to the screen. It is typically created as part of the swapchain and is used as the target for rendering operations.

Definition at line 361 of file ASwapchainImage.hpp.

◆ _colorMemory

VkDeviceMemory evan::ASwapchainImage::_colorMemory = VK_NULL_HANDLE
protected

The memory allocated for the color image, which is used to store the rendered color output on the GPU. It is allocated and managed by the Vulkan API and is associated with the color image to enable efficient access during rendering operations.

Definition at line 379 of file ASwapchainImage.hpp.

◆ _colorView

VkImageView evan::ASwapchainImage::_colorView = VK_NULL_HANDLE
protected

The image view for the color image, which provides a way to access the color image's data in a specific format and layout. It is used to bind the color image to the graphics pipeline and allows shaders to read from or write to the color image during rendering operations.

Definition at line 371 of file ASwapchainImage.hpp.

◆ _depthImage

VkImage evan::ASwapchainImage::_depthImage = VK_NULL_HANDLE
protected

The depth image, which is used for depth testing during rendering. It stores depth information for each pixel and is typically used in 3D rendering to determine the visibility of objects based on their distance from the camera.

Definition at line 335 of file ASwapchainImage.hpp.

◆ _depthMemory

VkDeviceMemory evan::ASwapchainImage::_depthMemory = VK_NULL_HANDLE
protected

The memory allocated for the depth image, which is used to store the depth information on the GPU. It is allocated and managed by the Vulkan API and is associated with the depth image to enable efficient access during rendering operations.

Definition at line 352 of file ASwapchainImage.hpp.

◆ _depthView

VkImageView evan::ASwapchainImage::_depthView = VK_NULL_HANDLE
protected

The image view for the depth image, which provides a way to access the depth image's data in a specific format and layout. It is used to bind the depth image to the graphics pipeline and allows shaders to read from or write to the depth image during rendering operations.

Definition at line 344 of file ASwapchainImage.hpp.

◆ _extent

VkExtent2D evan::ASwapchainImage::_extent = { 0, 0 }
protected

The extent of the swapchain images, which defines the width and height of the images in pixels. It is typically determined based on the surface capabilities and the desired resolution for rendering.

Definition at line 398 of file ASwapchainImage.hpp.

◆ _format

VkFormat evan::ASwapchainImage::_format = VK_FORMAT_UNDEFINED
protected

The format of the swapchain images, which specifies the color format and layout of the pixel data. It is determined based on the surface capabilities and the desired format for rendering output.

Definition at line 406 of file ASwapchainImage.hpp.

◆ _framebuffers

std::vector<VkFramebuffer> evan::ASwapchainImage::_framebuffers
protected

A vector of Vulkan framebuffers that are associated with the swapchain images. Framebuffers are used to define the render targets for rendering operations and are typically created by combining the color and depth image views. Each framebuffer corresponds to a specific swapchain image and is used during the rendering process to specify where the rendered output should be stored.

Definition at line 437 of file ASwapchainImage.hpp.

◆ _images

std::vector<VkImage> evan::ASwapchainImage::_images
protected

A vector of Vulkan images that represent the swapchain images. These images are created as part of the swapchain and are used as the targets for rendering operations. Each image in this vector corresponds to a specific swapchain image and is used during the rendering process to specify where the rendered output should be stored for presentation to the screen.

Definition at line 426 of file ASwapchainImage.hpp.

◆ _imageViews

std::vector<VkImageView> evan::ASwapchainImage::_imageViews
protected

A vector of Vulkan images that represent the swapchain images. These images are created as part of the swapchain and are used as the targets for rendering operations. Each image in this vector corresponds to a specific swapchain image and is used during the rendering process to specify where the rendered output should be stored for presentation to the screen.

Definition at line 389 of file ASwapchainImage.hpp.


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