From 6b8103f31b5d2550cb3588d3e30fb2fa4b8c3d55 Mon Sep 17 00:00:00 2001 From: Christoph Haag Date: Sat, 15 Feb 2020 02:35:37 +0100 Subject: [PATCH] comp: Update nominal frame interval to match chosen mode in direct mdoe This value is used in xrWaitFrame() to throttle the application's rendering down to the refresh rate of the HMD. --- .../compositor/main/comp_window_direct_mode.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/xrt/compositor/main/comp_window_direct_mode.cpp b/src/xrt/compositor/main/comp_window_direct_mode.cpp index f9432fd67..7f2c646f2 100644 --- a/src/xrt/compositor/main/comp_window_direct_mode.cpp +++ b/src/xrt/compositor/main/comp_window_direct_mode.cpp @@ -468,6 +468,20 @@ comp_window_direct_get_primary_display_mode(struct comp_window_direct *w, props.parameters.visibleRegion.height, (float)props.parameters.refreshRate / 1000.); + int64_t new_frame_interval = + 1000. * 1000. * 1000. * 1000. / props.parameters.refreshRate; + + COMP_DEBUG(w->base.c, + "Updating compositor settings nominal frame interval from " + "%lu (%f Hz) to %lu (%f Hz)", + w->base.c->settings.nominal_frame_interval_ns, + 1000. * 1000. * 1000. / + (float)w->base.c->settings.nominal_frame_interval_ns, + new_frame_interval, + (float)props.parameters.refreshRate / 1000.); + + w->base.c->settings.nominal_frame_interval_ns = new_frame_interval; + delete[] mode_properties; return props.displayMode;