Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Reuse the last frame and tracking when a VR frame is discarded in Oculus #2341

Merged
merged 1 commit into from
Nov 21, 2019
Merged
Changes from all commits
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
15 changes: 14 additions & 1 deletion app/src/oculusvr/cpp/DeviceDelegateOculusVR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,9 @@ struct DeviceDelegateOculusVR::State {
uint32_t frameIndex = 0;
double predictedDisplayTime = 0;
ovrTracking2 predictedTracking = {};
ovrTracking2 discardPredictedTracking = {};
uint32_t discardedFrameIndex = 0;
int discardCount = 0;
Comment on lines +677 to +679
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Please unify these variables' naming, discarded or discard? I would consider to replace discardFrameIndex with discardFrameIndex.

uint32_t renderWidth = 0;
uint32_t renderHeight = 0;
int32_t standaloneFoveatedLevel = 0;
Expand Down Expand Up @@ -1463,7 +1466,17 @@ DeviceDelegateOculusVR::EndFrame(const bool aDiscard) {
}

if (aDiscard) {
return;
// Reuse the last frame when a frame is discarded.
// The last frame is timewarped by the VR compositor.
if (m.discardCount == 0) {
m.discardPredictedTracking = m.predictedTracking;
m.discardedFrameIndex = m.frameIndex;
}
m.discardCount++;
m.frameIndex = m.discardedFrameIndex;
m.predictedTracking = m.discardPredictedTracking;
} else {
m.discardCount = 0;
}

uint32_t layerCount = 0;
Expand Down