High-level Vulkan context for easy device, swapchain, and sync setup. Ported from vulkan_examples/vulkan_context.nim to use the vk14 bindings.
Types
VulkanContext = object instance*: VkInstance physicalDevice*: VkPhysicalDevice device*: VkDevice surface*: VkSurfaceKHR graphicsQueue*: VkQueue presentQueue*: VkQueue swapChain*: VkSwapchainKHR swapChainImages*: seq[VkImage] swapChainImageFormat*: VkFormat swapChainExtent*: VkExtent2D commandPool*: VkCommandPool commandBuffers*: array[FRAME_COUNT, VkCommandBuffer] imageAvailableSemaphores*: array[FRAME_COUNT, VkSemaphore] renderFinishedSemaphores*: array[FRAME_COUNT, VkSemaphore] inFlightFences*: array[FRAME_COUNT, VkFence] currentFrame*: int vsync*: bool
- Source Edit
Procs
proc cleanup(ctx: var VulkanContext) {....raises: [Exception], tags: [RootEffect], forbids: [].}
- Destroys all Vulkan objects in the context. Source Edit
proc initDevice(ctx: var VulkanContext; hwnd: int; width, height: int; vsync = true) {....raises: [Exception], tags: [RootEffect], forbids: [].}
- Initializes full Vulkan device, surface, swapchain, and sync objects. Source Edit
proc recordClearFrame(ctx: var VulkanContext; color: array[4, float32]; imageIndex: uint32) {....raises: [Exception], tags: [RootEffect], forbids: [].}
- Records a command buffer that clears the swapchain image. Source Edit
proc recreateSwapChain(ctx: var VulkanContext; width, height: int) {. ...raises: [Exception], tags: [RootEffect], forbids: [].}
- Waits for the device and recreates the swapchain. Source Edit
proc renderFrame(ctx: var VulkanContext; color: array[4, float32]) {. ...raises: [Exception], tags: [RootEffect], forbids: [].}
- Acquires, records, submits, and presents a clear-color frame. Source Edit