tracking frequency is now a divisor of display period

This commit is contained in:
Patrick Nicolas
2025-01-30 08:58:31 +01:00
parent 06b5fd7e6c
commit 54c592e66a
3 changed files with 20 additions and 3 deletions
+16 -3
View File
@@ -186,7 +186,9 @@ void scenes::stream::tracking()
XrSpace view_space = application::space(xr::spaces::view);
XrSpace world_space = application::space(xr::spaces::world);
XrDuration tracking_period = min_tracking_period;
XrDuration tracking_period = min_tracking_period; // target period for 20% busy time
XrDuration current_tracking_period = tracking_period; // divider of frame period
int period_adjust = 0;
XrTime t0 = instance.now();
XrTime last_hand_sample = t0;
@@ -288,7 +290,7 @@ void scenes::stream::tracking()
XrDuration busy_time = t.count();
// Target: polling between 1 and 5ms, with 20% busy time
tracking_period = std::clamp<XrDuration>(std::lerp(tracking_period, busy_time * 5, 0.2), min_tracking_period, max_tracking_period);
tracking_period = std::clamp<XrDuration>(std::lerp(tracking_period, busy_time * 5, 0.1), min_tracking_period, max_tracking_period);
#ifdef __ANDROID__
if (next_battery_check < now and control.enabled[size_t(tid::battery)])
@@ -335,7 +337,18 @@ void scenes::stream::tracking()
network_session->send_stream(std::move(packets));
t0 += tracking_period;
if (period_adjust == 0)
{
if (auto p = real_display_period.load())
{
period_adjust = (p / tracking_period);
current_tracking_period = p / period_adjust;
}
}
else
--period_adjust;
t0 += current_tracking_period;
}
catch (std::exception & e)
{