Removed frame latency in GLEscrow

This could occur if the GLEscrow queue has extra frames in it.
When new textures were fetched, before this fix, they were simply popped from the queue.
This commit introduces a loop, that will fetch from the queue until it is empty.
This commit is contained in:
Anthony Thibault 2016-03-21 21:51:16 -07:00
parent 225c462685
commit b1286517c6
2 changed files with 8 additions and 6 deletions

View file

@ -203,13 +203,15 @@ public:
// Also releases any previous texture held by the caller
bool fetchSignaledAndRelease(T& value) {
T originalValue = value;
if (fetchSignaled(value)) {
bool fetched = false;
while (fetchSignaled(value)) {
fetched = true;
if (originalValue != invalid()) {
release(originalValue);
}
return true;
originalValue = value;
}
return false;
return fetched;
}
bool fetchAndReleaseWithFence(T& value, GLsync& sync) {

View file

@ -119,14 +119,14 @@ void OpenVrDisplayPlugin::updateHeadPose(uint32_t frameIndex) {
float vsyncToPhotons = _system->GetFloatTrackedDeviceProperty(vr::k_unTrackedDeviceIndex_Hmd, vr::Prop_SecondsFromVsyncToPhotons_Float);
#if THREADED_PRESENT
// TODO: this seems awfuly long, 44ms total, but it produced the best results.
const float NUM_PREDICTION_FRAMES = 3.0f;
// 2 frames of prediction + vsyncToPhotons = 33ms total
const float NUM_PREDICTION_FRAMES = 2.0f;
float predictedSecondsFromNow = NUM_PREDICTION_FRAMES * frameDuration + vsyncToPhotons;
#else
uint64_t frameCounter;
float timeSinceLastVsync;
_system->GetTimeSinceLastVsync(&timeSinceLastVsync, &frameCounter);
float predictedSecondsFromNow = 3.0f * frameDuration - timeSinceLastVsync + vsyncToPhotons;
float predictedSecondsFromNow = 2.0f * frameDuration - timeSinceLastVsync + vsyncToPhotons;
#endif
vr::TrackedDevicePose_t predictedTrackedDevicePose[vr::k_unMaxTrackedDeviceCount];