Class VulkanSwapchain¶
Defined in File vulkan_swapchain.h
Class Documentation¶
-
class VulkanSwapchain¶
Vulkan swapchain for presentation with per-image tracking and vsync support.
Manages swapchain creation, acquisition, and presentation. Maintains per-image data (SwapchainImageData) to track which frame-in-flight last used each image, preventing rendering to in-flight images.
Public Functions
-
VulkanSwapchain(ProjectSettings &settings, VulkanContext &context, const Reference<Surface> &surface)¶
Constructs swapchain (does not create yet)
- Parameters:
context – Vulkan context
surface – Presentation surface
-
void create(uint32_t *request_width, uint32_t *request_height, bool new_vsync)¶
Creates swapchain with requested dimensions and vsync.
- Parameters:
request_width – Requested width (may be adjusted to surface capabilities)
request_height – Requested height (may be adjusted to surface capabilities)
new_vsync – Whether vsync is enabled
-
void destroy()¶
Destroys swapchain and image views.
-
void on_resize(size_t new_width, size_t new_height)¶
Recreates swapchain with new dimensions.
- Parameters:
new_width – New width
new_height – New height
-
FrameRenderingContext prepare_frame(const FrameContext &frame)¶
Acquires next swapchain image for rendering.
- Parameters:
frame – Frame context with semaphore to signal when image is ready
- Returns:
SwapchainImageData for the acquired image
-
Reference<RenderTarget> get_current_render_target(bool non_linear = true)¶
-
void present(const FrameContext &frame)¶
Presents rendered image to surface.
- Parameters:
frame – Frame context with semaphore to wait on before presenting
-
inline size_t get_image_count() const¶
Gets number of swapchain images.
-
inline size_t get_width() const¶
Gets swapchain width.
-
inline size_t get_height() const¶
Gets swapchain height.
-
inline const vk::Format &get_linear_color_format() const¶
Gets linear swapchain color format.
-
inline const vk::Format &get_non_linear_color_format() const¶
Gets non linear swapchain color format.
-
inline vk::ColorSpaceKHR get_color_space() const¶
Gets swapchain color space.
-
inline VulkanContext &get_context() const¶
-
inline void set_vsync(const bool new_vsync)¶
Sets vsync enabled/disabled.
- Parameters:
new_vsync – Whether vsync is enabled
-
VulkanSwapchain(ProjectSettings &settings, VulkanContext &context, const Reference<Surface> &surface)¶