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

Represents a swapchain image for OpenXR rendering. More...

#include <headers/evan/openxr/XrSwapchainImage.hpp>

Inheritance diagram for evan::XrSwapchainImage:
Collaboration diagram for evan::XrSwapchainImage:

Classes

struct  CreateXrSwapchainImageProperties
 Encapsulates properties for creating an XrSwapchainImage instance. More...
 

Public Member Functions

 XrSwapchainImage (const CreateXrSwapchainImageProperties &properties)
 Constructs an XrSwapchainImage instance using the provided properties.
 
 ~XrSwapchainImage () override
 Releases the swapchain image resources if they were not already destroyed through destroy().
 
void destroy (VkDevice device) override
 Destroys the swapchain images and releases associated resources.
 
void fillPresentInfo (VkPresentInfoKHR &presentInfo) const override
 Fills the VkPresentInfoKHR structure with the necessary information for presenting the swapchain images.
 
- 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

XrSwapchain _swapchain = XR_NULL_HANDLE
 
uint32_t _width = 0
 
uint32_t _height = 0
 

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

Represents a swapchain image for OpenXR rendering.

This class encapsulates the functionality for managing swapchain images in the context of OpenXR rendering. It inherits from ASwapchainImage and provides implementations for destroying the swapchain images and filling presentation information. The class holds a reference to the OpenXR swapchain handle, the dimensions of the swapchain images, and a vector of Vulkan swapchain image structures. It also includes a structure for encapsulating properties required for creating an instance of XrSwapchainImage, which includes the OpenXR swapchain handle, swapchain creation info, Vulkan render pass, and a reference to the device context.

Note
The XrSwapchainImage class is designed to work within the rendering system of the project, providing a way to manage swapchain images for OpenXR applications. It is responsible for handling the lifecycle of the swapchain images, including their creation, destruction, and presentation to the screen.

Definition at line 38 of file XrSwapchainImage.hpp.

Constructor & Destructor Documentation

◆ XrSwapchainImage()

evan::XrSwapchainImage::XrSwapchainImage ( const CreateXrSwapchainImageProperties &  properties)

Constructs an XrSwapchainImage instance using the provided properties.

This constructor initializes the XrSwapchainImage by creating Vulkan image views for each swapchain image based on the provided OpenXR swapchain handle and creation info. It also sets up the necessary resources for rendering operations, such as determining the dimensions of the swapchain images and storing references to the Vulkan render pass and device context for later use in rendering and presentation operations.

Parameters
propertiesA structure containing all necessary properties for initializing the XrSwapchainImage, including the OpenXR swapchain handle, swapchain creation info, Vulkan render pass, and a reference to the device context.
Note
The constructor performs several initialization steps, including:
  • Retrieving the number of swapchain images from the OpenXR swapchain handle.
  • Creating Vulkan image views for each swapchain image based on the provided creation info.
  • Storing the dimensions of the swapchain images for later use in rendering and presentation operations.
  • Setting up references to the Vulkan render pass and device context for use in rendering operations.
  • Handling any necessary error checking and resource management to ensure that the swapchain images are properly initialized and ready for use in the rendering system.

Definition at line 10 of file XrSwapchainImage.cpp.

Here is the call graph for this function:

◆ ~XrSwapchainImage()

evan::XrSwapchainImage::~XrSwapchainImage ( )
override

Releases the swapchain image resources if they were not already destroyed through destroy().

Definition at line 71 of file XrSwapchainImage.cpp.

Member Function Documentation

◆ destroy()

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

Destroys the swapchain images and releases associated resources.

This function overrides the pure virtual function from ASwapchainImage to handle the destruction of the swapchain images and the release of any resources associated with them. It takes a Vulkan device as a parameter, which is used to perform the necessary cleanup operations, such as destroying image views and freeing memory. Implement this function to ensure that all resources related to the swapchain images are properly released when they are no longer needed.

Parameters
deviceThe Vulkan device used to perform the cleanup operations for the swapchain images.
Note
This function is responsible for ensuring that all Vulkan resources associated with the swapchain images are properly released to prevent memory leaks and ensure efficient resource management in the rendering system.

Implements evan::ASwapchainImage.

Definition at line 77 of file XrSwapchainImage.cpp.

◆ fillPresentInfo()

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

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

This function overrides the pure virtual function from ASwapchainImage to populate the VkPresentInfoKHR structure with the appropriate information required for presenting the swapchain images 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. 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 images.
Note
This function is responsible for ensuring that the presentation information is correctly populated to allow the rendering system to present frames using the swapchain images without issues, such as synchronization problems or incorrect image indices. Proper implementation of this function is crucial for the correct functioning of the presentation pipeline in the rendering system.

Implements evan::ASwapchainImage.

Definition at line 146 of file XrSwapchainImage.cpp.

Member Data Documentation

◆ _height

uint32_t evan::XrSwapchainImage::_height = 0

The height of the swapchain images, which is determined based on the swapchain creation info and surface capabilities. This dimension is essential for configuring the rendering pipeline and ensuring that rendered content is correctly sized for presentation.

Note
The width and height of the swapchain images are typically determined during the initialization of the XrSwapchainImage instance based on the parameters provided in the swapchain creation info and the capabilities of the surface being rendered to. Properly setting these dimensions is crucial for ensuring that rendered content is displayed correctly on the screen without distortion or scaling issues.

Definition at line 223 of file XrSwapchainImage.hpp.

◆ _swapchain

XrSwapchain evan::XrSwapchainImage::_swapchain = XR_NULL_HANDLE

The OpenXR swapchain handle associated with the swapchain images.

Definition at line 190 of file XrSwapchainImage.hpp.

◆ _width

uint32_t evan::XrSwapchainImage::_width = 0

The dimensions (width and height) of the swapchain images, which are determined based on the swapchain creation info and surface capabilities. These dimensions are essential for configuring the rendering pipeline and ensuring that rendered content is correctly sized for presentation.

Note
The width and height of the swapchain images are typically determined during the initialization of the XrSwapchainImage instance based on the parameters provided in the swapchain creation info and the capabilities of the surface being rendered to. Properly setting these dimensions is crucial for ensuring that rendered content is displayed correctly on the screen without distortion or scaling issues.

Definition at line 207 of file XrSwapchainImage.hpp.


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