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:
- Begin a frame (
crate::RenderSender::begin_owned_frame,crate::RenderSender::try_begin_owned_frame, …). crate::OwnedFrame::vulkan_frame: find each eye’s color and depth view (VulkanFrameState::view_index) and read the image records.- Record a barrier per image from its reported
layoutandqueue_family_indexto the attachment layout on the application’s queue family (no ownership transfer when the reported family isVK_QUEUE_FAMILY_IGNOREDor already the application’s). - Render each eye with the frame’s view pose and field of view.
- Record a barrier per image to
SHOWN_LAYOUT(VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL) that releases ownership toVK_QUEUE_FAMILY_EXTERNAL. - Submit, signalling
VulkanFrameState::semaphore. - Write the new state back:
VulkanFrame::release_to_external(orVulkanFrame::set_image_stateper image) andVulkanFrame::set_fencewith a null fence. 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_vulkancall or sender destruction.VulkanFrameStateandVulkanFrameborrow 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
showconsumes 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§
- Vulkan
Frame - The Vulkan frame of an open frame cycle, with write access to the state
QAROS reads at
show_frame. Fromcrate::OwnedFrame::vulkan_frameorcrate::Frame::vulkan_frame. Dereferences toVulkanFrameState. - Vulkan
Frame State - Read access to the sender-owned Vulkan frame record. From
crate::RenderSender::vulkan_frame_stateoutside a frame cycle, or throughVulkanFrameinside one. - Vulkan
Image - One sender-owned image of the frame (
QarVideoTextureVulkan), copied out of the library’s record. - Vulkan
Stream Params 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
VkFormatassumed for a QAROS pixel format. The header reports only thePixelFormat, not the image’sVkFormat; these are the UNORM and SFLOAT formatsqaros-stubcreates, and the depth-stencil formats by their Vulkan names (D32FloatS8X24UintisD32_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_fdwhere the device has it). None elsewhere, where no QAROS runtime exists and the stub works with plain images.