8#include "evan/openxr/XrSwapchainImage.hpp"
13 this->
getLogger().info() <<
"Initializing XrSwapchainImage";
20 _device =
properties.deviceContext.getDeviceBackend()->getDevice();
38 _swapchainImagesBase =
44 for (
auto &
image: _swapchainImages) {
47 for (
size_t i = 0;
i < _swapchainImages.size(); ++
i) {
56 == ColorAttachmentMode::ResolveToSwapchain) {
73 this->
getLogger().info() <<
"Destroying XrSwapchainImage...";
87void evan::XrSwapchainImage::cleanup()
90 <<
"Destroying XrSwapchainImage and releasing resources";
93 for (
size_t i = 0;
i < _swapchainImages.size(); ++
i) {
95 <<
"Destroying image view and framebuffer for swapchain "
101 if (i < _framebuffers.size()
102 && _framebuffers[i] != VK_NULL_HANDLE) {
103 vkDestroyFramebuffer(_device, _framebuffers[i],
nullptr);
109 _framebuffers.clear();
111 if (_device != VK_NULL_HANDLE) {
112 this->getLogger().info()
113 <<
"Destroying color and depth resources for swapchain image";
114 if (_colorView != VK_NULL_HANDLE) {
115 vkDestroyImageView(_device, _colorView,
nullptr);
116 _colorView = VK_NULL_HANDLE;
118 if (_colorImage != VK_NULL_HANDLE) {
119 vkDestroyImage(_device, _colorImage,
nullptr);
120 _colorImage = VK_NULL_HANDLE;
122 if (_colorMemory != VK_NULL_HANDLE) {
123 vkFreeMemory(_device, _colorMemory,
nullptr);
124 _colorMemory = VK_NULL_HANDLE;
126 if (_depthView != VK_NULL_HANDLE) {
127 vkDestroyImageView(_device, _depthView,
nullptr);
128 _depthView = VK_NULL_HANDLE;
130 if (_depthImage != VK_NULL_HANDLE) {
131 vkDestroyImage(_device, _depthImage,
nullptr);
132 _depthImage = VK_NULL_HANDLE;
134 if (_depthMemory != VK_NULL_HANDLE) {
135 vkFreeMemory(_device, _depthMemory,
nullptr);
136 _depthMemory = VK_NULL_HANDLE;
140 if (_swapchain != XR_NULL_HANDLE) {
141 xrDestroySwapchain(_swapchain);
142 _swapchain = XR_NULL_HANDLE;
void createFramebuffers(VkDevice logicalDevice, VkRenderPass renderPass, ColorAttachmentMode mode)
Creates framebuffers 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.
uint32_t _arrayLayers
The number of array layers of the swapchain and attachment images.
std::vector< VkImageView > _imageViews
std::vector< VkFramebuffer > _framebuffers
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 imag...
Small result wrapper used by helpers that must return both a status and a value (e....
Encapsulates properties for creating an XrSwapchainImage instance.
const DeviceContext & deviceContext
A reference to the device context, which provides access to Vulkan device resources and operations ne...