Skip to main content
QAROS Rust API Dev (main) · versions: Dev (main) · Developer Guide

Module vulkan

Module vulkan 

Source
Expand description

The Vulkan render sender path (feature vulkan).

The application creates its own VkInstance and VkDevice on the adapter the session uses (crate::GraphicsAdapter) and hands both to QAROS (VulkanStreamParams, chained into QarRenderSenderInit). QAROS then owns the frame images: it creates them on that device and reports, per frame, each image’s handle, memory, size, format features, current layout and queue family, plus a binary semaphore to signal.

One frame, in the order of QuaternAR’s vulkan_cube example:

  1. Begin a frame (crate::RenderSender::begin_owned_frame, crate::RenderSender::try_begin_owned_frame, …).
  2. crate::OwnedFrame::vulkan_frame: find each eye’s color and depth view (VulkanFrameState::view_index) and read the image records.
  3. Record a barrier per image from its reported layout and queue_family_index to the attachment layout on the application’s queue family (no ownership transfer when the reported family is VK_QUEUE_FAMILY_IGNORED or already the application’s).
  4. Render each eye with the frame’s view pose and field of view.
  5. Record a barrier per image to SHOWN_LAYOUT (VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL) that releases ownership to VK_QUEUE_FAMILY_EXTERNAL.
  6. Submit, signalling VulkanFrameState::semaphore.
  7. Write the new state back: VulkanFrame::release_to_external (or VulkanFrame::set_image_state per image) and VulkanFrame::set_fence with a null fence.
  8. crate::OwnedFrame::show.

A frame that is begun but not rendered must still signal the semaphore (an empty submission will do) before it is dropped, so that QAROS can consume it.

§Safety rules

These come from the header (qar_render_sender_frame_vulkan, QarStreamParamsVulkan) and the cube example; the wrapper enforces what a borrow can express and documents the rest.

  • Ownership. QAROS owns the images, their memory and the semaphore. Never destroy, free or re-bind them. They live at most as long as the render sender; the handles may change between frames (after a layout change, for example), so read the records every frame and rebuild image views when a handle changes.
  • Frame pointer validity. The library’s frame record stays valid until the next qar_render_sender_frame_vulkan call or sender destruction. VulkanFrameState and VulkanFrame borrow the sender or the open frame mutably, which rules out both while they live. Handles copied out of them stay valid after the borrow ends, as long as the sender lives.
  • Writes only inside a frame cycle. Only VulkanFrame, from an open frame, can write back; VulkanFrameState (from the sender, outside a cycle) is read-only.
  • Order. Submit the work that signals the semaphore, then write back, then show. The write-back cannot outlive the frame (the borrow ends before show consumes it), but the wrapper cannot see the GPU submission: a binary semaphore wait needs its signal submitted first, so showing before submitting is invalid Vulkan usage on the QAROS side.
  • Device. The device must be created from the physical device on the session’s adapter, enable required_device_extensions, and outlive every render sender created with it. Queue submissions and the images’ layouts are the application’s responsibility; QAROS reads the written-back records to know them.

Structs§

VulkanFrame
The Vulkan frame of an open frame cycle, with write access to the state QAROS reads at show_frame. From crate::OwnedFrame::vulkan_frame or crate::Frame::vulkan_frame. Dereferences to VulkanFrameState.
VulkanFrameState
Read access to the sender-owned Vulkan frame record. From crate::RenderSender::vulkan_frame_state outside a frame cycle, or through VulkanFrame inside one.
VulkanImage
One sender-owned image of the frame (QarVideoTextureVulkan), copied out of the library’s record.
VulkanStreamParams
QarStreamParamsVulkan: the application’s physical device and device, on which QAROS creates the frame images.

Constants§

SHOWN_LAYOUT
The layout every image is left in, and written back as, before show_frame (the cube’s final transition).

Functions§

assumed_vk_format
The VkFormat assumed for a QAROS pixel format. The header reports only the PixelFormat, not the image’s VkFormat; these are the UNORM and SFLOAT formats qaros-stub creates, and the depth-stencil formats by their Vulkan names (D32FloatS8X24Uint is D32_SFLOAT_S8_UINT). Whether QAROS uses the sRGB variants for 8-bit color is not documented.
required_device_extensions
Device extensions QAROS needs on the application’s device, as the C Vulkan cube enables them: Win32 external memory and semaphores on Windows, file descriptor external memory on Linux (the cube also enables VK_KHR_external_semaphore_fd where the device has it). None elsewhere, where no QAROS runtime exists and the stub works with plain images.