Class Swapchain¶
Defined in File swapchain.hpp
Class Documentation¶
-
class Swapchain¶
RAII wrapper class for swapchains.
Public Functions
-
Swapchain(const Device &device, VkSurfaceKHR surface, std::uint32_t width, std::uint32_t height, bool vsync_enabled)¶
Default constructor
- Parameters:
device – The device wrapper
surface – The surface
width – The swapchain image width
height – The swapchain image height
vsync_enabled –
trueif vertical synchronization is enabled
-
~Swapchain()¶
-
std::uint32_t acquire_next_image_index(std::uint64_t timeout = std::numeric_limits<std::uint64_t>::max())¶
Call vkAcquireNextImageKHR
- Parameters:
timeout – (
std::numeric_limits<std::uint64_t>::max()by default)- Throws:
VulkanException – vkAcquireNextImageKHR call failed
- Returns:
The index of the next image
-
inline VkExtent2D extent() const¶
-
inline const VkSemaphore *image_available_semaphore() const¶
-
inline std::uint32_t image_count() const¶
-
inline VkFormat image_format() const¶
-
inline const std::vector<VkImageView> &image_views() const¶
-
void present(std::uint32_t img_index)¶
Call vkQueuePresentKHR
- Parameters:
img_index – The image index
- Throws:
VulkanException – vkQueuePresentKHR call failed
-
void setup_swapchain(VkExtent2D extent, bool vsync_enabled)¶
Setup the swapchain
- Parameters:
extent – The extent of the swapchain.
vsync_enabled –
trueif vertical synchronization is enabled.
- Throws:
VulkanException – vkCreateSwapchainKHR call failed
VulkanException – vkGetPhysicalDeviceSurfaceSupportKHR call failed
-
inline const VkSwapchainKHR *swapchain() const¶
Private Functions
-
std::vector<VkImage> get_swapchain_images()¶
Call vkGetSwapchainImagesKHR
- Throws:
inexor::vulkan_renderer::VulkanException – vkGetSwapchainImagesKHR call failed
- Returns:
A std::vector of swapchain images (this can be empty!)
Private Members
-
VkSwapchainKHR m_swapchain = {VK_NULL_HANDLE}¶
-
VkSurfaceKHR m_surface = {VK_NULL_HANDLE}¶
-
VkSurfaceFormatKHR m_surface_format¶
-
std::vector<VkImage> m_imgs¶
-
std::vector<VkImageView> m_img_views¶
-
VkExtent2D m_current_extent = {}¶
-
std::unique_ptr<Semaphore> m_img_available¶
-
bool m_vsync_enabled = {false}¶
-
Swapchain(const Device &device, VkSurfaceKHR surface, std::uint32_t width, std::uint32_t height, bool vsync_enabled)¶