From 6bf0a5cb5034a7e684dcc3500e841785237ce2dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 19:32:43 +0200 Subject: Adding upstream version 1:115.7.0. Signed-off-by: Daniel Baumann --- gfx/vr/service/OculusSession.h | 115 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 gfx/vr/service/OculusSession.h (limited to 'gfx/vr/service/OculusSession.h') diff --git a/gfx/vr/service/OculusSession.h b/gfx/vr/service/OculusSession.h new file mode 100644 index 0000000000..0ab70e1817 --- /dev/null +++ b/gfx/vr/service/OculusSession.h @@ -0,0 +1,115 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef GFX_VR_SERVICE_OCULUSSESSION_H +#define GFX_VR_SERVICE_OCULUSSESSION_H + +#include "VRSession.h" + +#include "moz_external_vr.h" +#include "mozilla/TimeStamp.h" +#include "mozilla/gfx/2D.h" +#include "nsTArray.h" +#include "oculus/ovr_capi_dynamic.h" +#include "prlink.h" +#include "ShaderDefinitionsD3D11.h" // for VertexShaderConstants and PixelShaderConstants + +struct ID3D11Device; + +namespace mozilla { +namespace layers { +struct VertexShaderConstants; +struct PixelShaderConstants; +} // namespace layers +namespace gfx { + +class OculusSession : public VRSession { + public: + OculusSession(); + virtual ~OculusSession(); + + bool Initialize(mozilla::gfx::VRSystemState& aSystemState, + bool aDetectRuntimesOnly) override; + void Shutdown() override; + void ProcessEvents(mozilla::gfx::VRSystemState& aSystemState) override; + void StartFrame(mozilla::gfx::VRSystemState& aSystemState) override; + bool StartPresentation() override; + void StopPresentation() override; + bool SubmitFrame(const mozilla::gfx::VRLayer_Stereo_Immersive& aLayer, + ID3D11Texture2D* aTexture) override; + void VibrateHaptic(uint32_t aControllerIdx, uint32_t aHapticIndex, + float aIntensity, float aDuration) override; + void StopVibrateHaptic(uint32_t aControllerIdx) override; + void StopAllHaptics() override; + + private: + bool LoadOvrLib(); + void UnloadOvrLib(); + bool StartLib(ovrInitFlags aFlags); + void StopLib(); + bool StartSession(); + void StopSession(); + bool StartRendering(); + void StopRendering(); + bool CreateD3DObjects(); + bool CreateShaders(); + void DestroyShaders(); + void CoverTransitions(); + void UpdateVisibility(); + bool ChangeVisibility(bool bVisible); + bool InitState(mozilla::gfx::VRSystemState& aSystemState); + void UpdateStageParameters(mozilla::gfx::VRDisplayState& aState); + void UpdateEyeParameters(mozilla::gfx::VRSystemState& aState); + void UpdateHeadsetPose(mozilla::gfx::VRSystemState& aState); + void UpdateControllers(VRSystemState& aState); + void UpdateControllerInputs(VRSystemState& aState, + const ovrInputState& aInputState); + void UpdateHaptics(); + void EnumerateControllers(VRSystemState& aState, + const ovrInputState& aInputState); + void UpdateControllerPose(VRSystemState& aState, + const ovrInputState& aInputState); + void UpdateTelemetry(VRSystemState& aSystemState); + bool IsPresentationReady() const; + bool UpdateConstantBuffers(); + + PRLibrary* mOvrLib; + ovrSession mSession; + ovrInitFlags mInitFlags; + ovrTextureSwapChain mTextureSet; + nsTArray> mRTView; + nsTArray> mTexture; + nsTArray> mSRV; + + ID3D11VertexShader* mQuadVS; + ID3D11PixelShader* mQuadPS; + RefPtr mLinearSamplerState; + layers::VertexShaderConstants mVSConstants; + layers::PixelShaderConstants mPSConstants; + RefPtr mVSConstantBuffer; + RefPtr mPSConstantBuffer; + RefPtr mVertexBuffer; + RefPtr mInputLayout; + + IntSize mPresentationSize; + ovrFovPort mFOVPort[2]; + + // Most recent HMD eye poses, from start of frame + ovrPosef mFrameStartPose[2]; + + float mRemainingVibrateTime[2]; + float mHapticPulseIntensity[2]; + TimeStamp mLastHapticUpdate; + + // The timestamp of the last ending presentation + TimeStamp mLastPresentationEnd; + bool mIsPresenting; +}; + +} // namespace gfx +} // namespace mozilla + +#endif // GFX_VR_SERVICE_OCULUSSESSION_H -- cgit v1.2.3