Plasma Engine  2.0
Loading...
Searching...
No Matches
OpenXRSwapChain.h
1#pragma once
2
3#include <GameEngine/XR/XRSwapChain.h>
4#include <OpenXRPlugin/Basics.h>
5#include <OpenXRPlugin/OpenXRIncludes.h>
6
7class plOpenXR;
8
9PL_DEFINE_AS_POD_TYPE(XrSwapchainImageD3D11KHR);
10
11class PL_OPENXRPLUGIN_DLL plGALOpenXRSwapChain : public plGALXRSwapChain
12{
13public:
14 plSizeU32 GetRenderTargetSize() const { return m_CurrentSize; }
15 XrSwapchain GetColorSwapchain() const { return m_ColorSwapchain.handle; }
16 XrSwapchain GetDepthSwapchain() const { return m_DepthSwapchain.handle; }
17
18 virtual void AcquireNextRenderTarget(plGALDevice* pDevice) override;
19 virtual void PresentRenderTarget(plGALDevice* pDevice) override;
20 void PresentRenderTarget() const;
21
22protected:
23 virtual plResult InitPlatform(plGALDevice* pDevice) override;
24 virtual plResult DeInitPlatform(plGALDevice* pDevice) override;
25
26private:
27 friend class plOpenXR;
28 struct Swapchain
29 {
30 XrSwapchain handle = 0;
31 int64_t format = 0;
32 plUInt32 imageCount = 0;
33 XrSwapchainImageBaseHeader* images = nullptr;
34 uint32_t imageIndex = 0;
35 };
36 enum class SwapchainType
37 {
38 Color,
39 Depth,
40 };
41
42private:
43 plGALOpenXRSwapChain(plOpenXR* pXrInterface, plGALMSAASampleCount::Enum msaaCount);
44 XrResult SelectSwapchainFormat(int64_t& colorFormat, int64_t& depthFormat);
45 XrResult CreateSwapchainImages(Swapchain& swapchain, SwapchainType type);
46 XrResult InitSwapChain(plGALMSAASampleCount::Enum msaaCount);
47 void DeinitSwapChain();
48
49private:
50 XrInstance m_pInstance = XR_NULL_HANDLE;
51 uint64_t m_SystemId = XR_NULL_SYSTEM_ID;
52 XrSession m_pSession = XR_NULL_HANDLE;
54
55 // Swapchain
56 XrViewConfigurationView m_PrimaryConfigView;
57 Swapchain m_ColorSwapchain;
58 Swapchain m_DepthSwapchain;
59
60 plHybridArray<XrSwapchainImageD3D11KHR, 3> m_ColorSwapChainImagesD3D11;
61 plHybridArray<XrSwapchainImageD3D11KHR, 3> m_DepthSwapChainImagesD3D11;
64
65 bool m_bImageAcquired = false;
66 plGALTextureHandle m_hColorRT;
67 plGALTextureHandle m_hDepthRT;
68};
The plRenderDevice class is the primary interface for interactions with rendering APIs It contains a ...
Definition Device.h:19
Definition OpenXRSwapChain.h:12
Definition RendererFoundationDLL.h:411
Definition XRSwapChain.h:10
A hybrid array uses in-place storage to handle the first few elements without any allocation....
Definition HybridArray.h:12
Definition OpenXRSingleton.h:25
A custom enum implementation that allows to define the underlying storage type to control its memory ...
Definition Enum.h:37
Default enum for returning failure or success, instead of using a bool.
Definition Types.h:54