Sync predictions with display time

This commit is contained in:
Patrick Nicolas
2024-09-03 23:34:23 +02:00
parent b0290c037a
commit 7eea3c2e7b
4 changed files with 25 additions and 6 deletions
+6 -1
View File
@@ -193,8 +193,9 @@ void scenes::stream::tracking()
timer t(instance);
XrDuration prediction = std::min<XrDuration>(tracking_prediction_offset, 80'000'000);
auto period = std::max<XrDuration>(display_time_period.load(), 1'000'000);
// 1 or 2 samples
for (XrDuration Δt = 0; Δt <= prediction; Δt += std::max<XrDuration>(1, prediction))
for (XrDuration Δt = 0; Δt <= prediction + period / 2; Δt += period)
{
from_headset::hand_tracking hands{};
from_headset::fb_face2 fb_face2{};
@@ -264,6 +265,10 @@ void scenes::stream::tracking()
e.code().value() != XR_ERROR_TIME_INVALID)
throw;
}
// Make sure predictions are phase-synced with display time
if (Δt == 0 and prediction)
Δt = display_time_phase - t0 % period;
}
#ifdef __ANDROID__