MCPcopy Create free account
hub / github.com/LibreVR/Revive / ovr_GetPerfStats

Function ovr_GetPerfStats

Revive/REV_CAPI.cpp:988–1079  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

986} ovrPerfStats1;
987
988OVR_PUBLIC_FUNCTION(ovrResult) ovr_GetPerfStats(ovrSession session, ovrPerfStats* outStats)
989{
990 REV_TRACE(ovr_GetPerfStats);
991
992 if (session->UseHack(HACK_DISABLE_STATS))
993 return ovrSuccess;
994
995 ovrPerfStatsPerCompositorFrame FrameStats[ovrMaxProvidedFrameStats] = { 0 };
996
997 // TODO: Implement performance scale heuristics
998 float AdaptiveGpuPerformanceScale = 1.0f;
999 ovrBool AnyFrameStatsDropped = (session->FrameIndex - session->StatsIndex) > ovrMaxProvidedFrameStats;
1000 int FrameStatsCount = AnyFrameStatsDropped ? ovrMaxProvidedFrameStats : int(session->FrameIndex - session->StatsIndex);
1001 session->StatsIndex = session->FrameIndex;
1002
1003 vr::Compositor_FrameTiming TimingStats[ovrMaxProvidedFrameStats];
1004 TimingStats[0].m_nSize = sizeof(vr::Compositor_FrameTiming);
1005 FrameStatsCount = vr::VRCompositor()->GetFrameTimings(TimingStats, FrameStatsCount);
1006
1007 vr::Compositor_CumulativeStats TotalStats;
1008 vr::VRCompositor()->GetCumulativeStats(&TotalStats, sizeof(vr::Compositor_CumulativeStats));
1009
1010 // Subtract the base stats so we get the cumulative stats since the last call to ovr_ResetPerfStats
1011 TotalStats.m_nNumFramePresents -= session->BaseStats.m_nNumFramePresents;
1012 TotalStats.m_nNumDroppedFrames -= session->BaseStats.m_nNumDroppedFrames;
1013 TotalStats.m_nNumReprojectedFrames -= session->BaseStats.m_nNumReprojectedFrames;
1014 TotalStats.m_nNumFramePresentsOnStartup -= session->BaseStats.m_nNumFramePresentsOnStartup;
1015 TotalStats.m_nNumDroppedFramesOnStartup -= session->BaseStats.m_nNumDroppedFramesOnStartup;
1016 TotalStats.m_nNumReprojectedFramesOnStartup -= session->BaseStats.m_nNumReprojectedFramesOnStartup;
1017 TotalStats.m_nNumLoading -= session->BaseStats.m_nNumLoading;
1018 TotalStats.m_nNumFramePresentsLoading -= session->BaseStats.m_nNumFramePresentsLoading;
1019 TotalStats.m_nNumDroppedFramesLoading -= session->BaseStats.m_nNumDroppedFramesLoading;
1020 TotalStats.m_nNumReprojectedFramesLoading -= session->BaseStats.m_nNumReprojectedFramesLoading;
1021 TotalStats.m_nNumTimedOut -= session->BaseStats.m_nNumTimedOut;
1022 TotalStats.m_nNumFramePresentsTimedOut -= session->BaseStats.m_nNumFramePresentsTimedOut;
1023 TotalStats.m_nNumDroppedFramesTimedOut -= session->BaseStats.m_nNumDroppedFramesTimedOut;
1024 TotalStats.m_nNumReprojectedFramesTimedOut -= session->BaseStats.m_nNumReprojectedFramesTimedOut;
1025
1026 float fVsyncToPhotons = vr::VRSystem()->GetFloatTrackedDeviceProperty(vr::k_unTrackedDeviceIndex_Hmd, vr::Prop_SecondsFromVsyncToPhotons_Float);
1027 float fDisplayFrequency = vr::VRSystem()->GetFloatTrackedDeviceProperty(vr::k_unTrackedDeviceIndex_Hmd, vr::Prop_DisplayFrequency_Float);
1028 float fFrameDuration = 1.0f / fDisplayFrequency;
1029 for (int i = 0; i < FrameStatsCount; i++)
1030 {
1031 ovrPerfStatsPerCompositorFrame& stats = FrameStats[i];
1032
1033 stats.HmdVsyncIndex = TotalStats.m_nNumFramePresents;
1034 stats.AppFrameIndex = (int)session->FrameIndex;
1035 stats.AppDroppedFrameCount = TotalStats.m_nNumDroppedFrames + TotalStats.m_nNumReprojectedFrames;
1036 // TODO: Improve latency stats with sensor timestamps and latency markers
1037 stats.AppMotionToPhotonLatency = fFrameDuration + fVsyncToPhotons;
1038 stats.AppQueueAheadTime = VR_COMPOSITOR_ADDITIONAL_PREDICTED_FRAMES(TimingStats[i]) / fDisplayFrequency;
1039 stats.AppCpuElapsedTime = TimingStats[i].m_flClientFrameIntervalMs / 1000.0f;
1040 stats.AppGpuElapsedTime = TimingStats[i].m_flPreSubmitGpuMs / 1000.0f;
1041
1042 stats.CompositorFrameIndex = TimingStats[i].m_nNumFramePresents;
1043 stats.CompositorDroppedFrameCount = 0;
1044 stats.CompositorLatency = fVsyncToPhotons;
1045 stats.CompositorCpuElapsedTime = TimingStats[i].m_flCompositorRenderCpuMs / 1000.0f;

Callers

nothing calls this directly

Calls 1

UseHackMethod · 0.45

Tested by

no test coverage detected