Debian Codegraph @

3rdparty/osgXR/src/OpenXR/SwapchainGroup.h

raw symbols SCIP
1 // SPDX-License-Identifier: LGPL-2.1-only
2 // Copyright (C) 2021 James Hogan <[email protected]>
3
4 #ifndef OSGXR_OPENXR_SWAPCHAIN_GROUP
5 #define OSGXR_OPENXR_SWAPCHAIN_GROUP 1
6
7 #include "Swapchain.h"
8
9 #include <osg/Referenced>
10 #include <osg/ref_ptr>
11
12 namespace osgXR {
13
14 namespace OpenXR {
15
16 class SwapchainGroupSubImage;
17
18 /// Groups colour and depth swapchains together
19 class SwapchainGroup : public osg::Referenced
20 {
21 public:
22
23 typedef SwapchainGroupSubImage SubImage;
24
25 // GL context must not be bound in another thread
26 SwapchainGroup(osg::ref_ptr<Session> session,
27 const System::ViewConfiguration::View &view,
28 XrSwapchainUsageFlags usageFlags,
29 int64_t format,
30 XrSwapchainUsageFlags depthUsageFlags = 0,
31 int64_t depthFormat = 0);
32 // GL context must not be bound in another thread
33 virtual ~SwapchainGroup();
34
35 // Error checking
36
37 inline bool valid() const
38 {
39 return _swapchain->valid();
40 }
41
42 inline bool released() const
43 {
44 return _swapchain->released();
45 }
46
47 inline bool depthValid() const
48 {
49 return _depthSwapchain.valid() && _depthSwapchain->valid();
50 }
51
52 // Accessors
53
54 inline osg::ref_ptr<Swapchain> getSwapchain() const
55 {
56 return _swapchain;
57 }
58
59 inline osg::ref_ptr<Swapchain> getDepthSwapchain() const
60 {
61 return _depthSwapchain;
62 }
63
64 inline XrSwapchain getXrSwapchain() const
65 {
66 return _swapchain->getXrSwapchain();
67 }
68
69 inline XrSwapchain getDepthXrSwapchain() const
70 {
71 if (_depthSwapchain.valid())
72 return _depthSwapchain->getXrSwapchain();
73 else
74 return XR_NULL_HANDLE;
75 }
76
77 inline uint32_t getWidth() const
78 {
79 return _swapchain->getWidth();
80 }
81
82 inline uint32_t getHeight() const
83 {
84 return _swapchain->getHeight();
85 }
86
87 inline uint32_t getSamples() const
88 {
89 return _swapchain->getSamples();
90 }
91
92 // Queries
93
94 typedef Swapchain::ImageTextures ImageTextures;
95 const ImageTextures &getImageTextures() const
96 {
97 return _swapchain->getImageTextures();
98 }
99 const ImageTextures &getDepthImageTextures() const
100 {
101 return _depthSwapchain->getImageTextures();
102 }
103
104 // Operations
105
106 int acquireImages() const;
107 bool waitImages(XrDuration timeoutNs) const;
108 void releaseImages() const;
109
110 protected:
111
112 osg::ref_ptr<Swapchain> _swapchain;
113 osg::ref_ptr<Swapchain> _depthSwapchain;
114 };
115
116 }
117
118 }
119
120 #endif