| Fling Engine 0.00.1 Fling Engine is a game engine written in Vulkan

SwapChain.h
Go to the documentation of this file.
1 #pragma once
2
3 #include "FlingVulkan.h"
4 #include "FlingExports.h"
5
6 namespace Fling
7 {
8 struct SwapChainSupportDetails
9 {
10 VkSurfaceCapabilitiesKHR Capabilities;
11 std::vector<VkSurfaceFormatKHR> Formats;
12 std::vector<VkPresentModeKHR> PresentModes;
13 };
14
15 class PhysicalDevice;
16 class LogicalDevice;
17
21 class Swapchain
22 {
23 public:
24
25 explicit Swapchain(const VkExtent2D& t_Extent, LogicalDevice* t_Dev, PhysicalDevice* t_PhysDev, VkSurfaceKHR t_Surface);
26
27 ~Swapchain();
28
29 VkResult AquireNextImage(const VkSemaphore& t_CompletedSemaphore);
30
31 VkResult QueuePresent(const VkQueue& t_PresentQueue, const VkSemaphore& t_WaitSemaphore);
32
37 void Recreate(const VkExtent2D& t_Extent);
38
42 void Cleanup();
43
44 const VkSwapchainKHR& GetVkSwapChain() const { return m_SwapChain; }
45 const VkPresentModeKHR& GetPresentMode() const { return m_PresentMode; }
46 const VkExtent2D& GetExtents() const { return m_Extents; }
47 const VkFormat& GetImageFormat() const { return m_ImageFormat; }
48
49 const std::vector<VkImage>& GetImages() const { return m_Images; }
50 const size_t GetImageCount() const { return m_Images.size(); }
51 const VkImage& GetActiveImage() const { return m_Images[m_ActiveImageIndex]; }
52 const UINT32 GetActiveImageIndex() const { return m_ActiveImageIndex; }
53
54 const size_t GetImageViewCount() const { return m_ImageViews.size(); }
55 const std::vector<VkImageView>& GetImageViews() const { return m_ImageViews; }
56
57 private:
58
59 VkSwapchainKHR m_SwapChain = VK_NULL_HANDLE;
60
61 VkPresentModeKHR m_PresentMode;
62
63 VkExtent2D m_Extents;
64
65 VkFormat m_ImageFormat;
66
67 UINT32 m_ActiveImageIndex{};
68
69 const LogicalDevice* m_Device;
70 const PhysicalDevice* m_PhysicalDevice;
71 const VkSurfaceKHR m_Surface;
72
74 std::vector<VkImage> m_Images;
75 std::vector<VkImageView> m_ImageViews;
76
80 void CreateResources();
81
85 void CreateImageViews();
86
93 SwapChainSupportDetails QuerySwapChainSupport();
94
104 VkSurfaceFormatKHR ChooseSwapChainSurfaceFormat(const std::vector<VkSurfaceFormatKHR>& t_AvailableFormats);
105
114 VkPresentModeKHR ChooseSwapChainPresentMode(const std::vector<VkPresentModeKHR>& t_AvialableFormats);
115 };
116 } // namespace Fling
Fling::Swapchain::GetExtents
const VkExtent2D & GetExtents() const
Definition: SwapChain.h:46
FlingVulkan.h
Fling::Swapchain::GetPresentMode
const VkPresentModeKHR & GetPresentMode() const
Definition: SwapChain.h:45
Fling::Swapchain::m_Surface
const VkSurfaceKHR m_Surface
Definition: SwapChain.h:71
Fling::Swapchain::GetImageFormat
const VkFormat & GetImageFormat() const
Definition: SwapChain.h:47
Fling::Swapchain::m_ImageFormat
VkFormat m_ImageFormat
Definition: SwapChain.h:65
Fling::Swapchain::m_PhysicalDevice
const PhysicalDevice * m_PhysicalDevice
Definition: SwapChain.h:70
Fling::PhysicalDevice
A physical device represents the Vulkan physical device (the GPU) that we are currently using...
Definition: PhyscialDevice.h:11
Fling::SwapChainSupportDetails::Formats
std::vector< VkSurfaceFormatKHR > Formats
Definition: SwapChain.h:11
Fling::Swapchain::m_Extents
VkExtent2D m_Extents
Definition: SwapChain.h:63
Fling::LogicalDevice
A logical device represents the application view of the device.
Definition: LogicalDevice.h:13
Fling::Swapchain::m_PresentMode
VkPresentModeKHR m_PresentMode
Definition: SwapChain.h:61
Fling::SwapChainSupportDetails::PresentModes
std::vector< VkPresentModeKHR > PresentModes
Definition: SwapChain.h:12
Fling::Swapchain::GetImageViewCount
const size_t GetImageViewCount() const
Definition: SwapChain.h:54
Fling::Swapchain
Represents a swap chain that can be used throughout the program.
Definition: SwapChain.h:21
Fling::Swapchain::m_ImageViews
std::vector< VkImageView > m_ImageViews
Definition: SwapChain.h:75
Fling::Swapchain::m_Device
const LogicalDevice * m_Device
Definition: SwapChain.h:69
Fling::Swapchain::GetImageCount
const size_t GetImageCount() const
Definition: SwapChain.h:50
FlingExports.h
Fling::Swapchain::GetActiveImageIndex
const UINT32 GetActiveImageIndex() const
Definition: SwapChain.h:52
Fling::Swapchain::m_Images
std::vector< VkImage > m_Images
The images inside of the swap chain.
Definition: SwapChain.h:74
Fling::SwapChainSupportDetails::Capabilities
VkSurfaceCapabilitiesKHR Capabilities
Definition: SwapChain.h:10
UINT32
uint32_t UINT32
Definition: FlingTypes.h:13
Fling
Definition: Engine.h:29
Fling::Swapchain::GetImages
const std::vector< VkImage > & GetImages() const
Definition: SwapChain.h:49
Fling::Swapchain::GetVkSwapChain
const VkSwapchainKHR & GetVkSwapChain() const
Definition: SwapChain.h:44
Fling::SwapChainSupportDetails
Definition: SwapChain.h:8
Fling::Swapchain::GetImageViews
const std::vector< VkImageView > & GetImageViews() const
Definition: SwapChain.h:55
Fling::Swapchain::GetActiveImage
const VkImage & GetActiveImage() const
Definition: SwapChain.h:51