Class Swapchain

Class Documentation

class inexor::vulkan_renderer::wrapper::Swapchain

RAII wrapper class for VkSwapchainKHR.

Public Functions

Swapchain(const Device &device, VkSurfaceKHR surface, std::uint32_t window_width, std::uint32_t window_height, bool enable_vsync, std::string name)

Default constructor.

Parameters
  • device – The const reference to a device RAII wrapper instance.

  • surface – The surface.

  • window_width – The width of the window.

  • window_height – The height of the window.

  • enable_vsync – True if vertical synchronization is requested, false otherwise.

  • name – The internal debug marker name of the VkSwapchainKHR.

Swapchain(const Swapchain&) = delete
Swapchain(Swapchain&&) noexcept
~Swapchain()
Swapchain &operator=(const Swapchain&) = delete
Swapchain &operator=(Swapchain&&) = delete
std::uint32_t acquire_next_image(const Semaphore &semaphore)

Call vkAcquireNextImageKHR.

Parameters

semaphore – A semaphore to signal once image acquisition has completed.

void recreate(std::uint32_t window_width, std::uint32_t window_height)

Recreate the swapchain.

Parameters
  • window_width – The width of the window.

  • window_height – The height of the window.

inline const VkSwapchainKHR *swapchain_ptr() const
inline VkSwapchainKHR swapchain() const
inline std::uint32_t image_count() const
inline VkFormat image_format() const
inline VkExtent2D extent() const
inline VkImageView image_view(std::size_t index) const
inline std::vector<VkImageView> image_views() const

Private Functions

void setup_swapchain(VkSwapchainKHR old_swapchain, std::uint32_t window_width, std::uint32_t window_height)

Set up the swapchain.

Note

Swapchain recreation can be made faster drastically when passing the old swapchain.

Parameters
  • old_swapchain – The old swapchain.

  • window_width – The width of the window.

  • window_height – The height of the window.

Private Members

const wrapper::Device &m_device
VkSurfaceKHR m_surface = {VK_NULL_HANDLE}
VkSwapchainKHR m_swapchain = {VK_NULL_HANDLE}
VkSurfaceFormatKHR m_surface_format = {}
VkExtent2D m_extent = {}
std::vector<VkImage> m_swapchain_images
std::vector<VkImageView> m_swapchain_image_views
std::uint32_t m_swapchain_image_count = {0}
std::string m_name
bool m_vsync_enabled = {false}