Monado OpenXR Runtime
oxr_swapchain_common.h
Go to the documentation of this file.
1// Copyright 2019-2023, Collabora, Ltd.
2// SPDX-License-Identifier: BSL-1.0
3/*!
4 * @file
5 * @brief Helper functions for @ref oxr_swapchain functions.
6 * @author Jakob Bornecrantz <jakob@collabora.com>
7 * @ingroup oxr_main
8 * @ingroup comp_client
9 */
10
11#pragma once
12
13#include "oxr_objects.h"
14
15
16/*
17 *
18 * Helper defines.
19 *
20 */
21
22#define CHECK_OXR_RET(THING) \
23 do { \
24 XrResult check_ret = (THING); \
25 if (check_ret != XR_SUCCESS) { \
26 return check_ret; \
27 } \
28 } while (false)
29
30
31/*
32 *
33 * Verify functions.
34 *
35 */
36
37static inline XrResult
38oxr_swapchain_verify_wait_state(struct oxr_logger *log, struct oxr_swapchain *sc)
39{
40 if (sc->inflight.yes) {
41 return oxr_error(log, XR_ERROR_CALL_ORDER_INVALID, "Swapchain has already been waited, call release");
42 }
43
44 if (u_index_fifo_is_empty(&sc->acquired.fifo)) {
45 return oxr_error(log, XR_ERROR_CALL_ORDER_INVALID, "No image acquired");
46 }
47
48 return XR_SUCCESS;
49}
50
51
52/*
53 *
54 * Common shared functions.
55 *
56 */
57
58/*!
59 * The shared code of the acquire call used by all graphics APIs.
60 *
61 * @param log Logger set with the current OpenXR function call context.
62 * @param sc Swapchain.
63 * @param[out] out_index Return of the acquired index.
64 */
65XrResult
66oxr_swapchain_common_acquire(struct oxr_logger *log, struct oxr_swapchain *sc, uint32_t *out_index);
67
68/*!
69 * The shared code of the wait call used by all graphics APIs.
70 *
71 * @param log Logger set with the current OpenXR function call context.
72 * @param sc Swapchain.
73 * @param timeout Return of the acquired index.
74 */
75XrResult
76oxr_swapchain_common_wait(struct oxr_logger *log, struct oxr_swapchain *sc, XrDuration timeout);
77
78/*!
79 * The shared code of the release call used by all graphics APIs.
80 *
81 * @param log Logger set with the current OpenXR function call context.
82 * @param sc Swapchain.
83 */
84XrResult
86
87/*!
88 * Shared create function for swapchains, called by graphics API specific
89 * implementations list below. Does most init, but not @ref xrt_swapchain
90 * allocation and other API specific things.
91 *
92 * @param log Logger set with the current OpenXR function call context.
93 * @param sess OpenXR session
94 * @param createInfo Creation info.
95 * @param[out] out_swapchain Return of the allocated swapchain.
96 */
97XrResult
99 struct oxr_session *sess,
100 const XrSwapchainCreateInfo *createInfo,
101 struct oxr_swapchain **out_swapchain);
XrResult oxr_error(struct oxr_logger *logger, XrResult result, const char *fmt,...)
Definition: oxr_logger.c:203
The objects representing OpenXR handles, and prototypes for internal functions used in the state trac...
XrResult oxr_swapchain_common_acquire(struct oxr_logger *log, struct oxr_swapchain *sc, uint32_t *out_index)
The shared code of the acquire call used by all graphics APIs.
Definition: oxr_swapchain.c:183
XrResult oxr_swapchain_common_release(struct oxr_logger *log, struct oxr_swapchain *sc)
The shared code of the release call used by all graphics APIs.
Definition: oxr_swapchain.c:253
XrResult oxr_swapchain_common_wait(struct oxr_logger *log, struct oxr_swapchain *sc, XrDuration timeout)
The shared code of the wait call used by all graphics APIs.
Definition: oxr_swapchain.c:222
XrResult oxr_swapchain_common_create(struct oxr_logger *log, struct oxr_session *sess, const XrSwapchainCreateInfo *createInfo, struct oxr_swapchain **out_swapchain)
Shared create function for swapchains, called by graphics API specific implementations list below.
Definition: oxr_swapchain.c:282
Logger struct that lives on the stack, one for each call client call.
Definition: oxr_logger.h:40
Object that client program interact with.
Definition: oxr_objects.h:1741
A set of images used for rendering.
Definition: oxr_objects.h:2330