6. Window — surface, swapchain, frame sync, and the present loop
Windowing and presentation: create a SurfaceKHR from a native window,
build and recreate a Swapchain (with its images, views, and
framebuffers), set up per-frame FrameSync primitives, and run the
acquire → record → submit → present loop via draw_frame. Pair with
create_graphics_pipeline_simple(..., dynamic_viewport = true) for
resize-friendly pipelines.
6.1. Constants
- UINT64_MAX = 0xffffffffffffffff
UINT64_MAX:uint64 const
6.2. Structures
- Swapchain
struct Swapchain
- FrameSync
struct FrameSync
6.3. Surfaces
- create_surface(instance: Instance; native_window: void?; native_display: void? = null ): SurfaceKHR
def create_surface (instance: Instance; native_window: void?; native_display: void? = null) : SurfaceKHR
- Arguments:
instance : Instance
native_window : void?
native_display : void?
- queue_family_supports_present(phys: VkPhysicalDevice; queue_family: uint; surface: SurfaceKHR ): bool
def queue_family_supports_present (phys: VkPhysicalDevice; queue_family: uint; surface: SurfaceKHR) : bool
- Arguments:
phys : VkPhysicalDevice
queue_family : uint
surface : SurfaceKHR
6.4. Swapchain
- build_swapchain_framebuffers(device: Device; sc: Swapchain; render_pass: RenderPass )
def build_swapchain_framebuffers (device: Device; var sc: Swapchain; render_pass: RenderPass)
- Arguments:
device : Device
sc : Swapchain
render_pass : RenderPass
- create_swapchain(device: Device; phys: VkPhysicalDevice; surface: SurfaceKHR; width: int; height: int ): Swapchain
def create_swapchain (device: Device; phys: VkPhysicalDevice; surface: SurfaceKHR; width: int; height: int) : Swapchain
- Arguments:
device : Device
phys : VkPhysicalDevice
surface : SurfaceKHR
width : int
height : int
- recreate_swapchain(sc: Swapchain; device: Device; phys: VkPhysicalDevice; surface: SurfaceKHR; render_pass: RenderPass; width: int; height: int )
def recreate_swapchain (var sc: Swapchain; device: Device; phys: VkPhysicalDevice; surface: SurfaceKHR; render_pass: RenderPass; width: int; height: int)
- Arguments:
sc : Swapchain
device : Device
phys : VkPhysicalDevice
surface : SurfaceKHR
render_pass : RenderPass
width : int
height : int
6.5. Frame sync
- create_frame_sync(device: Device ): FrameSync
def create_frame_sync (device: Device) : FrameSync
- Arguments:
device : Device
6.6. Frame loop
- draw_frame(device: Device; queue: VkQueue; sc: Swapchain; render_pass: RenderPass; pool: CommandPool; sync: FrameSync; clear: VkClearValue; dynamic_viewport: bool = false; blk: block<(cmd:CommandBuffer):void> ): bool
def draw_frame (device: Device; queue: VkQueue; sc: Swapchain; render_pass: RenderPass; pool: CommandPool; sync: FrameSync; clear: VkClearValue; dynamic_viewport: bool = false; blk: block<(cmd:CommandBuffer):void>) : bool
- Arguments:
device : Device
queue : VkQueue
sc : Swapchain
render_pass : RenderPass
pool : CommandPool
sync : FrameSync
clear : VkClearValue
dynamic_viewport : bool
blk : block<(cmd: CommandBuffer):void>