Monado OpenXR Runtime
oxr_extension_support.h
Go to the documentation of this file.
1 // Copyright 2019, Collabora, Ltd.
2 // SPDX-License-Identifier: BSL-1.0
3 /*!
4  * @file
5  * @brief Macros for generating extension-related tables and code and
6  * inspecting Monado's extension support.
7  *
8  * MOSTLY GENERATED CODE - see below!
9  *
10  * To add support for a new extension, edit and run generate_oxr_ext_support.py,
11  * then run clang-format on this file. Two entire chunks of this file get
12  * replaced by that script: comments indicate where they are.
13  *
14  * @author Ryan Pavlik <ryan.pavlik@collabora.com>
15  */
16 
17 #pragma once
18 
19 // beginning of GENERATED defines - do not modify - used by scripts
20 
21 /*
22  * XR_EXT_debug_utils
23  */
24 #if defined(XR_EXT_debug_utils)
25 #define OXR_HAVE_EXT_debug_utils
26 #define OXR_EXTENSION_SUPPORT_EXT_debug_utils(_) \
27  _(EXT_debug_utils, EXT_DEBUG_UTILS)
28 #else
29 #define OXR_EXTENSION_SUPPORT_EXT_debug_utils(_)
30 #endif
31 
32 
33 /*
34  * XR_KHR_convert_timespec_time
35  */
36 #if defined(XR_KHR_convert_timespec_time) && defined(XR_USE_TIMESPEC)
37 #define OXR_HAVE_KHR_convert_timespec_time
38 #define OXR_EXTENSION_SUPPORT_KHR_convert_timespec_time(_) \
39  _(KHR_convert_timespec_time, KHR_CONVERT_TIMESPEC_TIME)
40 #else
41 #define OXR_EXTENSION_SUPPORT_KHR_convert_timespec_time(_)
42 #endif
43 
44 
45 /*
46  * XR_KHR_opengl_enable
47  */
48 #if defined(XR_KHR_opengl_enable) && defined(XR_USE_GRAPHICS_API_OPENGL)
49 #define OXR_HAVE_KHR_opengl_enable
50 #define OXR_EXTENSION_SUPPORT_KHR_opengl_enable(_) \
51  _(KHR_opengl_enable, KHR_OPENGL_ENABLE)
52 #else
53 #define OXR_EXTENSION_SUPPORT_KHR_opengl_enable(_)
54 #endif
55 
56 
57 /*
58  * XR_KHR_opengl_es_enable
59  */
60 #if defined(XR_KHR_opengl_es_enable) && defined(XR_USE_GRAPHICS_API_OPENGL_ES)
61 #define OXR_HAVE_KHR_opengl_es_enable
62 #define OXR_EXTENSION_SUPPORT_KHR_opengl_es_enable(_) \
63  _(KHR_opengl_es_enable, KHR_OPENGL_ES_ENABLE)
64 #else
65 #define OXR_EXTENSION_SUPPORT_KHR_opengl_es_enable(_)
66 #endif
67 
68 
69 /*
70  * XR_KHR_vulkan_enable
71  */
72 #if defined(XR_KHR_vulkan_enable) && defined(XR_USE_GRAPHICS_API_VULKAN)
73 #define OXR_HAVE_KHR_vulkan_enable
74 #define OXR_EXTENSION_SUPPORT_KHR_vulkan_enable(_) \
75  _(KHR_vulkan_enable, KHR_VULKAN_ENABLE)
76 #else
77 #define OXR_EXTENSION_SUPPORT_KHR_vulkan_enable(_)
78 #endif
79 
80 
81 /*
82  * XR_MND_egl_enable
83  */
84 #if defined(XR_MND_egl_enable) && defined(XR_USE_PLATFORM_EGL) && \
85  defined(XR_USE_GRAPHICS_API_OPENGL)
86 #define OXR_HAVE_MND_egl_enable
87 #define OXR_EXTENSION_SUPPORT_MND_egl_enable(_) \
88  _(MND_egl_enable, MND_EGL_ENABLE)
89 #else
90 #define OXR_EXTENSION_SUPPORT_MND_egl_enable(_)
91 #endif
92 
93 
94 /*
95  * XR_MND_headless
96  */
97 #if defined(XR_MND_headless)
98 #define OXR_HAVE_MND_headless
99 #define OXR_EXTENSION_SUPPORT_MND_headless(_) _(MND_headless, MND_HEADLESS)
100 #else
101 #define OXR_EXTENSION_SUPPORT_MND_headless(_)
102 #endif
103 
104 // end of GENERATED per-extension defines - do not modify - used by scripts
105 
106 /*!
107  * Call this, passing a macro taking two parameters, to
108  * generate tables, code, etc. related to OpenXR extensions.
109  * Upon including invoking OXR_EXTENSION_SUPPORT_GENERATE() with some
110  * MY_HANDLE_EXTENSION(mixed_case, all_caps), MY_HANDLE_EXTENSION will be called
111  * for each extension implemented in Monado and supported in this build:
112  *
113  * - The first parameter is the name of the extension without the leading XR_
114  * prefix: e.g. `KHR_opengl_enable`
115  * - The second parameter is the same text as the first, but in all uppercase,
116  * since this transform cannot be done in the C preprocessor, and some
117  * extension-related entities use this instead of the exact extension name.
118  *
119  * Implementation note: This macro calls another macro for each extension: that
120  * macro is either defined to call your provided macro, or defined to nothing,
121  * depending on if the extension is supported in this build.
122  *
123  * @note Do not edit anything between `clang-format off` and `clang-format on` -
124  * it will be replaced next time this file is generated!
125  */
126 // clang-format off
127 #define OXR_EXTENSION_SUPPORT_GENERATE(_) \
128  OXR_EXTENSION_SUPPORT_EXT_debug_utils(_) \
129  OXR_EXTENSION_SUPPORT_KHR_convert_timespec_time(_) \
130  OXR_EXTENSION_SUPPORT_KHR_opengl_enable(_) \
131  OXR_EXTENSION_SUPPORT_KHR_opengl_es_enable(_) \
132  OXR_EXTENSION_SUPPORT_KHR_vulkan_enable(_) \
133  OXR_EXTENSION_SUPPORT_MND_egl_enable(_) \
134  OXR_EXTENSION_SUPPORT_MND_headless(_)
135 // clang-format on