Monado OpenXR Runtime
Loading...
Searching...
No Matches
xrt_allocation_collection_vk.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 typed helpers for the allocation collection.
6 * @author Jakob Bornecrantz <tbornecrantz@nvidia.com>
7 * @ingroup xrt
8 */
9
10#pragma once
11
14
15
16#ifdef __cplusplus
17extern "C" {
18#endif
19
20/*!
21 * @addtogroup xrt_iface
22 * @{
23 */
24
25/*!
26 * Typed helper to get the @ref XRT_ALLOCATION_PROPERTY_VK_DEVICE property.
27 *
28 * @param xac The allocation collection.
29 * @param[out] out_device The VkDevice the allocations were created on, see
30 * @ref XRT_ALLOCATION_PROPERTY_VK_DEVICE for lifetime.
31 *
32 * @public @memberof xrt_allocation_collection
33 */
34static inline xrt_result_t
36{
37 return xac->get_property_raw(xac, XRT_ALLOCATION_PROPERTY_VK_DEVICE, out_device);
38}
39
40/*!
41 * Typed helper to get all the VkImages from an allocation collection, see
42 * @ref XRT_ALLOCATION_TYPE_VULKAN_IMAGE for lifetime.
43 *
44 * Does type checking and ownership checking, the VkImages are only returned if
45 * @p device is the VkDevice the images were created on, otherwise
46 * @ref XRT_ERROR_INVALID_CONTEXT_FOR_TYPE is returned.
47 *
48 * @param xac The allocation collection.
49 * @param device The VkDevice the caller will use the images with.
50 * @param[out] out_images Array of at least @ref xrt_allocation_collection::image_count elements.
51 *
52 * @public @memberof xrt_allocation_collection
53 */
54static inline xrt_result_t
55xrt_allocation_collection_get_vk_images(struct xrt_allocation_collection *xac, VkDevice device, VkImage *out_images)
56{
57 VkDevice xac_device = VK_NULL_HANDLE;
58 xrt_result_t xret = xrt_allocation_collection_get_vk_device(xac, &xac_device);
59 if (xret != XRT_SUCCESS) {
60 return xret;
61 }
62
63 if (xac_device != device) {
65 }
66
67 return xac->get_all_raw(xac, XRT_ALLOCATION_TYPE_VULKAN_IMAGE, out_images);
68}
69
70/*!
71 * @}
72 */
73
74#ifdef __cplusplus
75}
76#endif
static xrt_result_t xrt_allocation_collection_get_vk_device(struct xrt_allocation_collection *xac, VkDevice *out_device)
Typed helper to get the XRT_ALLOCATION_PROPERTY_VK_DEVICE property.
Definition xrt_allocation_collection_vk.h:35
enum xrt_result xrt_result_t
Result type used across Monado.
static xrt_result_t xrt_allocation_collection_get_vk_images(struct xrt_allocation_collection *xac, VkDevice device, VkImage *out_images)
Typed helper to get all the VkImages from an allocation collection, see XRT_ALLOCATION_TYPE_VULKAN_IM...
Definition xrt_allocation_collection_vk.h:55
@ XRT_ALLOCATION_PROPERTY_VK_DEVICE
Get with xrt_allocation_collection_get_vk_device.
Definition xrt_allocation_collection.h:80
@ XRT_ERROR_INVALID_CONTEXT_FOR_TYPE
The context passed in, such as a VkDevice, is not the one the allocations were created with,...
Definition xrt_results.h:307
@ XRT_SUCCESS
The operation succeeded.
Definition xrt_results.h:27
@ XRT_ALLOCATION_TYPE_VULKAN_IMAGE
Get with xrt_allocation_collection_get_vk_images.
Definition xrt_allocation_collection.h:138
A collection of allocations, these can be images, buffers or general memory.
Definition xrt_allocation_collection.h:224
xrt_result_t(* get_property_raw)(struct xrt_allocation_collection *xac, enum xrt_allocation_property prop, void *ptr)
Get a property from the allocation collection.
Definition xrt_allocation_collection.h:279
xrt_result_t(* get_all_raw)(struct xrt_allocation_collection *xac, enum xrt_allocation_type type, void *ptr)
Get all images of a given type.
Definition xrt_allocation_collection.h:293
Allocation collection.
Include all of the Vulkan headers in one place, and cope with any "messy" includes implied by it.