Monado OpenXR Runtime
Loading...
Searching...
No Matches
vk_image_collection.h
Go to the documentation of this file.
1// Copyright 2025-2026, NVIDIA CORPORATION.
2// SPDX-License-Identifier: BSL-1.0
3/*!
4 * @file
5 * @brief Vulkan image collection implementing xrt_allocation_collection.
6 * @author Jakob Bornecrantz <tbornecrantz@nvidia.com>
7 * @ingroup aux_vk
8 */
9
10#pragma once
11
13
14
15#ifdef __cplusplus
16extern "C" {
17#endif
18
19struct vk_bundle;
22
23
24/*!
25 * @addtogroup aux_vk
26 * @{
27 */
28
29/*!
30 * Allocates a new xrt_allocation_collection backed by Vulkan images.
31 * Internally calls vk_ic_allocate to create the images.
32 *
33 * Supports retrieving images via:
34 * - XRT_ALLOCATION_TYPE_VULKAN_IMAGE (VkImage handles)
35 * - XRT_ALLOCATION_TYPE_NATIVE_IMAGE (xrt_image_native structs)
36 *
37 * @param vk Vulkan bundle.
38 * @param xscci Swapchain creation info describing the images.
39 * @param image_count Number of images to allocate.
40 * @param out_xac Pointer to receive the new allocation collection.
41 * @return XRT_SUCCESS on success.
42 *
43 * @ingroup aux_vk
44 */
46vk_xac_allocate(struct vk_bundle *vk,
47 const struct xrt_swapchain_create_info *xscci,
48 uint32_t image_count,
49 struct xrt_allocation_collection **out_xac);
50
51/*!
52 * Creates a new xrt_allocation_collection by importing native image handles.
53 * Internally calls vk_ic_from_natives to import the images.
54 *
55 * Takes ownership of the native handles in the native_images array. On success,
56 * the handles are consumed (closed/unreffed) and should not be used by the
57 * caller. On failure, the handles remain valid and owned by the caller. This is
58 * an all-or-nothing operation.
59 *
60 * Supports retrieving images via:
61 * - XRT_ALLOCATION_TYPE_VULKAN_IMAGE (VkImage handles)
62 *
63 * Imported memory can't be exported, so native images are not supported.
64 *
65 * @param vk Vulkan bundle.
66 * @param xscci Swapchain creation info describing the images.
67 * @param native_images Array of native image handles to import (ownership transferred on success).
68 * @param image_count Number of images to import.
69 * @param out_xac Pointer to receive the new allocation collection.
70 * @return XRT_SUCCESS on success.
71 *
72 * @ingroup aux_vk
73 */
76 const struct xrt_swapchain_create_info *xscci,
77 struct xrt_image_native *native_images,
78 uint32_t image_count,
79 struct xrt_allocation_collection **out_xac);
80
81/*!
82 * Creates a new xrt_allocation_collection that wraps a vk_image_collection.
83 * Takes ownership of the vk_image_collection - the caller should not
84 * call vk_ic_destroy on it after this function succeeds.
85 *
86 * @p vkic must have been allocated with vk_ic_allocate, imported images can't
87 * be exported as native images.
88 *
89 * @param vk Vulkan bundle.
90 * @param vkic The vk_image_collection to wrap (ownership transferred).
91 * @param out_xac Pointer to receive the new allocation collection.
92 * @return XRT_SUCCESS on success.
93 *
94 * @ingroup aux_vk
95 */
97vk_xac_create(struct vk_bundle *vk, struct vk_image_collection *vkic, struct xrt_allocation_collection **out_xac);
98
99/*!
100 * @}
101 */
102
103
104#ifdef __cplusplus
105}
106#endif
xrt_result_t vk_xac_create(struct vk_bundle *vk, struct vk_image_collection *vkic, struct xrt_allocation_collection **out_xac)
Creates a new xrt_allocation_collection that wraps a vk_image_collection.
Definition vk_image_collection.c:293
xrt_result_t vk_xac_allocate(struct vk_bundle *vk, const struct xrt_swapchain_create_info *xscci, uint32_t image_count, struct xrt_allocation_collection **out_xac)
Allocates a new xrt_allocation_collection backed by Vulkan images.
Definition vk_image_collection.c:207
xrt_result_t vk_xac_from_native_images(struct vk_bundle *vk, const struct xrt_swapchain_create_info *xscci, struct xrt_image_native *native_images, uint32_t image_count, struct xrt_allocation_collection **out_xac)
Creates a new xrt_allocation_collection by importing native image handles.
Definition vk_image_collection.c:249
enum xrt_result xrt_result_t
Result type used across Monado.
A bundle of Vulkan functions and objects, used by both Compositor and Compositor client code.
Definition vk_helpers.h:82
Definition vk_image_allocator.h:36
A collection of allocations, these can be images, buffers or general memory.
Definition xrt_allocation_collection.h:224
A single image of a swapchain based on native buffer handles.
Definition xrt_compositor.h:2103
Swapchain creation info.
Definition xrt_compositor.h:883
Allocation collection.