| 1 | // SPDX-License-Identifier: LGPL-2.1-only |
| 2 | // Copyright (C) 2021 James Hogan <[email protected]> |
| 3 | |
| 4 | #ifndef OSGXR_OPENXR_QUIRKS |
| 5 | #define OSGXR_OPENXR_QUIRKS 1 |
| 6 | |
| 7 | #include <bitset> |
| 8 | |
| 9 | namespace osgXR { |
| 10 | |
| 11 | namespace OpenXR { |
| 12 | |
| 13 | class Instance; |
| 14 | |
| 15 | typedef enum Quirk { |
| 16 | /** |
| 17 | * This quirk indicates that the GLX context may be assumed to be current by |
| 18 | * certain XR calls. |
| 19 | * The affected calls are: |
| 20 | * - xrCreateSession |
| 21 | * - xrCreateSwapchain |
| 22 | */ |
| 23 | QUIRK_GL_CONTEXT_IGNORED = 0, |
| 24 | |
| 25 | /** |
| 26 | * This quirk indicates that the GLX context may be switched but not |
| 27 | * restored by certain XR calls. |
| 28 | * The affected calls are: |
| 29 | * - xrCreateSwapchain |
| 30 | */ |
| 31 | QUIRK_GL_CONTEXT_CHANGED, |
| 32 | |
| 33 | /** |
| 34 | * This quirk indicates that the GLX context may be unconditionally cleared |
| 35 | * by various XR calls. |
| 36 | * The affected calls are: |
| 37 | * - xrCreateSwapchain |
| 38 | * - xrAcquireSwapchainImage |
| 39 | * - xrWaitSwapchainImage |
| 40 | * - xrReleaseSwapchainImage |
| 41 | * - xrEndFrame |
| 42 | */ |
| 43 | QUIRK_GL_CONTEXT_CLEARED, |
| 44 | |
| 45 | /** |
| 46 | * This quirk indicates that the app should avoid destroying the XR instance |
| 47 | * to avoid hangs. |
| 48 | */ |
| 49 | QUIRK_AVOID_DESTROY_INSTANCE, |
| 50 | |
| 51 | QUIRK_MAX |
| 52 | } Quirk; |
| 53 | |
| 54 | /** |
| 55 | * Represents a set of OpenXR runtime quirks which require workarounds. |
| 56 | */ |
| 57 | class Quirks : public std::bitset<QUIRK_MAX> |
| 58 | { |
| 59 | public: |
| 60 | |
| 61 | /** |
| 62 | * Probe the OpenXR instance to see which quirks are required. |
| 63 | */ |
| 64 | void probe(Instance *instance); |
| 65 | }; |
| 66 | |
| 67 | } // osgXR::OpenXR |
| 68 | |
| 69 | } // osgXR |
| 70 | |
| 71 | #endif |