Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] master from LibreVR:master #80

Merged
merged 2 commits into from
Oct 13, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
CompositorBase: Move WaitGetPoses to WaitBeginFrame.
PostPresentHandoff now works correctly so we can
split up the wait call for better performance on UE4.
  • Loading branch information
CrossVR committed Oct 13, 2019
commit f69126f96547e1f8f6a4acd4d36d00c28fe3403e
19 changes: 13 additions & 6 deletions Revive/CompositorBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,21 @@ ovrResult CompositorBase::WaitToBeginFrame(ovrSession session, long long frameIn
{
MICROPROFILE_SCOPE(WaitToBeginFrame);

// TODO: Allow waiting to begin frame on the CPU thread
// WaitGetPoses is equivalent to calling BeginFrame, so we need to wait for any frame still in-flight
m_FrameMutex.lock();
m_FrameMutex.unlock();

MICROPROFILE_SCOPE(WaitGetPoses);
vr::VRCompositor()->WaitGetPoses(nullptr, 0, nullptr, 0);
return ovrSuccess;
}

ovrResult CompositorBase::BeginFrame(ovrSession session, long long frameIndex)
{
MICROPROFILE_SCOPE(BeginFrame);

m_FrameMutex.lock();

session->FrameIndex = frameIndex;
return session->Input->UpdateInputState();
}
Expand Down Expand Up @@ -221,17 +228,17 @@ ovrResult CompositorBase::EndFrame(ovrSession session, ovrLayerHeader const * co
if (baseLayer)
error = SubmitLayer(session, baseLayer);

vr::VRCompositor()->PostPresentHandoff();

// Frame now completed so we can let anyone waiting on the next frame call WaitGetPoses
m_FrameMutex.unlock();

if (m_MirrorTexture && error == vr::VRCompositorError_None)
RenderMirrorTexture(m_MirrorTexture);

// Flip the profiler.
MicroProfileFlip();

{
MICROPROFILE_SCOPE(WaitGetPoses);
vr::VRCompositor()->WaitGetPoses(nullptr, 0, nullptr, 0);
}

return rev_CompositorErrorToOvrError(error);
}

Expand Down
2 changes: 2 additions & 0 deletions Revive/CompositorBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include <openvr.h>
#include <vector>
#include <mutex>

class CompositorBase
{
Expand Down Expand Up @@ -47,4 +48,5 @@ class CompositorBase
// Overlays
unsigned int m_OverlayCount;
std::vector<vr::VROverlayHandle_t> m_ActiveOverlays;
std::mutex m_FrameMutex;
};