evan 2026.1.4
Evan
Loading...
Searching...
No Matches
ASwapchainImage.hpp
1/*
2** ETIB PROJECT, 2026
3** evan
4** File description:
5** ASwapchainImage
6*/
7
8#pragma once
9
10#include "evan/EvanPlatform.hpp"
11
12#include "evan/QueueFamilyIndices.hpp"
13#include "evan/RenderSettings.hpp"
14#include "evan/Version.hpp"
15
16#include <utility/logging/loggable.hpp>
17#include <utility/logging/default_logger.hpp>
18
19namespace evan
20{
21 class DeviceContext;
22 class ADeviceBackend;
23
40 protected utility::logging::Loggable<ASwapchainImage,
41 utility::logging::DefaultLogger>
42 {
43 public:
44 virtual ~ASwapchainImage();
45
65 virtual void destroy(VkDevice device) = 0;
66
90 virtual void fillPresentInfo(VkPresentInfoKHR &presentInfo) const = 0;
91
114 static VkFormat findDepthFormat(VkPhysicalDevice physicalDevice);
115
157 static VkFormat
158 findSupportedFormat(VkPhysicalDevice physicalDevice,
159 const std::vector<VkFormat> &candidates,
160 VkImageTiling tiling,
161 VkFormatFeatureFlags features);
162
180 VkFramebuffer getFramebuffer(uint32_t index) const;
181
197 VkExtent2D getExtent() const;
198
215 uint32_t getFramebufferCount() const;
216
217 protected:
232 void createImageViews(const ADeviceBackend &deviceBackend);
233
251 void createColorResources(const ADeviceBackend &deviceBackend,
252 VkSampleCountFlagBits msaaSamples);
253
276 void createDepthResources(const DeviceContext &deviceContext,
277 VkSampleCountFlagBits msaaSamples);
278
303 void createFramebuffers(VkDevice logicalDevice, VkRenderPass renderPass,
304 ColorAttachmentMode mode);
305
326 void createImages(VkDevice logicalDevice, VkSwapchainKHR swapchain);
327
335 VkImage _depthImage = VK_NULL_HANDLE;
336
344 VkImageView _depthView = VK_NULL_HANDLE;
345
352 VkDeviceMemory _depthMemory = VK_NULL_HANDLE;
353
361 VkImage _colorImage = VK_NULL_HANDLE;
362
371 VkImageView _colorView = VK_NULL_HANDLE;
372
379 VkDeviceMemory _colorMemory = VK_NULL_HANDLE;
380
389 std::vector<VkImageView> _imageViews;
390
398 VkExtent2D _extent = { 0, 0 };
399
406 VkFormat _format = VK_FORMAT_UNDEFINED;
407
416 uint32_t _arrayLayers = 1;
426 std::vector<VkImage> _images;
427
437 std::vector<VkFramebuffer> _framebuffers;
438 };
439} // namespace evan
Abstract base class for Vulkan device backends.
ASwapchainImage is a class that represents an image in the swapchain of the Evan engine....
void createFramebuffers(VkDevice logicalDevice, VkRenderPass renderPass, ColorAttachmentMode mode)
Creates framebuffers for the swapchain images.
VkFramebuffer getFramebuffer(uint32_t index) const
Retrieves the Vulkan framebuffer associated with the swapchain image at the specified index.
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.
static VkFormat findDepthFormat(VkPhysicalDevice physicalDevice)
Finds a supported depth format for the swapchain context.
virtual void fillPresentInfo(VkPresentInfoKHR &presentInfo) const =0
Fills the VkPresentInfoKHR structure with the necessary information for presenting the swapchain imag...
void createDepthResources(const DeviceContext &deviceContext, VkSampleCountFlagBits msaaSamples)
Creates depth resources for the swapchain images.
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.
virtual void destroy(VkDevice device)=0
Destroys the swapchain image and releases associated resources.
uint32_t _arrayLayers
The number of array layers of the swapchain and attachment images.
void createImages(VkDevice logicalDevice, VkSwapchainKHR swapchain)
Creates the Vulkan images for the swapchain.
std::vector< VkImageView > _imageViews
uint32_t getFramebufferCount() const
Retrieves the number of framebuffers associated with the swapchain images.
std::vector< VkImage > _images
VkExtent2D getExtent() const
Retrieves the extent (width and height) of the swapchain images.
std::vector< VkFramebuffer > _framebuffers
Represents the device context for the engine, managing Vulkan-related resources and operations.