mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1230352 - Update to Oculus SDK 0.8.0,r=vlad
This commit is contained in:
parent
075f835810
commit
b79965bb59
@ -120,7 +120,12 @@ TextureSourceD3D11::GetShaderResourceView()
|
||||
if (!mSRV && mTexture) {
|
||||
RefPtr<ID3D11Device> device;
|
||||
mTexture->GetDevice(getter_AddRefs(device));
|
||||
HRESULT hr = device->CreateShaderResourceView(mTexture, nullptr, getter_AddRefs(mSRV));
|
||||
|
||||
// see comment in CompositingRenderTargetD3D11 constructor
|
||||
CD3D11_SHADER_RESOURCE_VIEW_DESC srvDesc(D3D11_SRV_DIMENSION_TEXTURE2D, mFormatOverride);
|
||||
D3D11_SHADER_RESOURCE_VIEW_DESC *desc = mFormatOverride == DXGI_FORMAT_UNKNOWN ? nullptr : &srvDesc;
|
||||
|
||||
HRESULT hr = device->CreateShaderResourceView(mTexture, desc, getter_AddRefs(mSRV));
|
||||
if (FAILED(hr)) {
|
||||
gfxCriticalNote << "[D3D11] TextureSourceD3D11:GetShaderResourceView CreateSRV failure " << gfx::hexa(hr);
|
||||
return nullptr;
|
||||
@ -1166,7 +1171,8 @@ DataTextureSourceD3D11::SetCompositor(Compositor* aCompositor)
|
||||
}
|
||||
|
||||
CompositingRenderTargetD3D11::CompositingRenderTargetD3D11(ID3D11Texture2D* aTexture,
|
||||
const gfx::IntPoint& aOrigin)
|
||||
const gfx::IntPoint& aOrigin,
|
||||
DXGI_FORMAT aFormatOverride)
|
||||
: CompositingRenderTarget(aOrigin)
|
||||
{
|
||||
MOZ_ASSERT(aTexture);
|
||||
@ -1176,7 +1182,15 @@ CompositingRenderTargetD3D11::CompositingRenderTargetD3D11(ID3D11Texture2D* aTex
|
||||
RefPtr<ID3D11Device> device;
|
||||
mTexture->GetDevice(getter_AddRefs(device));
|
||||
|
||||
HRESULT hr = device->CreateRenderTargetView(mTexture, nullptr, getter_AddRefs(mRTView));
|
||||
mFormatOverride = aFormatOverride;
|
||||
|
||||
// If we happen to have a typeless underlying DXGI surface, we need to be explicit
|
||||
// about the format here. (Such a surface could come from an external source, such
|
||||
// as the Oculus compositor)
|
||||
CD3D11_RENDER_TARGET_VIEW_DESC rtvDesc(D3D11_RTV_DIMENSION_TEXTURE2D, mFormatOverride);
|
||||
D3D11_RENDER_TARGET_VIEW_DESC *desc = aFormatOverride == DXGI_FORMAT_UNKNOWN ? nullptr : &rtvDesc;
|
||||
|
||||
HRESULT hr = device->CreateRenderTargetView(mTexture, desc, getter_AddRefs(mRTView));
|
||||
|
||||
if (FAILED(hr)) {
|
||||
LOGD3D11("Failed to create RenderTargetView.");
|
||||
|
@ -221,7 +221,7 @@ protected:
|
||||
class TextureSourceD3D11
|
||||
{
|
||||
public:
|
||||
TextureSourceD3D11() {}
|
||||
TextureSourceD3D11() : mFormatOverride(DXGI_FORMAT_UNKNOWN) {}
|
||||
virtual ~TextureSourceD3D11() {}
|
||||
|
||||
virtual ID3D11Texture2D* GetD3D11Texture() const { return mTexture; }
|
||||
@ -232,6 +232,7 @@ protected:
|
||||
gfx::IntSize mSize;
|
||||
RefPtr<ID3D11Texture2D> mTexture;
|
||||
RefPtr<ID3D11ShaderResourceView> mSRV;
|
||||
DXGI_FORMAT mFormatOverride;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -404,7 +405,8 @@ class CompositingRenderTargetD3D11 : public CompositingRenderTarget,
|
||||
{
|
||||
public:
|
||||
CompositingRenderTargetD3D11(ID3D11Texture2D* aTexture,
|
||||
const gfx::IntPoint& aOrigin);
|
||||
const gfx::IntPoint& aOrigin,
|
||||
DXGI_FORMAT aFormatOverride = DXGI_FORMAT_UNKNOWN);
|
||||
|
||||
virtual TextureSourceD3D11* AsSourceD3D11() override { return this; }
|
||||
|
||||
|
@ -34,25 +34,23 @@ namespace {
|
||||
static pfn_ovr_Initialize ovr_Initialize = nullptr;
|
||||
static pfn_ovr_Shutdown ovr_Shutdown = nullptr;
|
||||
static pfn_ovr_GetTimeInSeconds ovr_GetTimeInSeconds = nullptr;
|
||||
static pfn_ovr_GetHmdDesc ovr_GetHmdDesc = nullptr;
|
||||
|
||||
static pfn_ovrHmd_Detect ovrHmd_Detect = nullptr;
|
||||
static pfn_ovrHmd_Create ovrHmd_Create = nullptr;
|
||||
static pfn_ovrHmd_CreateDebug ovrHmd_CreateDebug = nullptr;
|
||||
static pfn_ovrHmd_Destroy ovrHmd_Destroy = nullptr;
|
||||
static pfn_ovr_Create ovr_Create = nullptr;
|
||||
static pfn_ovr_Destroy ovr_Destroy = nullptr;
|
||||
|
||||
static pfn_ovrHmd_ConfigureTracking ovrHmd_ConfigureTracking = nullptr;
|
||||
static pfn_ovrHmd_RecenterPose ovrHmd_RecenterPose = nullptr;
|
||||
static pfn_ovrHmd_GetTrackingState ovrHmd_GetTrackingState = nullptr;
|
||||
static pfn_ovrHmd_GetFovTextureSize ovrHmd_GetFovTextureSize = nullptr;
|
||||
static pfn_ovrHmd_GetRenderDesc ovrHmd_GetRenderDesc = nullptr;
|
||||
static pfn_ovr_RecenterPose ovr_RecenterPose = nullptr;
|
||||
static pfn_ovr_GetTrackingState ovr_GetTrackingState = nullptr;
|
||||
static pfn_ovr_GetFovTextureSize ovr_GetFovTextureSize = nullptr;
|
||||
static pfn_ovr_GetRenderDesc ovr_GetRenderDesc = nullptr;
|
||||
|
||||
static pfn_ovrHmd_DestroySwapTextureSet ovrHmd_DestroySwapTextureSet = nullptr;
|
||||
static pfn_ovrHmd_SubmitFrame ovrHmd_SubmitFrame = nullptr;
|
||||
static pfn_ovr_DestroySwapTextureSet ovr_DestroySwapTextureSet = nullptr;
|
||||
static pfn_ovr_SubmitFrame ovr_SubmitFrame = nullptr;
|
||||
|
||||
#ifdef XP_WIN
|
||||
static pfn_ovrHmd_CreateSwapTextureSetD3D11 ovrHmd_CreateSwapTextureSetD3D11 = nullptr;
|
||||
static pfn_ovr_CreateSwapTextureSetD3D11 ovr_CreateSwapTextureSetD3D11 = nullptr;
|
||||
#endif
|
||||
static pfn_ovrHmd_CreateSwapTextureSetGL ovrHmd_CreateSwapTextureSetGL = nullptr;
|
||||
static pfn_ovr_CreateSwapTextureSetGL ovr_CreateSwapTextureSetGL = nullptr;
|
||||
|
||||
#ifdef HAVE_64BIT_BUILD
|
||||
#define BUILD_BITS 64
|
||||
@ -61,7 +59,7 @@ static pfn_ovrHmd_CreateSwapTextureSetGL ovrHmd_CreateSwapTextureSetGL = nullptr
|
||||
#endif
|
||||
|
||||
#define OVR_PRODUCT_VERSION 0
|
||||
#define OVR_MAJOR_VERSION 6
|
||||
#define OVR_MAJOR_VERSION 8
|
||||
#define OVR_MINOR_VERSION 0
|
||||
|
||||
static bool
|
||||
@ -165,24 +163,22 @@ InitializeOculusCAPI()
|
||||
REQUIRE_FUNCTION(ovr_Initialize);
|
||||
REQUIRE_FUNCTION(ovr_Shutdown);
|
||||
REQUIRE_FUNCTION(ovr_GetTimeInSeconds);
|
||||
REQUIRE_FUNCTION(ovr_GetHmdDesc);
|
||||
|
||||
REQUIRE_FUNCTION(ovrHmd_Detect);
|
||||
REQUIRE_FUNCTION(ovrHmd_Create);
|
||||
REQUIRE_FUNCTION(ovrHmd_CreateDebug);
|
||||
REQUIRE_FUNCTION(ovrHmd_Destroy);
|
||||
REQUIRE_FUNCTION(ovr_Create);
|
||||
REQUIRE_FUNCTION(ovr_Destroy);
|
||||
|
||||
REQUIRE_FUNCTION(ovrHmd_ConfigureTracking);
|
||||
REQUIRE_FUNCTION(ovrHmd_RecenterPose);
|
||||
REQUIRE_FUNCTION(ovrHmd_GetTrackingState);
|
||||
REQUIRE_FUNCTION(ovrHmd_GetFovTextureSize);
|
||||
REQUIRE_FUNCTION(ovrHmd_GetRenderDesc);
|
||||
REQUIRE_FUNCTION(ovr_RecenterPose);
|
||||
REQUIRE_FUNCTION(ovr_GetTrackingState);
|
||||
REQUIRE_FUNCTION(ovr_GetFovTextureSize);
|
||||
REQUIRE_FUNCTION(ovr_GetRenderDesc);
|
||||
|
||||
REQUIRE_FUNCTION(ovrHmd_DestroySwapTextureSet);
|
||||
REQUIRE_FUNCTION(ovrHmd_SubmitFrame);
|
||||
REQUIRE_FUNCTION(ovr_DestroySwapTextureSet);
|
||||
REQUIRE_FUNCTION(ovr_SubmitFrame);
|
||||
#ifdef XP_WIN
|
||||
REQUIRE_FUNCTION(ovrHmd_CreateSwapTextureSetD3D11);
|
||||
REQUIRE_FUNCTION(ovr_CreateSwapTextureSetD3D11);
|
||||
#endif
|
||||
REQUIRE_FUNCTION(ovrHmd_CreateSwapTextureSetGL);
|
||||
REQUIRE_FUNCTION(ovr_CreateSwapTextureSetGL);
|
||||
|
||||
#undef REQUIRE_FUNCTION
|
||||
|
||||
@ -247,41 +243,35 @@ FromFovPort(const ovrFovPort& aFOV)
|
||||
|
||||
} // namespace
|
||||
|
||||
HMDInfoOculus::HMDInfoOculus(ovrHmd aHMD, bool aDebug, int aDeviceID)
|
||||
HMDInfoOculus::HMDInfoOculus(ovrSession aSession)
|
||||
: VRHMDInfo(VRHMDType::Oculus, false)
|
||||
, mHMD(aHMD)
|
||||
, mTracking(false)
|
||||
, mDebug(aDebug)
|
||||
, mDeviceID(aDeviceID)
|
||||
, mSensorTrackingFramesRemaining(0)
|
||||
, mSession(aSession)
|
||||
{
|
||||
MOZ_ASSERT(sizeof(HMDInfoOculus::DistortionVertex) == sizeof(VRDistortionVertex),
|
||||
"HMDInfoOculus::DistortionVertex must match the size of VRDistortionVertex");
|
||||
|
||||
MOZ_COUNT_CTOR_INHERITED(HMDInfoOculus, VRHMDInfo);
|
||||
|
||||
if (aDebug) {
|
||||
mDeviceInfo.mDeviceName.AssignLiteral("Oculus VR HMD Debug)");
|
||||
} else {
|
||||
mDeviceInfo.mDeviceName.AssignLiteral("Oculus VR HMD");
|
||||
}
|
||||
mDeviceInfo.mDeviceName.AssignLiteral("Oculus VR HMD");
|
||||
|
||||
mDesc = ovr_GetHmdDesc(aSession);
|
||||
|
||||
mDeviceInfo.mSupportedSensorBits = VRStateValidFlags::State_None;
|
||||
if (mHMD->TrackingCaps & ovrTrackingCap_Orientation) {
|
||||
if (mDesc.AvailableTrackingCaps & ovrTrackingCap_Orientation) {
|
||||
mDeviceInfo.mSupportedSensorBits |= VRStateValidFlags::State_Orientation;
|
||||
}
|
||||
if (mHMD->TrackingCaps & ovrTrackingCap_Position) {
|
||||
if (mDesc.AvailableTrackingCaps & ovrTrackingCap_Position) {
|
||||
mDeviceInfo.mSupportedSensorBits |= VRStateValidFlags::State_Position;
|
||||
}
|
||||
|
||||
mDeviceInfo.mRecommendedEyeFOV[VRDeviceInfo::Eye_Left] = FromFovPort(mHMD->DefaultEyeFov[ovrEye_Left]);
|
||||
mDeviceInfo.mRecommendedEyeFOV[VRDeviceInfo::Eye_Right] = FromFovPort(mHMD->DefaultEyeFov[ovrEye_Right]);
|
||||
mDeviceInfo.mRecommendedEyeFOV[VRDeviceInfo::Eye_Left] = FromFovPort(mDesc.DefaultEyeFov[ovrEye_Left]);
|
||||
mDeviceInfo.mRecommendedEyeFOV[VRDeviceInfo::Eye_Right] = FromFovPort(mDesc.DefaultEyeFov[ovrEye_Right]);
|
||||
|
||||
mDeviceInfo.mMaximumEyeFOV[VRDeviceInfo::Eye_Left] = FromFovPort(mHMD->MaxEyeFov[ovrEye_Left]);
|
||||
mDeviceInfo.mMaximumEyeFOV[VRDeviceInfo::Eye_Right] = FromFovPort(mHMD->MaxEyeFov[ovrEye_Right]);
|
||||
mDeviceInfo.mMaximumEyeFOV[VRDeviceInfo::Eye_Left] = FromFovPort(mDesc.MaxEyeFov[ovrEye_Left]);
|
||||
mDeviceInfo.mMaximumEyeFOV[VRDeviceInfo::Eye_Right] = FromFovPort(mDesc.MaxEyeFov[ovrEye_Right]);
|
||||
|
||||
uint32_t w = mHMD->Resolution.w;
|
||||
uint32_t h = mHMD->Resolution.h;
|
||||
uint32_t w = mDesc.Resolution.w;
|
||||
uint32_t h = mDesc.Resolution.h;
|
||||
mDeviceInfo.mScreenRect.x = 0;
|
||||
mDeviceInfo.mScreenRect.y = 0;
|
||||
mDeviceInfo.mScreenRect.width = std::max(w, h);
|
||||
@ -291,25 +281,12 @@ HMDInfoOculus::HMDInfoOculus(ovrHmd aHMD, bool aDebug, int aDeviceID)
|
||||
SetFOV(mDeviceInfo.mRecommendedEyeFOV[VRDeviceInfo::Eye_Left], mDeviceInfo.mRecommendedEyeFOV[VRDeviceInfo::Eye_Right], 0.01, 10000.0);
|
||||
}
|
||||
|
||||
bool
|
||||
HMDInfoOculus::GetIsDebug() const
|
||||
{
|
||||
return mDebug;
|
||||
}
|
||||
|
||||
int
|
||||
HMDInfoOculus::GetDeviceID() const
|
||||
{
|
||||
return mDeviceID;
|
||||
}
|
||||
|
||||
void
|
||||
HMDInfoOculus::Destroy()
|
||||
{
|
||||
StopSensorTracking();
|
||||
if (mHMD) {
|
||||
ovrHmd_Destroy(mHMD);
|
||||
mHMD = nullptr;
|
||||
if (mSession) {
|
||||
ovr_Destroy(mSession);
|
||||
mSession = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@ -325,7 +302,7 @@ HMDInfoOculus::SetFOV(const gfx::VRFieldOfView& aFOVLeft, const gfx::VRFieldOfVi
|
||||
mDeviceInfo.mEyeFOV[eye] = eye == 0 ? aFOVLeft : aFOVRight;
|
||||
mFOVPort[eye] = ToFovPort(mDeviceInfo.mEyeFOV[eye]);
|
||||
|
||||
ovrEyeRenderDesc renderDesc = ovrHmd_GetRenderDesc(mHMD, (ovrEyeType) eye, mFOVPort[eye]);
|
||||
ovrEyeRenderDesc renderDesc = ovr_GetRenderDesc(mSession, (ovrEyeType)eye, mFOVPort[eye]);
|
||||
|
||||
// As of Oculus 0.6.0, the HmdToEyeViewOffset values are correct and don't need to be negated.
|
||||
mDeviceInfo.mEyeTranslation[eye] = Point3D(renderDesc.HmdToEyeViewOffset.x, renderDesc.HmdToEyeViewOffset.y, renderDesc.HmdToEyeViewOffset.z);
|
||||
@ -333,7 +310,7 @@ HMDInfoOculus::SetFOV(const gfx::VRFieldOfView& aFOVLeft, const gfx::VRFieldOfVi
|
||||
// note that we are using a right-handed coordinate system here, to match CSS
|
||||
mDeviceInfo.mEyeProjectionMatrix[eye] = mDeviceInfo.mEyeFOV[eye].ConstructProjectionMatrix(zNear, zFar, true);
|
||||
|
||||
texSize[eye] = ovrHmd_GetFovTextureSize(mHMD, (ovrEyeType) eye, mFOVPort[eye], pixelsPerDisplayPixel);
|
||||
texSize[eye] = ovr_GetFovTextureSize(mSession, (ovrEyeType)eye, mFOVPort[eye], pixelsPerDisplayPixel);
|
||||
}
|
||||
|
||||
// take the max of both for eye resolution
|
||||
@ -361,56 +338,20 @@ HMDInfoOculus::FillDistortionConstants(uint32_t whichEye,
|
||||
bool
|
||||
HMDInfoOculus::KeepSensorTracking()
|
||||
{
|
||||
// Keep sensor tracking alive for short time after the last request for
|
||||
// tracking state by content. Value conservatively high to accomodate
|
||||
// potentially high frame rates.
|
||||
const uint32_t kKeepAliveFrames = 200;
|
||||
|
||||
bool success = true;
|
||||
if (mSensorTrackingFramesRemaining == 0) {
|
||||
success = StartSensorTracking();
|
||||
}
|
||||
if (success) {
|
||||
mSensorTrackingFramesRemaining = kKeepAliveFrames;
|
||||
}
|
||||
|
||||
return success;
|
||||
// Oculus PC SDK 0.8 and newer enable tracking by default
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
HMDInfoOculus::NotifyVsync(const mozilla::TimeStamp& aVsyncTimestamp)
|
||||
{
|
||||
if (mSensorTrackingFramesRemaining == 1) {
|
||||
StopSensorTracking();
|
||||
}
|
||||
if (mSensorTrackingFramesRemaining) {
|
||||
--mSensorTrackingFramesRemaining;
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
HMDInfoOculus::StartSensorTracking()
|
||||
{
|
||||
if (!mTracking) {
|
||||
mTracking = ovrHmd_ConfigureTracking(mHMD, ovrTrackingCap_Orientation | ovrTrackingCap_Position, 0);
|
||||
}
|
||||
|
||||
return mTracking;
|
||||
}
|
||||
|
||||
void
|
||||
HMDInfoOculus::StopSensorTracking()
|
||||
{
|
||||
if (mTracking) {
|
||||
ovrHmd_ConfigureTracking(mHMD, 0, 0);
|
||||
mTracking = false;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
HMDInfoOculus::ZeroSensor()
|
||||
{
|
||||
ovrHmd_RecenterPose(mHMD);
|
||||
ovr_RecenterPose(mSession);
|
||||
}
|
||||
|
||||
VRHMDSensorState
|
||||
@ -421,7 +362,7 @@ HMDInfoOculus::GetSensorState(double timeOffset)
|
||||
|
||||
// XXX this is the wrong time base for timeOffset; we need to figure out how to synchronize
|
||||
// the Oculus time base and the browser one.
|
||||
ovrTrackingState state = ovrHmd_GetTrackingState(mHMD, ovr_GetTimeInSeconds() + timeOffset);
|
||||
ovrTrackingState state = ovr_GetTrackingState(mSession, ovr_GetTimeInSeconds() + timeOffset, true);
|
||||
ovrPoseStatef& pose(state.HeadPose);
|
||||
|
||||
result.timestamp = pose.TimeInSeconds;
|
||||
@ -487,10 +428,10 @@ struct RenderTargetSetOculus : public VRHMDRenderingSupport::RenderTargetSet
|
||||
if (!hmd)
|
||||
return;
|
||||
|
||||
if (hmd->GetOculusHMD()) {
|
||||
// If the ovrHmd was already destroyed, so were all associated
|
||||
if (hmd->GetOculusSession()) {
|
||||
// If the ovrSession was already destroyed, so were all associated
|
||||
// texture sets
|
||||
ovrHmd_DestroySwapTextureSet(hmd->GetOculusHMD(), textureSet);
|
||||
ovr_DestroySwapTextureSet(hmd->GetOculusSession(), textureSet);
|
||||
}
|
||||
hmd = nullptr;
|
||||
textureSet = nullptr;
|
||||
@ -533,7 +474,7 @@ struct RenderTargetSetD3D11 : public RenderTargetSetOculus
|
||||
RefPtr<layers::CompositingRenderTargetD3D11> rt;
|
||||
|
||||
tex11 = (ovrD3D11Texture*)&aTS->Textures[i];
|
||||
rt = new layers::CompositingRenderTargetD3D11(tex11->D3D11.pTexture, IntPoint(0, 0));
|
||||
rt = new layers::CompositingRenderTargetD3D11(tex11->D3D11.pTexture, IntPoint(0, 0), DXGI_FORMAT_B8G8R8A8_UNORM);
|
||||
rt->SetSize(size);
|
||||
renderTargets[i] = rt;
|
||||
}
|
||||
@ -549,11 +490,11 @@ HMDInfoOculus::CreateRenderTargetSet(layers::Compositor *aCompositor, const IntS
|
||||
{
|
||||
layers::CompositorD3D11 *comp11 = static_cast<layers::CompositorD3D11*>(aCompositor);
|
||||
|
||||
CD3D11_TEXTURE2D_DESC desc(DXGI_FORMAT_B8G8R8A8_UNORM, aSize.width, aSize.height, 1, 1,
|
||||
CD3D11_TEXTURE2D_DESC desc(DXGI_FORMAT_B8G8R8A8_UNORM_SRGB, aSize.width, aSize.height, 1, 1,
|
||||
D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET);
|
||||
ovrSwapTextureSet *ts = nullptr;
|
||||
|
||||
ovrResult orv = ovrHmd_CreateSwapTextureSetD3D11(mHMD, comp11->GetDevice(), &desc, &ts);
|
||||
ovrResult orv = ovr_CreateSwapTextureSetD3D11(mSession, comp11->GetDevice(), &desc, ovrSwapTextureSetD3D11_Typeless, &ts);
|
||||
if (orv != ovrSuccess) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -606,7 +547,7 @@ HMDInfoOculus::SubmitFrame(RenderTargetSet *aRTSet)
|
||||
do_CalcEyePoses(rts->hmd->mLastTrackingState.HeadPose.ThePose, hmdToEyeViewOffset, layer.RenderPose);
|
||||
|
||||
ovrLayerHeader *layers = &layer.Header;
|
||||
ovrResult orv = ovrHmd_SubmitFrame(mHMD, 0, nullptr, &layers, 1);
|
||||
ovrResult orv = ovr_SubmitFrame(mSession, 0, nullptr, &layers, 1);
|
||||
//printf_stderr("Submitted frame %d, result: %d\n", rts->textureSet->CurrentIndex, orv);
|
||||
if (orv != ovrSuccess) {
|
||||
// not visible? failed?
|
||||
@ -662,11 +603,7 @@ VRHMDManagerOculus::Destroy()
|
||||
MOZ_ASSERT(NS_GetCurrentThread() == mOculusThread);
|
||||
mOculusThread = nullptr;
|
||||
|
||||
for (size_t i = 0; i < mOculusHMDs.Length(); ++i) {
|
||||
mOculusHMDs[i]->Destroy();
|
||||
}
|
||||
|
||||
mOculusHMDs.Clear();
|
||||
mHMDInfo = nullptr;
|
||||
|
||||
ovr_Shutdown();
|
||||
mOculusInitialized = false;
|
||||
@ -680,60 +617,24 @@ VRHMDManagerOculus::GetHMDs(nsTArray<RefPtr<VRHMDInfo>>& aHMDResult)
|
||||
return;
|
||||
}
|
||||
|
||||
nsTArray<RefPtr<impl::HMDInfoOculus> > newHMDs;
|
||||
|
||||
ovrResult orv;
|
||||
|
||||
int count = ovrHmd_Detect();
|
||||
|
||||
for (int j = 0; j < count; ++j) {
|
||||
bool is_new = true;
|
||||
for (size_t i = 0; i < mOculusHMDs.Length(); ++i) {
|
||||
if (mOculusHMDs[i]->GetDeviceID() == j) {
|
||||
newHMDs.AppendElement(mOculusHMDs[i]);
|
||||
is_new = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (is_new) {
|
||||
ovrHmd hmd;
|
||||
orv = ovrHmd_Create(j, &hmd);
|
||||
if (orv == ovrSuccess) {
|
||||
RefPtr<HMDInfoOculus> oc = new HMDInfoOculus(hmd, false, j);
|
||||
newHMDs.AppendElement(oc);
|
||||
}
|
||||
// ovr_Create can be slow when no HMD is present and we wish
|
||||
// to keep the same oculus session when possible, so we detect
|
||||
// presence of an HMD with ovr_GetHmdDesc before calling ovr_Create
|
||||
ovrHmdDesc desc = ovr_GetHmdDesc(NULL);
|
||||
if (desc.Type == ovrHmd_None) {
|
||||
// No HMD connected.
|
||||
mHMDInfo = nullptr;
|
||||
} else if (mHMDInfo == nullptr) {
|
||||
// HMD Detected
|
||||
ovrSession session;
|
||||
ovrGraphicsLuid luid;
|
||||
ovrResult orv = ovr_Create(&session, &luid);
|
||||
if (orv == ovrSuccess) {
|
||||
mHMDInfo = new HMDInfoOculus(session);
|
||||
}
|
||||
}
|
||||
|
||||
// VRAddTestDevices == 1: add test device only if no real devices present
|
||||
// VRAddTestDevices == 2: add test device always
|
||||
if ((count == 0 && gfxPrefs::VRAddTestDevices() == 1) ||
|
||||
(gfxPrefs::VRAddTestDevices() == 2))
|
||||
{
|
||||
// Keep existing debug HMD if possible
|
||||
bool foundDebug = false;
|
||||
for (size_t i = 0; i < mOculusHMDs.Length(); ++i) {
|
||||
if (mOculusHMDs[i]->GetIsDebug()) {
|
||||
newHMDs.AppendElement(mOculusHMDs[i]);
|
||||
foundDebug = true;
|
||||
}
|
||||
}
|
||||
|
||||
// If there isn't already a debug HMD, create one
|
||||
if (!foundDebug) {
|
||||
ovrHmd hmd;
|
||||
orv = ovrHmd_CreateDebug(ovrHmd_DK2, &hmd);
|
||||
if (orv == ovrSuccess) {
|
||||
RefPtr<HMDInfoOculus> oc = new HMDInfoOculus(hmd, true, -1);
|
||||
newHMDs.AppendElement(oc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mOculusHMDs = newHMDs;
|
||||
|
||||
for (size_t j = 0; j < mOculusHMDs.Length(); ++j) {
|
||||
aHMDResult.AppendElement(mOculusHMDs[j]);
|
||||
if (mHMDInfo) {
|
||||
aHMDResult.AppendElement(mHMDInfo);
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ namespace impl {
|
||||
|
||||
class HMDInfoOculus : public VRHMDInfo, public VRHMDRenderingSupport {
|
||||
public:
|
||||
explicit HMDInfoOculus(ovrHmd aHMD, bool aDebug, int aDeviceID);
|
||||
explicit HMDInfoOculus(ovrSession aSession);
|
||||
|
||||
bool SetFOV(const VRFieldOfView& aFOVLeft, const VRFieldOfView& aFOVRight,
|
||||
double zNear, double zFar) override;
|
||||
@ -47,9 +47,7 @@ public:
|
||||
void DestroyRenderTargetSet(RenderTargetSet *aRTSet) override;
|
||||
void SubmitFrame(RenderTargetSet *aRTSet) override;
|
||||
|
||||
ovrHmd GetOculusHMD() const { return mHMD; }
|
||||
bool GetIsDebug() const;
|
||||
int GetDeviceID() const;
|
||||
ovrSession GetOculusSession() const { return mSession; }
|
||||
|
||||
protected:
|
||||
virtual ~HMDInfoOculus() {
|
||||
@ -57,9 +55,6 @@ protected:
|
||||
MOZ_COUNT_DTOR_INHERITED(HMDInfoOculus, VRHMDInfo);
|
||||
}
|
||||
|
||||
bool StartSensorTracking();
|
||||
void StopSensorTracking();
|
||||
|
||||
// must match the size of VRDistortionVertex
|
||||
struct DistortionVertex {
|
||||
float pos[2];
|
||||
@ -69,15 +64,10 @@ protected:
|
||||
float genericAttribs[4];
|
||||
};
|
||||
|
||||
ovrHmd mHMD;
|
||||
ovrSession mSession;
|
||||
ovrHmdDesc mDesc;
|
||||
ovrFovPort mFOVPort[2];
|
||||
bool mTracking;
|
||||
ovrTrackingState mLastTrackingState;
|
||||
|
||||
bool mDebug; // True if this is a debug HMD
|
||||
int mDeviceID; // Index of device passed to ovrHmd_Create
|
||||
|
||||
uint32_t mSensorTrackingFramesRemaining;
|
||||
};
|
||||
|
||||
} // namespace impl
|
||||
@ -94,7 +84,7 @@ protected:
|
||||
: mOculusInitialized(false)
|
||||
{ }
|
||||
|
||||
nsTArray<RefPtr<impl::HMDInfoOculus>> mOculusHMDs;
|
||||
RefPtr<impl::HMDInfoOculus> mHMDInfo;
|
||||
bool mOculusInitialized;
|
||||
RefPtr<nsIThread> mOculusThread;
|
||||
};
|
||||
|
@ -64,16 +64,25 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
typedef int32_t ovrResult;
|
||||
typedef char ovrBool;
|
||||
typedef struct { int x, y; } ovrVector2i;
|
||||
typedef struct { int w, h; } ovrSizei;
|
||||
typedef struct { ovrVector2i Pos; ovrSizei Size; } ovrRecti;
|
||||
typedef struct { float x, y, z, w; } ovrQuatf;
|
||||
typedef struct { float x, y; } ovrVector2f;
|
||||
typedef struct { float x, y, z; } ovrVector3f;
|
||||
typedef struct { float M[4][4]; } ovrMatrix4f;
|
||||
|
||||
typedef struct {
|
||||
typedef enum {
|
||||
ovrSuccess = 0,
|
||||
ovrSuccess_NotVisible = 1000,
|
||||
ovrSuccess_HMDFirmwareMismatch = 4100,
|
||||
ovrSuccess_TrackerFirmwareMismatch = 4101,
|
||||
ovrSuccess_ControllerFirmwareMismatch = 4104,
|
||||
} ovrSuccessType;
|
||||
|
||||
typedef char ovrBool;
|
||||
typedef struct OVR_ALIGNAS(4) { int x, y; } ovrVector2i;
|
||||
typedef struct OVR_ALIGNAS(4) { int w, h; } ovrSizei;
|
||||
typedef struct OVR_ALIGNAS(4) { ovrVector2i Pos; ovrSizei Size; } ovrRecti;
|
||||
typedef struct OVR_ALIGNAS(4) { float x, y, z, w; } ovrQuatf;
|
||||
typedef struct OVR_ALIGNAS(4) { float x, y; } ovrVector2f;
|
||||
typedef struct OVR_ALIGNAS(4) { float x, y, z; } ovrVector3f;
|
||||
typedef struct OVR_ALIGNAS(4) { float M[4][4]; } ovrMatrix4f;
|
||||
|
||||
typedef struct OVR_ALIGNAS(4) {
|
||||
ovrQuatf Orientation;
|
||||
ovrVector3f Position;
|
||||
} ovrPosef;
|
||||
@ -96,23 +105,23 @@ typedef struct {
|
||||
} ovrFovPort;
|
||||
|
||||
typedef enum {
|
||||
ovrHmd_None = 0,
|
||||
ovrHmd_DK1 = 3,
|
||||
ovrHmd_DKHD = 4,
|
||||
ovrHmd_DK2 = 6,
|
||||
ovrHmd_BlackStar = 7,
|
||||
ovrHmd_CB = 8,
|
||||
ovrHmd_Other = 9,
|
||||
ovrHmd_EnumSize = 0x7fffffff
|
||||
ovrHmd_None = 0,
|
||||
ovrHmd_DK1 = 3,
|
||||
ovrHmd_DKHD = 4,
|
||||
ovrHmd_DK2 = 6,
|
||||
ovrHmd_CB = 8,
|
||||
ovrHmd_Other = 9,
|
||||
ovrHmd_E3_2015 = 10,
|
||||
ovrHmd_ES06 = 11,
|
||||
ovrHmd_EnumSize = 0x7fffffff
|
||||
} ovrHmdType;
|
||||
|
||||
typedef enum {
|
||||
ovrHmdCap_Writable_Mask = 0x0000,
|
||||
ovrHmdCap_Service_Mask = 0x0000,
|
||||
ovrHmdCap_DebugDevice = 0x0010,
|
||||
ovrHmdCap_LowPersistence = 0x0080,
|
||||
ovrHmdCap_DynamicPrediction = 0x0200,
|
||||
ovrHmdCap_NoVSync = 0x1000,
|
||||
ovrHmdCap_EnumSize = 0x7fffffff
|
||||
} ovrHmdCapBits;
|
||||
} ovrHmdCaps;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
@ -123,6 +132,10 @@ typedef enum
|
||||
ovrTrackingCap_EnumSize = 0x7fffffff
|
||||
} ovrTrackingCaps;
|
||||
|
||||
typedef struct OVR_ALIGNAS(OVR_PTR_SIZE) {
|
||||
char Reserved[8];
|
||||
} ovrGraphicsLuid;
|
||||
|
||||
typedef enum {
|
||||
ovrEye_Left = 0,
|
||||
ovrEye_Right = 1,
|
||||
@ -131,11 +144,10 @@ typedef enum {
|
||||
} ovrEyeType;
|
||||
|
||||
typedef struct OVR_ALIGNAS(OVR_PTR_SIZE) {
|
||||
void* Handle;
|
||||
ovrHmdType Type;
|
||||
OVR_ON64(uint32_t pad0;)
|
||||
const char* ProductName;
|
||||
const char* Manufacturer;
|
||||
OVR_ON64(unsigned char pad0[4];)
|
||||
char ProductName[64];
|
||||
char Manufacturer[64];
|
||||
short VendorId;
|
||||
short ProductId;
|
||||
char SerialNumber[24];
|
||||
@ -146,17 +158,19 @@ typedef struct OVR_ALIGNAS(OVR_PTR_SIZE) {
|
||||
float CameraFrustumNearZInMeters;
|
||||
float CameraFrustumFarZInMeters;
|
||||
|
||||
unsigned int HmdCaps;
|
||||
unsigned int TrackingCaps;
|
||||
unsigned int AvailableHmdCaps;
|
||||
unsigned int DefaultHmdCaps;
|
||||
unsigned int AvailableTrackingCaps;
|
||||
unsigned int DefaultTrackingCaps;
|
||||
|
||||
ovrFovPort DefaultEyeFov[ovrEye_Count];
|
||||
ovrFovPort MaxEyeFov[ovrEye_Count];
|
||||
ovrEyeType EyeRenderOrder[ovrEye_Count];
|
||||
|
||||
ovrSizei Resolution;
|
||||
float DisplayRefreshRate;
|
||||
OVR_ON64(unsigned char pad1[4];)
|
||||
} ovrHmdDesc;
|
||||
|
||||
typedef const ovrHmdDesc* ovrHmd;
|
||||
typedef struct ovrHmdStruct* ovrSession;
|
||||
|
||||
typedef enum {
|
||||
ovrStatus_OrientationTracked = 0x0001,
|
||||
@ -180,47 +194,40 @@ typedef struct OVR_ALIGNAS(8) {
|
||||
ovrPoseStatef HeadPose;
|
||||
ovrPosef CameraPose;
|
||||
ovrPosef LeveledCameraPose;
|
||||
ovrPoseStatef HandPoses[2];
|
||||
ovrSensorData RawSensorData;
|
||||
unsigned int StatusFlags;
|
||||
unsigned int HandStatusFlags[2];
|
||||
uint32_t LastCameraFrameCounter;
|
||||
uint32_t pad0;
|
||||
unsigned char pad0[4];
|
||||
} ovrTrackingState;
|
||||
|
||||
typedef struct OVR_ALIGNAS(8) {
|
||||
double DisplayMidpointSeconds;
|
||||
double FrameIntervalSeconds;
|
||||
unsigned AppFrameIndex;
|
||||
unsigned DisplayFrameIndex;
|
||||
} ovrFrameTiming;
|
||||
|
||||
typedef struct OVR_ALIGNAS(4) {
|
||||
ovrEyeType Eye;
|
||||
ovrFovPort Fov;
|
||||
ovrRecti DistortedViewport;
|
||||
ovrVector2f PixelsPerTanAngleAtCenter;
|
||||
ovrVector3f HmdToEyeViewOffset;
|
||||
ovrEyeType Eye;
|
||||
ovrFovPort Fov;
|
||||
ovrRecti DistortedViewport;
|
||||
ovrVector2f PixelsPerTanAngleAtCenter;
|
||||
ovrVector3f HmdToEyeViewOffset;
|
||||
} ovrEyeRenderDesc;
|
||||
|
||||
typedef struct OVR_ALIGNAS(4) {
|
||||
float Projection22;
|
||||
float Projection23;
|
||||
float Projection32;
|
||||
float Projection22;
|
||||
float Projection23;
|
||||
float Projection32;
|
||||
} ovrTimewarpProjectionDesc;
|
||||
|
||||
typedef struct OVR_ALIGNAS(4) {
|
||||
ovrVector3f HmdToEyeViewOffset[ovrEye_Count];
|
||||
float HmdSpaceToWorldScaleInMeters;
|
||||
ovrVector3f HmdToEyeViewOffset[ovrEye_Count];
|
||||
float HmdSpaceToWorldScaleInMeters;
|
||||
} ovrViewScaleDesc;
|
||||
|
||||
typedef enum {
|
||||
ovrRenderAPI_None,
|
||||
ovrRenderAPI_OpenGL,
|
||||
ovrRenderAPI_Android_GLES,
|
||||
ovrRenderAPI_D3D9_Obsolete,
|
||||
ovrRenderAPI_D3D10_Obsolete,
|
||||
ovrRenderAPI_D3D11,
|
||||
ovrRenderAPI_Count,
|
||||
ovrRenderAPI_EnumSize = 0x7fffffff
|
||||
ovrRenderAPI_None = 0,
|
||||
ovrRenderAPI_OpenGL = 1,
|
||||
ovrRenderAPI_Android_GLES = 2,
|
||||
ovrRenderAPI_D3D11 = 5,
|
||||
ovrRenderAPI_Count = 4,
|
||||
ovrRenderAPI_EnumSize = 0x7fffffff
|
||||
} ovrRenderAPIType;
|
||||
|
||||
typedef struct OVR_ALIGNAS(4) {
|
||||
@ -230,7 +237,7 @@ typedef struct OVR_ALIGNAS(4) {
|
||||
|
||||
typedef struct OVR_ALIGNAS(OVR_PTR_SIZE) {
|
||||
ovrTextureHeader Header;
|
||||
OVR_ON64(uint32_t pad0;)
|
||||
OVR_ON64(unsigned char pad0[4];)
|
||||
uintptr_t PlatformData[8];
|
||||
} ovrTexture;
|
||||
|
||||
@ -240,11 +247,72 @@ typedef struct OVR_ALIGNAS(OVR_PTR_SIZE) {
|
||||
int CurrentIndex;
|
||||
} ovrSwapTextureSet;
|
||||
|
||||
|
||||
typedef enum {
|
||||
ovrButton_A = 0x00000001,
|
||||
ovrButton_B = 0x00000002,
|
||||
ovrButton_RThumb = 0x00000004,
|
||||
ovrButton_RShoulder = 0x00000008,
|
||||
ovrButton_X = 0x00000100,
|
||||
ovrButton_Y = 0x00000200,
|
||||
ovrButton_LThumb = 0x00000400,
|
||||
ovrButton_LShoulder = 0x00000800,
|
||||
ovrButton_Up = 0x00010000,
|
||||
ovrButton_Down = 0x00020000,
|
||||
ovrButton_Left = 0x00040000,
|
||||
ovrButton_Right = 0x00080000,
|
||||
ovrButton_Enter = 0x00100000,
|
||||
ovrButton_Back = 0x00200000,
|
||||
ovrButton_Private = 0x00400000 | 0x00800000 | 0x01000000,
|
||||
ovrButton_EnumSize = 0x7fffffff
|
||||
} ovrButton;
|
||||
|
||||
typedef enum {
|
||||
ovrTouch_A = ovrButton_A,
|
||||
ovrTouch_B = ovrButton_B,
|
||||
ovrTouch_RThumb = ovrButton_RThumb,
|
||||
ovrTouch_RIndexTrigger = 0x00000010,
|
||||
ovrTouch_X = ovrButton_X,
|
||||
ovrTouch_Y = ovrButton_Y,
|
||||
ovrTouch_LThumb = ovrButton_LThumb,
|
||||
ovrTouch_LIndexTrigger = 0x00001000,
|
||||
ovrTouch_RIndexPointing = 0x00000020,
|
||||
ovrTouch_RThumbUp = 0x00000040,
|
||||
ovrTouch_LIndexPointing = 0x00002000,
|
||||
ovrTouch_LThumbUp = 0x00004000,
|
||||
ovrTouch_EnumSize = 0x7fffffff
|
||||
} ovrTouch;
|
||||
|
||||
typedef enum {
|
||||
ovrControllerType_None = 0x00,
|
||||
ovrControllerType_LTouch = 0x01,
|
||||
ovrControllerType_RTouch = 0x02,
|
||||
ovrControllerType_Touch = 0x03,
|
||||
ovrControllerType_XBox = 0x10,
|
||||
ovrControllerType_All = 0xff,
|
||||
ovrControllerType_EnumSize = 0x7fffffff
|
||||
} ovrControllerType;
|
||||
|
||||
typedef enum {
|
||||
ovrHand_Left = 0,
|
||||
ovrHand_Right = 1,
|
||||
ovrHand_EnumSize = 0x7fffffff
|
||||
} ovrHandType;
|
||||
|
||||
typedef struct {
|
||||
double TimeInSeconds;
|
||||
unsigned int ConnectedControllerTypes;
|
||||
unsigned int Buttons;
|
||||
unsigned int Touches;
|
||||
float IndexTrigger[2];
|
||||
float HandTrigger[2];
|
||||
ovrVector2f Thumbstick[2];
|
||||
} ovrInputState;
|
||||
|
||||
typedef enum {
|
||||
ovrInit_Debug = 0x00000001,
|
||||
ovrInit_ServerOptional = 0x00000002,
|
||||
ovrInit_RequestVersion = 0x00000004,
|
||||
ovrInit_ForceNoDebug = 0x00000008,
|
||||
ovrinit_WritableBits = 0x00ffffff,
|
||||
ovrInit_EnumSize = 0x7fffffff
|
||||
} ovrInitFlags;
|
||||
|
||||
@ -255,19 +323,65 @@ typedef enum {
|
||||
ovrLogLevel_EnumSize = 0x7fffffff
|
||||
} ovrLogLevel;
|
||||
|
||||
typedef void (OVR_PFN *ovrLogCallback)(int level, const char* message);
|
||||
|
||||
typedef struct OVR_ALIGNAS(8) {
|
||||
uint32_t Flags;
|
||||
uint32_t RequestedMinorVersion;
|
||||
ovrLogCallback LogCallback;
|
||||
uintptr_t UserData;
|
||||
uint32_t ConnectionTimeoutMS;
|
||||
OVR_ON64(unsigned char pad0[4];)
|
||||
} ovrInitParams;
|
||||
|
||||
typedef ovrResult(OVR_PFN *pfn_ovr_Initialize)(ovrInitParams const* params);
|
||||
typedef void (OVR_PFN *pfn_ovr_Shutdown)();
|
||||
|
||||
typedef struct {
|
||||
ovrResult Result;
|
||||
char ErrorString[512];
|
||||
} ovrErrorInfo;
|
||||
|
||||
typedef void (OVR_PFN *pfn_ovr_GetLastErrorInfo)(ovrErrorInfo* errorInfo);
|
||||
typedef const char* (OVR_PFN *pfn_ovr_GetVersionString)();
|
||||
typedef int (OVR_PFN *pfn_ovr_TraceMessage)(int level, const char* message);
|
||||
typedef ovrHmdDesc (OVR_PFN *pfn_ovr_GetHmdDesc)(ovrSession session);
|
||||
typedef ovrResult (OVR_PFN *pfn_ovr_Create)(ovrSession*, ovrGraphicsLuid*);
|
||||
typedef void (OVR_PFN *pfn_ovr_Destroy)(ovrSession session);
|
||||
|
||||
typedef struct {
|
||||
ovrBool HasVrFocus;
|
||||
ovrBool HmdPresent;
|
||||
} ovrSessionStatus;
|
||||
|
||||
typedef ovrResult (OVR_PFN *pfn_ovr_GetSessionStatus)(ovrSession session, ovrSessionStatus* sessionStatus);
|
||||
typedef unsigned int (OVR_PFN *pfn_ovr_GetEnabledCaps)(ovrSession session);
|
||||
typedef void (OVR_PFN *pfn_ovr_SetEnabledCaps)(ovrSession session, unsigned int hmdCaps);
|
||||
typedef unsigned int (OVR_PFN *pfn_ovr_GetTrackingCaps)(ovrSession session);
|
||||
typedef ovrResult(OVR_PFN *pfn_ovr_ConfigureTracking)(ovrSession session, unsigned int requestedTrackingCaps, unsigned int requiredTrackingCaps);
|
||||
typedef void (OVR_PFN *pfn_ovr_RecenterPose)(ovrSession session);
|
||||
typedef ovrTrackingState (OVR_PFN *pfn_ovr_GetTrackingState)(ovrSession session, double absTime, ovrBool latencyMarker);
|
||||
typedef ovrResult (OVR_PFN *pfn_ovr_GetInputState)(ovrSession session, unsigned int controllerTypeMask, ovrInputState* inputState);
|
||||
typedef ovrResult (OVR_PFN *pfn_ovr_SetControllerVibration)(ovrSession session, unsigned int controllerTypeMask, float frequency, float amplitude);
|
||||
|
||||
enum {
|
||||
ovrMaxLayerCount = 32
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
ovrLayerType_Disabled = 0,
|
||||
ovrLayerType_EyeFov = 1,
|
||||
ovrLayerType_EyeFovDepth = 2,
|
||||
ovrLayerType_QuadInWorld = 3,
|
||||
ovrLayerType_QuadHeadLocked = 4,
|
||||
ovrLayerType_Quad = 3,
|
||||
ovrLayerType_EyeMatrix = 5,
|
||||
ovrLayerType_Direct = 6,
|
||||
ovrLayerType_EnumSize = 0x7fffffff
|
||||
} ovrLayerType;
|
||||
|
||||
typedef enum {
|
||||
ovrLayerFlag_HighQuality = 0x01,
|
||||
ovrLayerFlag_TextureOriginAtBottomLeft = 0x02
|
||||
ovrLayerFlag_TextureOriginAtBottomLeft = 0x02,
|
||||
ovrLayerFlag_HeadLocked = 0x04
|
||||
} ovrLayerFlags;
|
||||
|
||||
typedef struct OVR_ALIGNAS(OVR_PTR_SIZE) {
|
||||
@ -281,66 +395,157 @@ typedef struct OVR_ALIGNAS(OVR_PTR_SIZE) {
|
||||
ovrRecti Viewport[ovrEye_Count];
|
||||
ovrFovPort Fov[ovrEye_Count];
|
||||
ovrPosef RenderPose[ovrEye_Count];
|
||||
double SensorSampleTime;
|
||||
} ovrLayerEyeFov;
|
||||
|
||||
typedef void (OVR_PFN *ovrLogCallback)(int level, const char* message);
|
||||
typedef struct OVR_ALIGNAS(OVR_PTR_SIZE) {
|
||||
ovrLayerHeader Header;
|
||||
ovrSwapTextureSet* ColorTexture[ovrEye_Count];
|
||||
ovrRecti Viewport[ovrEye_Count];
|
||||
ovrFovPort Fov[ovrEye_Count];
|
||||
ovrPosef RenderPose[ovrEye_Count];
|
||||
double SensorSampleTime;
|
||||
ovrSwapTextureSet* DepthTexture[ovrEye_Count];
|
||||
ovrTimewarpProjectionDesc ProjectionDesc;
|
||||
} ovrLayerEyeFovDepth;
|
||||
|
||||
typedef struct OVR_ALIGNAS(8) {
|
||||
uint32_t Flags;
|
||||
uint32_t RequestedMinorVersion;
|
||||
ovrLogCallback LogCallback;
|
||||
uint32_t ConnectionTimeoutMS;
|
||||
OVR_ON64(uint32_t pad0;)
|
||||
} ovrInitParams;
|
||||
typedef struct OVR_ALIGNAS(OVR_PTR_SIZE) {
|
||||
ovrLayerHeader Header;
|
||||
ovrSwapTextureSet* ColorTexture[ovrEye_Count];
|
||||
ovrRecti Viewport[ovrEye_Count];
|
||||
ovrPosef RenderPose[ovrEye_Count];
|
||||
ovrMatrix4f Matrix[ovrEye_Count];
|
||||
double SensorSampleTime;
|
||||
} ovrLayerEyeMatrix;
|
||||
|
||||
enum {
|
||||
ovrSuccess = 0,
|
||||
typedef struct OVR_ALIGNAS(OVR_PTR_SIZE) {
|
||||
ovrLayerHeader Header;
|
||||
ovrSwapTextureSet* ColorTexture;
|
||||
ovrRecti Viewport;
|
||||
ovrPosef QuadPoseCenter;
|
||||
ovrVector2f QuadSize;
|
||||
} ovrLayerQuad;
|
||||
|
||||
ovrError_MemoryAllocationFailure = -1000,
|
||||
ovrError_SocketCreationFailure = -1001,
|
||||
ovrError_InvalidHmd = -1002,
|
||||
ovrError_Timeout = -1003,
|
||||
ovrError_NotInitialized = -1004,
|
||||
ovrError_InvalidParameter = -1005,
|
||||
ovrError_ServiceError = -1006,
|
||||
ovrError_NoHmd = -1007,
|
||||
typedef struct OVR_ALIGNAS(OVR_PTR_SIZE) {
|
||||
ovrLayerHeader Header;
|
||||
ovrSwapTextureSet* ColorTexture[ovrEye_Count];
|
||||
ovrRecti Viewport[ovrEye_Count];
|
||||
} ovrLayerDirect;
|
||||
|
||||
ovrError_AudioReservedBegin = -2000,
|
||||
ovrError_AudioReservedEnd = -2999,
|
||||
typedef union {
|
||||
ovrLayerHeader Header;
|
||||
ovrLayerEyeFov EyeFov;
|
||||
ovrLayerEyeFovDepth EyeFovDepth;
|
||||
ovrLayerQuad Quad;
|
||||
ovrLayerDirect Direct;
|
||||
} ovrLayer_Union;
|
||||
|
||||
ovrError_Initialize = -3000,
|
||||
ovrError_LibLoad = -3001,
|
||||
ovrError_LibVersion = -3002,
|
||||
ovrError_ServiceConnection = -3003,
|
||||
ovrError_ServiceVersion = -3004,
|
||||
ovrError_IncompatibleOS = -3005,
|
||||
ovrError_DisplayInit = -3006,
|
||||
ovrError_ServerStart = -3007,
|
||||
ovrError_Reinitialization = -3008,
|
||||
|
||||
ovrError_InvalidBundleAdjustment = -4000,
|
||||
ovrError_USBBandwidth = -4001
|
||||
};
|
||||
|
||||
typedef ovrResult (OVR_PFN *pfn_ovr_Initialize)(ovrInitParams const* params);
|
||||
typedef void (OVR_PFN *pfn_ovr_Shutdown)();
|
||||
typedef void (OVR_PFN *pfn_ovr_DestroySwapTextureSet)(ovrSession session, ovrSwapTextureSet* textureSet);
|
||||
typedef void (OVR_PFN *pfn_ovr_DestroyMirrorTexture)(ovrSession session, ovrTexture* mirrorTexture);
|
||||
typedef ovrSizei (OVR_PFN *pfn_ovr_GetFovTextureSize)(ovrSession session, ovrEyeType eye, ovrFovPort fov, float pixelsPerDisplayPixel);
|
||||
typedef ovrEyeRenderDesc (OVR_PFN *pfn_ovr_GetRenderDesc)(ovrSession session, ovrEyeType eyeType, ovrFovPort fov);
|
||||
typedef ovrResult (OVR_PFN *pfn_ovr_SubmitFrame)(ovrSession session, unsigned int frameIndex,
|
||||
const ovrViewScaleDesc* viewScaleDesc,
|
||||
ovrLayerHeader const * const * layerPtrList, unsigned int layerCount);
|
||||
typedef double (OVR_PFN *pfn_ovr_GetPredictedDisplayTime)(ovrSession session, long long frameIndex);
|
||||
typedef double (OVR_PFN *pfn_ovr_GetTimeInSeconds)();
|
||||
|
||||
typedef ovrResult (OVR_PFN *pfn_ovrHmd_Detect)();
|
||||
typedef ovrResult (OVR_PFN *pfn_ovrHmd_Create)(int index, ovrHmd*);
|
||||
typedef ovrResult (OVR_PFN *pfn_ovrHmd_CreateDebug)(ovrHmdType type, ovrHmd*);
|
||||
typedef void (OVR_PFN *pfn_ovrHmd_Destroy)(ovrHmd hmd);
|
||||
|
||||
typedef ovrResult (OVR_PFN *pfn_ovrHmd_ConfigureTracking)(ovrHmd hmd, unsigned int supportedTrackingCaps, unsigned int requiredTrackingCaps);
|
||||
typedef void (OVR_PFN *pfn_ovrHmd_RecenterPose)(ovrHmd hmd);
|
||||
typedef ovrTrackingState (OVR_PFN *pfn_ovrHmd_GetTrackingState)(ovrHmd hmd, double absTime);
|
||||
typedef ovrSizei (OVR_PFN *pfn_ovrHmd_GetFovTextureSize)(ovrHmd hmd, ovrEyeType eye, ovrFovPort fov, float pixelsPerDisplayPixel);
|
||||
typedef ovrEyeRenderDesc (OVR_PFN *pfn_ovrHmd_GetRenderDesc)(ovrHmd hmd, ovrEyeType eyeType, ovrFovPort fov);
|
||||
|
||||
typedef void (OVR_PFN *pfn_ovrHmd_DestroySwapTextureSet)(ovrHmd hmd, ovrSwapTextureSet* textureSet);
|
||||
typedef ovrResult (OVR_PFN *pfn_ovrHmd_SubmitFrame)(ovrHmd hmd, unsigned int frameIndex,
|
||||
const ovrViewScaleDesc* viewScaleDesc,
|
||||
ovrLayerHeader const * const * layerPtrList, unsigned int layerCount);
|
||||
typedef enum {
|
||||
ovrPerfHud_Off = 0,
|
||||
ovrPerfHud_LatencyTiming = 1,
|
||||
ovrPerfHud_RenderTiming = 2,
|
||||
ovrPerfHud_PerfHeadroom = 3,
|
||||
ovrPerfHud_VersionInfo = 4,
|
||||
ovrPerfHud_Count,
|
||||
ovrPerfHud_EnumSize = 0x7fffffff
|
||||
} ovrPerfHudMode;
|
||||
|
||||
typedef enum {
|
||||
ovrLayerHud_Off = 0,
|
||||
ovrLayerHud_Info = 1,
|
||||
ovrLayerHud_EnumSize = 0x7fffffff
|
||||
} ovrLayerHudMode;
|
||||
|
||||
typedef enum {
|
||||
ovrDebugHudStereo_Off = 0,
|
||||
ovrDebugHudStereo_Quad = 1,
|
||||
ovrDebugHudStereo_QuadWithCrosshair = 2,
|
||||
ovrDebugHudStereo_CrosshairAtInfinity = 3,
|
||||
ovrDebugHudStereo_Count,
|
||||
ovrDebugHudStereo_EnumSize = 0x7fffffff
|
||||
} ovrDebugHudStereoMode;
|
||||
|
||||
typedef void (OVR_PFN *pfn_ovr_ResetBackOfHeadTracking)(ovrSession session);
|
||||
typedef void (OVR_PFN *pfn_ovr_ResetMulticameraTracking)(ovrSession session);
|
||||
typedef ovrBool (OVR_PFN *pfn_ovr_GetBool)(ovrSession session, const char* propertyName, ovrBool defaultVal);
|
||||
typedef ovrBool (OVR_PFN *pfn_ovr_SetBool)(ovrSession session, const char* propertyName, ovrBool value);
|
||||
typedef int (OVR_PFN *pfn_ovr_GetInt)(ovrSession session, const char* propertyName, int defaultVal);
|
||||
typedef ovrBool (OVR_PFN *pfn_ovr_SetInt)(ovrSession session, const char* propertyName, int value);
|
||||
typedef float (OVR_PFN *pfn_ovr_GetFloat)(ovrSession session, const char* propertyName, float defaultVal);
|
||||
typedef ovrBool (OVR_PFN *pfn_ovr_SetFloat)(ovrSession session, const char* propertyName, float value);
|
||||
typedef unsigned int (OVR_PFN *pfn_ovr_GetFloatArray)(ovrSession session, const char* propertyName,
|
||||
float values[], unsigned int valuesCapacity);
|
||||
typedef ovrBool (OVR_PFN *pfn_ovr_SetFloatArray)(ovrSession session, const char* propertyName,
|
||||
const float values[], unsigned int valuesSize);
|
||||
typedef const char* (OVR_PFN *pfn_ovr_GetString)(ovrSession session, const char* propertyName,
|
||||
const char* defaultVal);
|
||||
typedef ovrBool (OVR_PFN *pfn_ovr_SetString)(ovrSession session, const char* propertyName,
|
||||
const char* value);
|
||||
|
||||
|
||||
|
||||
typedef enum {
|
||||
ovrError_MemoryAllocationFailure = -1000,
|
||||
ovrError_SocketCreationFailure = -1001,
|
||||
ovrError_InvalidSession = -1002,
|
||||
ovrError_Timeout = -1003,
|
||||
ovrError_NotInitialized = -1004,
|
||||
ovrError_InvalidParameter = -1005,
|
||||
ovrError_ServiceError = -1006,
|
||||
ovrError_NoHmd = -1007,
|
||||
ovrError_AudioReservedBegin = -2000,
|
||||
ovrError_AudioDeviceNotFound = -2001,
|
||||
ovrError_AudioComError = -2002,
|
||||
ovrError_AudioReservedEnd = -2999,
|
||||
ovrError_Initialize = -3000,
|
||||
ovrError_LibLoad = -3001,
|
||||
ovrError_LibVersion = -3002,
|
||||
ovrError_ServiceConnection = -3003,
|
||||
ovrError_ServiceVersion = -3004,
|
||||
ovrError_IncompatibleOS = -3005,
|
||||
ovrError_DisplayInit = -3006,
|
||||
ovrError_ServerStart = -3007,
|
||||
ovrError_Reinitialization = -3008,
|
||||
ovrError_MismatchedAdapters = -3009,
|
||||
ovrError_LeakingResources = -3010,
|
||||
ovrError_ClientVersion = -3011,
|
||||
ovrError_OutOfDateOS = -3012,
|
||||
ovrError_OutOfDateGfxDriver = -3013,
|
||||
ovrError_IncompatibleGPU = -3014,
|
||||
ovrError_NoValidVRDisplaySystem = -3015,
|
||||
ovrError_InvalidBundleAdjustment = -4000,
|
||||
ovrError_USBBandwidth = -4001,
|
||||
ovrError_USBEnumeratedSpeed = -4002,
|
||||
ovrError_ImageSensorCommError = -4003,
|
||||
ovrError_GeneralTrackerFailure = -4004,
|
||||
ovrError_ExcessiveFrameTruncation = -4005,
|
||||
ovrError_ExcessiveFrameSkipping = -4006,
|
||||
ovrError_SyncDisconnected = -4007,
|
||||
ovrError_TrackerMemoryReadFailure = -4008,
|
||||
ovrError_TrackerMemoryWriteFailure = -4009,
|
||||
ovrError_TrackerFrameTimeout = -4010,
|
||||
ovrError_TrackerTruncatedFrame = -4011,
|
||||
ovrError_HMDFirmwareMismatch = -4100,
|
||||
ovrError_TrackerFirmwareMismatch = -4101,
|
||||
ovrError_BootloaderDeviceDetected = -4102,
|
||||
ovrError_TrackerCalibrationError = -4103,
|
||||
ovrError_ControllerFirmwareMismatch = -4104,
|
||||
ovrError_Incomplete = -5000,
|
||||
ovrError_Abandoned = -5001,
|
||||
ovrError_DisplayLost = -6000,
|
||||
ovrError_RuntimeException = -7000,
|
||||
} ovrErrorType;
|
||||
|
||||
|
||||
#ifdef XP_WIN
|
||||
struct D3D11_TEXTURE2D_DESC;
|
||||
@ -360,9 +565,22 @@ typedef union {
|
||||
ovrD3D11TextureData D3D11;
|
||||
} ovrD3D11Texture;
|
||||
|
||||
typedef ovrResult (OVR_PFN *pfn_ovrHmd_CreateSwapTextureSetD3D11)(ovrHmd hmd, ID3D11Device* device,
|
||||
const D3D11_TEXTURE2D_DESC* desc,
|
||||
ovrSwapTextureSet** outTextureSet);
|
||||
typedef enum {
|
||||
ovrSwapTextureSetD3D11_Typeless = 0x0001,
|
||||
ovrSwapTextureSetD3D11_EnumSize = 0x7fffffff
|
||||
} ovrSwapTextureSetD3D11Flags;
|
||||
|
||||
typedef ovrResult (OVR_PFN *pfn_ovr_CreateSwapTextureSetD3D11)(ovrSession session, ID3D11Device* device,
|
||||
const D3D11_TEXTURE2D_DESC* desc,
|
||||
unsigned int miscFlags,
|
||||
ovrSwapTextureSet** outTextureSet);
|
||||
|
||||
typedef ovrResult (OVR_PFN *pfn_ovr_CreateMirrorTextureD3D11)(ovrSession session,
|
||||
ID3D11Device* device,
|
||||
const D3D11_TEXTURE2D_DESC* desc,
|
||||
unsigned int miscFlags,
|
||||
ovrTexture** outMirrorTexture);
|
||||
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
@ -375,9 +593,13 @@ typedef union {
|
||||
ovrGLTextureData OGL;
|
||||
} ovrGLTexture;
|
||||
|
||||
typedef ovrResult (OVR_PFN *pfn_ovrHmd_CreateSwapTextureSetGL)(ovrHmd hmd, uint32_t format,
|
||||
int width, int height,
|
||||
ovrSwapTextureSet** outTextureSet);
|
||||
typedef ovrResult (OVR_PFN *pfn_ovr_CreateSwapTextureSetGL)(ovrSession session, uint32_t format,
|
||||
int width, int height,
|
||||
ovrSwapTextureSet** outTextureSet);
|
||||
|
||||
typedef ovrResult (OVR_PFN *pfn_ovr_CreateMirrorTextureGL)(ovrSession session, uint32_t format,
|
||||
int width, int height,
|
||||
ovrTexture** outMirrorTexture);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user