···11+# Implementing OpenXR extensions {#implementing-extension}
22+33+<!--
44+Copyright 2021, Collabora, Ltd. and the Monado contributors
55+SPDX-License-Identifier: BSL-1.0
66+-->
77+88+Khronos often adds new functionality to the OpenXR specification as extensions.
99+1010+The general steps to implement an OpenXR extension in Monado are as follows.
1111+1212+* Edit scripts/generate_oxr_ext_support.py. Usually you only need to add an
1313+ entry to the `EXTENSIONS` list at the top.
1414+* Run the script `python scripts/generate_oxr_ext_support.py`.
1515+* Format the regenerated file with
1616+ `clang-format -i src/xrt/state_trackers/oxr/oxr_extension_support.h`.
1717+* Add entry points for each new function in
1818+ `src/xrt/state_trackers/oxr/oxr_api_negotiate.c`.
1919+* Monado internal implementations of "objects" (think XrSession or
2020+ XrHandTracker) go into `src/xrt/state_trackers/oxr/oxr_objects.h`.
2121+* Enums, defines and types go into `src/xrt/include/xrt/xrt_defines.h`. OpenXR
2222+ types are not used outside of the `oxr_api_*` files, instead equivalents with
2323+ the prefix `XRT_` are defined here.
2424+* Add Monado specific prototypes for the new functions in
2525+ `src/xrt/state_trackers/oxr/oxr_objects.h`. The Monado implementations of
2626+ OpenXR functions are prefixed with `oxr_`.
2727+* Implement the Monado specific functions in an appropriate source file
2828+ `src/state_trackers/oxr/oxr_api_*.c`. Trivial functions can be implemented
2929+ right there along with the usual parameter checks. More complex functions that
3030+ access more internal monado state should call functions implemented in the
3131+ relevant `oxr_*.c` file (without `_api_`).