| 880 | } |
| 881 | |
| 882 | OVR_PUBLIC_FUNCTION(ovrResult) ovr_WaitToBeginFrame(ovrSession session, long long frameIndex) |
| 883 | { |
| 884 | REV_TRACE(ovr_WaitToBeginFrame); |
| 885 | MICROPROFILE_META_CPU("Wait Frame", (int)frameIndex); |
| 886 | |
| 887 | if (!session) |
| 888 | return ovrError_InvalidSession; |
| 889 | |
| 890 | SessionStatusBits status = session->SessionStatus; |
| 891 | if (!status.IsVisible) |
| 892 | return ovrSuccess_NotVisible; |
| 893 | |
| 894 | { |
| 895 | // Wait until the session is running, since the render thread may still be initializing |
| 896 | std::unique_lock<std::mutex> lk(session->Running.first); |
| 897 | if (!session->Running.second.wait_for(lk, 10s, [session] { return session->Session != XR_NULL_HANDLE; })) |
| 898 | return ovrError_Timeout; |
| 899 | } |
| 900 | |
| 901 | assert(session->CurrentFrame.is_lock_free()); |
| 902 | XrIndexedFrameState* frameState = &session->FrameStats[frameIndex % ovrMaxProvidedFrameStats]; |
| 903 | XrFrameWaitInfo waitInfo = XR_TYPE(FRAME_WAIT_INFO); |
| 904 | CHK_XR(xrWaitFrame(session->Session, &waitInfo, frameState)); |
| 905 | frameState->frameIndex = frameIndex; |
| 906 | session->CurrentFrame = frameState; |
| 907 | |
| 908 | if (session->Input) |
| 909 | session->Input->SyncInputState(session->Session, frameState->predictedDisplayPeriod); |
| 910 | return ovrSuccess; |
| 911 | } |
| 912 | |
| 913 | OVR_PUBLIC_FUNCTION(ovrResult) ovr_BeginFrame(ovrSession session, long long frameIndex) |
| 914 | { |
no test coverage detected