12 #include <graphics/Geometry.h>
13 #include <display-plugins/hmd/HmdDisplayPlugin.h>
15 #include "OpenXrContext.h"
17 class OpenXrDisplayPlugin :
public HmdDisplayPlugin {
19 OpenXrDisplayPlugin(std::shared_ptr<OpenXrContext> c);
20 bool isSupported()
const override;
21 const QString getName()
const override;
22 bool getSupportsAutoSwitch() override final {
return true; }
24 glm::mat4 getEyeProjection(Eye eye,
const glm::mat4& baseProjection)
const override;
25 glm::mat4 getCullingProjection(
const glm::mat4& baseProjection)
const override;
29 float getTargetFrameRate()
const override;
30 bool hasAsyncReprojection()
const override {
return true; }
32 void customizeContext()
override;
33 void uncustomizeContext()
override;
35 void resetSensors()
override;
36 bool beginFrameRender(uint32_t frameIndex)
override;
37 void submitFrame(
const gpu::FramePointer& newFrame)
override;
38 void cycleDebugOutput()
override { _lockCurrentTexture = !_lockCurrentTexture; }
40 int getRequiredThreadCount()
const override;
42 QRectF getPlayAreaRect()
override;
44 virtual StencilMaskMode getStencilMaskMode()
const override {
return StencilMaskMode::MESH; }
45 virtual StencilMaskMeshOperator getStencilMaskMeshOperator()
override;
47 glm::mat4 getSensorResetMatrix()
const {
return glm::mat4(1.0f); }
50 bool internalActivate()
override;
51 void internalDeactivate()
override;
52 void updatePresentPose()
override;
54 void compositeLayers()
override;
55 void hmdPresent()
override;
56 bool isHmdMounted()
const override;
57 void postPreview()
override;
60 std::vector<gpu::TexturePointer> _compositeSwapChain;
62 XrViewState _lastViewState;
64 std::shared_ptr<OpenXrContext> _context;
66 uint32_t _viewCount = 0;
67 std::vector<XrCompositionLayerProjectionView> _projectionLayerViews;
69 std::optional<std::vector<XrView>> _views;
71 std::vector<XrViewConfigurationView> _viewConfigs;
73 std::vector<XrSwapchain> _swapChains;
74 std::vector<uint32_t> _swapChainLengths;
75 std::vector<uint32_t> _swapChainIndices;
76 std::vector<std::vector<XrSwapchainImageOpenGLKHR>> _images;
78 XrFrameState _lastFrameState;
81 bool initSwapChains();
85 bool _haveFrameToSubmit =
false;
86 std::mutex _haveFrameMutex;