1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-20 07:53:51 +00:00
openmw-tes3mp/apps/openmw/mwvr/openxrswapchainimpl.hpp

91 lines
2.9 KiB
C++
Raw Normal View History

#ifndef OPENXR_SWAPCHAINIMPL_HPP
#define OPENXR_SWAPCHAINIMPL_HPP
2020-12-30 14:03:40 +00:00
#include "openxrswapchainimage.hpp"
#include "openxrmanagerimpl.hpp"
struct XrSwapchainSubImage;
namespace MWVR
{
2020-12-30 14:03:40 +00:00
class VRFramebuffer;
/// \brief Implementation of OpenXRSwapchain
class OpenXRSwapchainImpl
{
private:
struct SwapchainPrivate
{
enum class Use {
COLOR = 0,
DEPTH = 1
};
SwapchainPrivate(osg::ref_ptr<osg::State> state, SwapchainConfig config, Use use);
~SwapchainPrivate();
uint32_t count() const;
bool isAcquired() const;
2020-12-30 14:03:40 +00:00
uint32_t acuiredIndex() const { return mAcquiredIndex; };
XrSwapchain xrSwapchain(void) const { return mSwapchain; };
XrSwapchainSubImage xrSubImage(void) const { return mSubImage; };
int width() const { return mWidth; };
int height() const { return mHeight; };
int samples() const { return mSamples; };
2020-12-30 14:03:40 +00:00
void acquire(osg::GraphicsContext* gc);
void blitAndRelease(osg::GraphicsContext* gc, VRFramebuffer& readBuffer);
void checkAcquired() const;
2020-12-30 14:03:40 +00:00
protected:
private:
SwapchainConfig mConfig;
XrSwapchain mSwapchain = XR_NULL_HANDLE;
XrSwapchainSubImage mSubImage{};
2020-12-30 14:03:40 +00:00
std::vector< std::unique_ptr<OpenXRSwapchainImage> > mImages;
int32_t mWidth = -1;
int32_t mHeight = -1;
int32_t mSamples = -1;
2021-01-25 21:46:08 +00:00
int64_t mFormat = 0;
uint32_t mAcquiredIndex{ 0 };
2020-12-30 14:03:40 +00:00
Use mUsage;
bool mIsIndexAcquired{ false };
bool mIsReady{ false };
};
public:
OpenXRSwapchainImpl(osg::ref_ptr<osg::State> state, SwapchainConfig config);
~OpenXRSwapchainImpl();
void beginFrame(osg::GraphicsContext* gc);
void endFrame(osg::GraphicsContext* gc, VRFramebuffer& readBuffer);
bool isAcquired() const;
2021-01-25 21:46:08 +00:00
XrSwapchain xrSwapchain(void) const;
XrSwapchain xrSwapchainDepth(void) const;
XrSwapchainSubImage xrSubImage(void) const;
XrSwapchainSubImage xrSubImageDepth(void) const;
int width() const { return mConfig.selectedWidth; };
int height() const { return mConfig.selectedHeight; };
int samples() const { return mConfig.selectedSamples; };
2020-06-28 09:33:01 +00:00
protected:
OpenXRSwapchainImpl(const OpenXRSwapchainImpl&) = delete;
void operator=(const OpenXRSwapchainImpl&) = delete;
2020-12-30 14:03:40 +00:00
void acquire(osg::GraphicsContext* gc);
void release(osg::GraphicsContext* gc, VRFramebuffer& readBuffer);
2020-06-28 09:33:01 +00:00
void checkAcquired() const;
private:
SwapchainConfig mConfig;
std::unique_ptr<SwapchainPrivate> mSwapchain{ nullptr };
std::unique_ptr<SwapchainPrivate> mSwapchainDepth{ nullptr };
bool mFormallyAcquired{ false };
bool mShouldRelease{ false };
};
}
#endif