Lugdunum  0.1.0
Swapchain.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <memory>
4 #include <set>
5 
8 
9 namespace lug {
10 namespace Graphics {
11 namespace Vulkan {
12 namespace API {
13 
14 class Device;
15 
16 namespace Builder {
17 
18 class Swapchain {
19 public:
20  Swapchain(const API::Device& device);
21 
22  Swapchain(const Swapchain&) = delete;
23  Swapchain(Swapchain&&) = delete;
24 
25  Swapchain& operator=(const Swapchain&) = delete;
26  Swapchain& operator=(Swapchain&&) = delete;
27 
28  ~Swapchain() = default;
29 
30  // Setters
31  void setPreferences(const Renderer::Preferences::Swapchain& preferences);
32  void setSurface(VkSurfaceKHR surface);
33  void setMinImageCount(uint32_t minImageCount);
34  void setImageFormat(VkFormat imageFormat);
35  void setImageColorSpace(VkColorSpaceKHR imageColorSpace);
36  void setImageExtent(VkExtent2D imageExtent);
37  void setImageUsage(VkImageUsageFlags imageUsage);
38  void setExclusive(bool exclusive);
39  void setQueueFamilyIndices(const std::set<uint32_t>& queueFamilyIndices);
40  void setPreTransform(VkSurfaceTransformFlagBitsKHR preTransform);
41  void setCompositeAlpha(VkCompositeAlphaFlagBitsKHR compositeAlpha);
42  void setPresentMode(VkPresentModeKHR presentMode);
43  void setClipped(VkBool32 clipped);
44  void setOldSwapchain(VkSwapchainKHR oldSwapchain);
45 
46  // Build methods
47  bool build(API::Swapchain& instance, VkResult* returnResult = nullptr);
48  std::unique_ptr<API::Swapchain> build(VkResult* returnResult = nullptr);
49 
50 private:
51  bool setFromPreferences();
52 
53 private:
55 
57  VkSurfaceKHR _surface{VK_NULL_HANDLE};
58  uint32_t _minImageCount;
59  VkFormat _imageFormat{VK_FORMAT_MAX_ENUM};
60  VkColorSpaceKHR _imageColorSpace{VK_COLOR_SPACE_MAX_ENUM_KHR};
61  VkExtent2D _imageExtent{};
62  VkImageUsageFlags _imageUsage{VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT};
63  bool _exclusive{false};
64  std::set<uint32_t> _queueFamilyIndices;
65  VkSurfaceTransformFlagBitsKHR _preTransform{VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR};
66  VkCompositeAlphaFlagBitsKHR _compositeAlpha{VK_COMPOSITE_ALPHA_FLAG_BITS_MAX_ENUM_KHR};
67  VkPresentModeKHR _presentMode{VK_PRESENT_MODE_MAX_ENUM_KHR};
68  VkBool32 _clipped{VK_TRUE};
69  VkSwapchainKHR _oldSwapchain{VK_NULL_HANDLE};
70 };
71 
73 
74 } // Builder
75 } // API
76 } // Vulkan
77 } // Graphics
78 } // lug
bool build(API::Swapchain &instance, VkResult *returnResult=nullptr)
Definition: Swapchain.cpp:85
Swapchain & operator=(const Swapchain &)=delete
void setPresentMode(VkPresentModeKHR presentMode)
Definition: Swapchain.inl:45
void setMinImageCount(uint32_t minImageCount)
Definition: Swapchain.inl:9
void setSurface(VkSurfaceKHR surface)
Definition: Swapchain.inl:5
void setPreTransform(VkSurfaceTransformFlagBitsKHR preTransform)
Definition: Swapchain.inl:37
void setImageFormat(VkFormat imageFormat)
Definition: Swapchain.inl:13
VkSurfaceTransformFlagBitsKHR _preTransform
Definition: Swapchain.hpp:65
void setImageColorSpace(VkColorSpaceKHR imageColorSpace)
Definition: Swapchain.inl:17
void setCompositeAlpha(VkCompositeAlphaFlagBitsKHR compositeAlpha)
Definition: Swapchain.inl:41
void setOldSwapchain(VkSwapchainKHR oldSwapchain)
Definition: Swapchain.inl:53
void setImageUsage(VkImageUsageFlags imageUsage)
Definition: Swapchain.inl:25
const Renderer::Preferences::Swapchain * _preferences
Definition: Swapchain.hpp:56
void setImageExtent(VkExtent2D imageExtent)
Definition: Swapchain.inl:21
void setQueueFamilyIndices(const std::set< uint32_t > &queueFamilyIndices)
Definition: Swapchain.inl:33
void setPreferences(const Renderer::Preferences::Swapchain &preferences)
Definition: Swapchain.inl:1
VkCompositeAlphaFlagBitsKHR _compositeAlpha
Definition: Swapchain.hpp:66