Skip to content

Commit

Permalink
Revive: Merge SessionDetails into Session.
Browse files Browse the repository at this point in the history
  • Loading branch information
CrossVR committed Mar 15, 2023
1 parent 0da2790 commit d708439
Show file tree
Hide file tree
Showing 9 changed files with 255 additions and 325 deletions.
7 changes: 3 additions & 4 deletions Revive/CompositorBase.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include "CompositorBase.h"
#include "Common.h"
#include "Session.h"
#include "SessionDetails.h"
#include "InputManager.h"
#include "ProfileManager.h"
#include "TextureBase.h"
Expand Down Expand Up @@ -393,10 +392,10 @@ vr::VRCompositorError CompositorBase::SubmitLayer(ovrSession session, const ovrL
vr::VRTextureBounds_t bounds = ViewportToTextureBounds(layer.EyeFov.Viewport[i], colorChain, baseLayer->Flags);

// Get the descriptor for this eye
const ovrEyeRenderDesc* desc = session->Details->GetRenderDesc((ovrEyeType)i);
const ovrEyeRenderDesc& desc = session->RenderDesc[i];

// Shrink the bounds to account for the overlapping fov
vr::VRTextureBounds_t fovBounds = FovPortToTextureBounds(desc->Fov, fov);
vr::VRTextureBounds_t fovBounds = FovPortToTextureBounds(desc.Fov, fov);

// Combine the fov bounds with the viewport bounds
bounds.uMin += fovBounds.uMin * (bounds.uMax - bounds.uMin);
Expand All @@ -415,7 +414,7 @@ vr::VRCompositorError CompositorBase::SubmitLayer(ovrSession session, const ovrL
texture.Color = colorTexture;

// Add the pose data to the eye texture
OVR::Matrix4f hmdToEye(viewScaleDesc ? viewScaleDesc->HmdToEyePose[i] : desc->HmdToEyePose);
OVR::Matrix4f hmdToEye(viewScaleDesc ? viewScaleDesc->HmdToEyePose[i] : desc.HmdToEyePose);
OVR::Matrix4f pose(baseLayer->Type == ovrLayerType_EyeMatrix ?
layer.EyeMatrix.RenderPose[i] : layer.EyeFov.RenderPose[i]);
texture.Pose.mDeviceToAbsoluteTracking = REV::Matrix4f(pose * hmdToEye.Inverted());
Expand Down
5 changes: 2 additions & 3 deletions Revive/InputManager.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "InputManager.h"
#include "Session.h"
#include "SessionDetails.h"
#include "CompositorBase.h"
#include "OVR_CAPI.h"
#include "REV_Math.h"
Expand Down Expand Up @@ -258,7 +257,7 @@ void InputManager::GetTrackingState(ovrSession session, ovrTrackingState* outSta
vr::TrackedDevicePose_t poses[vr::k_unMaxTrackedDeviceCount];
if (absTime > 0.0f)
{
uint32_t predictionID = (uint32_t)floor(absTime * session->Details->GetRefreshRate());
uint32_t predictionID = (uint32_t)floor(absTime * session->HmdDesc.DisplayRefreshRate);
vr::VRCompositor()->GetPosesForFrame(predictionID, poses, vr::k_unMaxTrackedDeviceCount);
}
else
Expand Down Expand Up @@ -299,7 +298,7 @@ ovrResult InputManager::GetDevicePoses(ovrSession session, ovrTrackedDeviceType*
{
// Get the device poses
vr::TrackedDevicePose_t poses[vr::k_unMaxTrackedDeviceCount];
uint32_t predictionID = (uint32_t)floor(absTime * session->Details->GetRefreshRate());
uint32_t predictionID = (uint32_t)floor(absTime * session->HmdDesc.DisplayRefreshRate);
vr::VRCompositor()->GetPosesForFrame(predictionID, poses, vr::k_unMaxTrackedDeviceCount);

// Get the generic tracker indices
Expand Down
37 changes: 15 additions & 22 deletions Revive/REV_CAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include "Common.h"
#include "Session.h"
#include "CompositorBase.h"
#include "SessionDetails.h"
#include "InputManager.h"
#include "ProfileManager.h"

Expand Down Expand Up @@ -182,7 +181,7 @@ OVR_PUBLIC_FUNCTION(ovrHmdDesc) ovr_GetHmdDesc(ovrSession session)
return desc;
}

return *session->Details->GetHmdDesc();
return session->HmdDesc;
}

OVR_PUBLIC_FUNCTION(unsigned int) ovr_GetTrackerCount(ovrSession session)
Expand All @@ -192,22 +191,16 @@ OVR_PUBLIC_FUNCTION(unsigned int) ovr_GetTrackerCount(ovrSession session)
if (!session)
return ovrError_InvalidSession;

return (unsigned int)session->Details->TrackerCount;
return (unsigned int)session->TrackerCount;
}

OVR_PUBLIC_FUNCTION(ovrTrackerDesc) ovr_GetTrackerDesc(ovrSession session, unsigned int trackerDescIndex)
{
REV_TRACE(ovr_GetTrackerDesc);

if (!session)
return ovrTrackerDesc();

const ovrTrackerDesc* pDesc = session->Details->GetTrackerDesc(trackerDescIndex);

if (!pDesc)
return ovrTrackerDesc();

return *pDesc;
if (session && trackerDescIndex < session->TrackerCount)
return session->TrackerDesc[trackerDescIndex];
return ovrTrackerDesc();
}

OVR_PUBLIC_FUNCTION(ovrResult) ovr_Create(ovrSession* pSession, ovrGraphicsLuid* pLuid)
Expand Down Expand Up @@ -302,7 +295,7 @@ OVR_PUBLIC_FUNCTION(ovrResult) ovr_GetSessionStatus(ovrSession session, ovrSessi
sessionStatus->IsVisible = vr::VRCompositor()->CanRenderScene() && !first_call;
first_call = false;

static const bool do_sleep = session->Details->UseHack(SessionDetails::HACK_SLEEP_IN_SESSION_STATUS);
static const bool do_sleep = session->UseHack(HACK_SLEEP_IN_SESSION_STATUS);
if (do_sleep)
std::this_thread::sleep_for(std::chrono::milliseconds(1));

Expand Down Expand Up @@ -397,7 +390,7 @@ OVR_PUBLIC_FUNCTION(ovrTrackerPose) ovr_GetTrackerPose(ovrSession session, unsig
if (!session)
return tracker;

if (session->Details->UseHack(SessionDetails::HACK_SPOOF_SENSORS))
if (session->UseHack(HACK_SPOOF_SENSORS))
{
if (trackerPoseIndex < ovr_GetTrackerCount(session))
{
Expand Down Expand Up @@ -812,12 +805,12 @@ OVR_PUBLIC_FUNCTION(ovrSizei) ovr_GetFovTextureSize(ovrSession session, ovrEyeTy
REV_TRACE(ovr_GetFovTextureSize);

// Get the descriptor for this eye
const ovrEyeRenderDesc* desc = session->Details->GetRenderDesc(eye);
ovrSizei size = desc->DistortedViewport.Size;
const ovrEyeRenderDesc& desc = session->RenderDesc[eye];
ovrSizei size = desc.DistortedViewport.Size;

// Grow the recommended size to account for the overlapping fov
// TODO: Add a setting to ignore pixelsPerDisplayPixel
vr::VRTextureBounds_t bounds = CompositorBase::FovPortToTextureBounds(desc->Fov, fov);
vr::VRTextureBounds_t bounds = CompositorBase::FovPortToTextureBounds(desc.Fov, fov);
size.w = int(size.w / (bounds.uMax - bounds.uMin));
size.h = int(size.h / (bounds.vMax - bounds.vMin));

Expand All @@ -829,7 +822,7 @@ OVR_PUBLIC_FUNCTION(ovrEyeRenderDesc) ovr_GetRenderDesc2(ovrSession session, ovr
REV_TRACE(ovr_GetRenderDesc);

// Make a copy so we can adjust a few parameters
ovrEyeRenderDesc desc = *session->Details->GetRenderDesc(eyeType);
ovrEyeRenderDesc desc = session->RenderDesc[eyeType];

// Adjust the descriptor for the supplied field-of-view
desc.Fov = fov;
Expand Down Expand Up @@ -928,8 +921,8 @@ OVR_PUBLIC_FUNCTION(ovrResult) ovr_SubmitFrame(ovrSession session, long long fra
if (viewScaleDesc)
{
ovrViewScaleDesc viewScale;
viewScale.HmdToEyePose[ovrEye_Left] = OVR::Posef(session->Details->GetRenderDesc(ovrEye_Left)->HmdToEyePose.Orientation, viewScaleDesc->HmdToEyeOffset[ovrEye_Left]);
viewScale.HmdToEyePose[ovrEye_Right] = OVR::Posef(session->Details->GetRenderDesc(ovrEye_Right)->HmdToEyePose.Orientation, viewScaleDesc->HmdToEyeOffset[ovrEye_Right]);
viewScale.HmdToEyePose[ovrEye_Left] = OVR::Posef(session->RenderDesc[ovrEye_Left].HmdToEyePose.Orientation, viewScaleDesc->HmdToEyeOffset[ovrEye_Left]);
viewScale.HmdToEyePose[ovrEye_Right] = OVR::Posef(session->RenderDesc[ovrEye_Right].HmdToEyePose.Orientation, viewScaleDesc->HmdToEyeOffset[ovrEye_Right]);
viewScale.HmdSpaceToWorldScaleInMeters = viewScaleDesc->HmdSpaceToWorldScaleInMeters;
return ovr_SubmitFrame2(session, frameIndex, &viewScale, layerPtrList, layerCount);
}
Expand Down Expand Up @@ -966,7 +959,7 @@ OVR_PUBLIC_FUNCTION(ovrResult) ovr_GetPerfStats(ovrSession session, ovrPerfStats
{
REV_TRACE(ovr_GetPerfStats);

if (session->Details->UseHack(SessionDetails::HACK_DISABLE_STATS))
if (session->UseHack(HACK_DISABLE_STATS))
return ovrSuccess;

ovrPerfStatsPerCompositorFrame FrameStats[ovrMaxProvidedFrameStats] = { 0 };
Expand Down Expand Up @@ -1072,7 +1065,7 @@ OVR_PUBLIC_FUNCTION(double) ovr_GetPredictedDisplayTime(ovrSession session, long
uint32_t predictionID = 0;
vr::VRCompositor()->GetLastPosePredictionIDs(&predictionID, nullptr);
predictionID += (uint32_t)(frameIndex - session->FrameIndex);
return (double)predictionID / session->Details->GetRefreshRate();
return (double)predictionID / session->HmdDesc.DisplayRefreshRate;
}

OVR_PUBLIC_FUNCTION(double) ovr_GetTimeInSeconds()
Expand Down
2 changes: 0 additions & 2 deletions Revive/Revive.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,6 @@
<ClInclude Include="OVR_CAPI.h" />
<ClInclude Include="ProfileManager.h" />
<ClInclude Include="REV_Math.h" />
<ClInclude Include="SessionDetails.h" />
<ClInclude Include="InputManager.h" />
<ClInclude Include="Session.h" />
<ClInclude Include="Common.h" />
Expand All @@ -364,7 +363,6 @@
<ClCompile Include="HapticsBuffer.cpp" />
<ClCompile Include="ProfileManager.cpp" />
<ClCompile Include="REV_CAPI_Vk.cpp" />
<ClCompile Include="SessionDetails.cpp" />
<ClCompile Include="InputManager.cpp" />
<ClCompile Include="main.cpp" />
<ClCompile Include="microprofile.cpp" />
Expand Down
6 changes: 0 additions & 6 deletions Revive/Revive.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,6 @@
<ClInclude Include="TextureGL.h">
<Filter>Header Files\LibRevive</Filter>
</ClInclude>
<ClInclude Include="SessionDetails.h">
<Filter>Header Files\LibRevive</Filter>
</ClInclude>
<ClInclude Include="HapticsBuffer.h">
<Filter>Header Files\LibRevive</Filter>
</ClInclude>
Expand Down Expand Up @@ -131,9 +128,6 @@
<ClCompile Include="microprofile.cpp">
<Filter>Source Files\microprofile</Filter>
</ClCompile>
<ClCompile Include="SessionDetails.cpp">
<Filter>Source Files\LibRevive</Filter>
</ClCompile>
<ClCompile Include="HapticsBuffer.cpp">
<Filter>Source Files\LibRevive</Filter>
</ClCompile>
Expand Down
Loading

0 comments on commit d708439

Please sign in to comment.