UgSwapchain

Vulkan swapchain creation and frame management

It

Swapchain with image views, semaphores, and depth buffer

struct It {
  VkSwapchainKHR handle;
  UgImageView.It* imageViews;
  U32 imageCount;
  U32 currentFrame;
  U32 imageIndex;
  UgSemaphore.It* pSemaphore;
  UgSemaphore.It* rSemaphore;
  VkSurfaceFormatKHR surfaceFormat;
  VkPresentModeKHR presentMode;
  VkSurfaceCapabilitiesKHR capabilities;
  VkImage depthImage;
  VkDeviceMemory depthImageMemory;
  VkImageView depthImageView;
};

extend

Get the current render extent of the swapchain

VkExtent2D extend(UgContext.It& ctx, UgSwapchain.It& swapchain);

Parameters

  • ctx — Vulkan context
  • swapchain — Swapchain to query

Returns — Current VkExtent2D for the swapchain images


update

Recreate the swapchain after a resize or out-of-date error

U0 update(UgContext.It& ctx, UgSwapchain.It& swapchain, VkCommandBuffer cmdBuffer);

Parameters

  • ctx — Vulkan context
  • swapchain — Swapchain to update
  • cmdBuffer — Command buffer used for image layout transitions

destroy

Destroy the swapchain and all associated image views

U0 destroy(UgContext.It& ctx, UgSwapchain.It& swapchain);

Parameters

  • ctx — Vulkan context
  • swapchain — Swapchain to destroy

create

Create a swapchain for the context's surface

UgSwapchain.It create(UgContext.It& ctx);

Parameters

  • ctx — Vulkan context

Returns — Initialized swapchain object