comp: Keep track of nominal display interval and last time

This commit is contained in:
Ryan Pavlik 2019-03-17 20:28:09 -07:00 committed by Jakob Bornecrantz
parent f6c97ec253
commit 8c37377853
4 changed files with 16 additions and 0 deletions

View file

@ -14,6 +14,7 @@
#include "util/u_debug.h" #include "util/u_debug.h"
#include "util/u_misc.h" #include "util/u_misc.h"
#include "util/u_time.h"
#include "main/comp_compositor.h" #include "main/comp_compositor.h"
#include "main/comp_client_interface.h" #include "main/comp_client_interface.h"
@ -79,6 +80,9 @@ compositor_wait_frame(struct xrt_compositor *xc,
{ {
struct comp_compositor *c = comp_compositor(xc); struct comp_compositor *c = comp_compositor(xc);
COMP_SPEW(c, "WAIT_FRAME"); COMP_SPEW(c, "WAIT_FRAME");
*predicted_display_period = c->settings.nominal_frame_interval_ns;
*predicted_display_time =
c->last_frame_time_ns + c->settings.nominal_frame_interval_ns;
//! @todo set *predicted_display_time //! @todo set *predicted_display_time
@ -121,6 +125,9 @@ compositor_end_frame(struct xrt_compositor *xc,
} else { } else {
COMP_ERROR(c, "non-stereo rendering not supported"); COMP_ERROR(c, "non-stereo rendering not supported");
} }
// Record the time of this frame.
c->last_frame_time_ns = time_state_get_now(c->timekeeping);
} }
@ -487,6 +494,7 @@ comp_compositor_create(struct xrt_device *xdev,
comp_settings_init(&c->settings, xdev); comp_settings_init(&c->settings, xdev);
c->settings.flip_y = flip_y; c->settings.flip_y = flip_y;
c->last_frame_time_ns = time_state_get_now(c->timekeeping);
// Need to select window backend before creating Vulkan, then // Need to select window backend before creating Vulkan, then
// swapchain will initialize the window fully and the swapchain, and // swapchain will initialize the window fully and the swapchain, and

View file

@ -118,6 +118,9 @@ struct comp_compositor
//! Vulkan bundle of things. //! Vulkan bundle of things.
struct vk_bundle vk; struct vk_bundle vk;
//! Timestamp of last-rendered (immersive) frame.
int64_t last_frame_time_ns;
/*! /*!
* The current state we are tracking. * The current state we are tracking.
* *

View file

@ -30,6 +30,8 @@ comp_settings_init(struct comp_settings *s, struct xrt_device *xdev)
s->distortion_model = xdev->distortion.preferred; s->distortion_model = xdev->distortion.preferred;
s->width = xdev->screens[0].w_pixels; s->width = xdev->screens[0].w_pixels;
s->height = xdev->screens[0].h_pixels; s->height = xdev->screens[0].h_pixels;
s->nominal_frame_interval_ns =
xdev->screens[0].nominal_frame_interval_ns;
s->print_spew = debug_get_bool_option_print_spew(); s->print_spew = debug_get_bool_option_print_spew();
s->print_debug = debug_get_bool_option_print_debug(); s->print_debug = debug_get_bool_option_print_debug();

View file

@ -67,6 +67,9 @@ struct comp_settings
//! Should we flip y axis for compositor buffers (for GL) //! Should we flip y axis for compositor buffers (for GL)
bool flip_y; bool flip_y;
//! Nominal frame interval
uint64_t nominal_frame_interval_ns;
}; };
/*! /*!