xrt: Pass along display_time_ns to layer begin

This commit is contained in:
Jakob Bornecrantz 2021-04-05 17:52:44 +01:00
parent f3abddf224
commit efdba1602f
7 changed files with 35 additions and 13 deletions

View file

@ -130,11 +130,14 @@ client_gl_compositor_discard_frame(struct xrt_compositor *xc, int64_t frame_id)
}
static xrt_result_t
client_gl_compositor_layer_begin(struct xrt_compositor *xc, int64_t frame_id, enum xrt_blend_mode env_blend_mode)
client_gl_compositor_layer_begin(struct xrt_compositor *xc,
int64_t frame_id,
uint64_t display_time_ns,
enum xrt_blend_mode env_blend_mode)
{
struct client_gl_compositor *c = client_gl_compositor(xc);
return xrt_comp_layer_begin(&c->xcn->base, frame_id, env_blend_mode);
return xrt_comp_layer_begin(&c->xcn->base, frame_id, display_time_ns, env_blend_mode);
}
static xrt_result_t

View file

@ -212,11 +212,14 @@ client_vk_compositor_discard_frame(struct xrt_compositor *xc, int64_t frame_id)
}
static xrt_result_t
client_vk_compositor_layer_begin(struct xrt_compositor *xc, int64_t frame_id, enum xrt_blend_mode env_blend_mode)
client_vk_compositor_layer_begin(struct xrt_compositor *xc,
int64_t frame_id,
uint64_t display_time_ns,
enum xrt_blend_mode env_blend_mode)
{
struct client_vk_compositor *c = client_vk_compositor(xc);
return xrt_comp_layer_begin(&c->xcn->base, frame_id, env_blend_mode);
return xrt_comp_layer_begin(&c->xcn->base, frame_id, display_time_ns, env_blend_mode);
}
static xrt_result_t

View file

@ -215,7 +215,10 @@ compositor_add_frame_timing(struct comp_compositor *c)
}
static xrt_result_t
compositor_layer_begin(struct xrt_compositor *xc, int64_t frame_id, enum xrt_blend_mode env_blend_mode)
compositor_layer_begin(struct xrt_compositor *xc,
int64_t frame_id,
uint64_t display_time_ns,
enum xrt_blend_mode env_blend_mode)
{
struct comp_compositor *c = comp_compositor(xc);

View file

@ -761,7 +761,10 @@ struct xrt_compositor
* @p layer_commit that layers will be displayed. From the point of view
* of the swapchain the image is used as soon as it's given in a call.
*/
xrt_result_t (*layer_begin)(struct xrt_compositor *xc, int64_t frame_id, enum xrt_blend_mode env_blend_mode);
xrt_result_t (*layer_begin)(struct xrt_compositor *xc,
int64_t frame_id,
uint64_t display_time_ns,
enum xrt_blend_mode env_blend_mode);
/*!
* Adds a stereo projection layer for submissions.
@ -1057,9 +1060,12 @@ xrt_comp_discard_frame(struct xrt_compositor *xc, int64_t frame_id)
* @public @memberof xrt_compositor
*/
static inline xrt_result_t
xrt_comp_layer_begin(struct xrt_compositor *xc, int64_t frame_id, enum xrt_blend_mode env_blend_mode)
xrt_comp_layer_begin(struct xrt_compositor *xc,
int64_t frame_id,
uint64_t display_time_ns,
enum xrt_blend_mode env_blend_mode)
{
return xc->layer_begin(xc, frame_id, env_blend_mode);
return xc->layer_begin(xc, frame_id, display_time_ns, env_blend_mode);
}
/*!

View file

@ -61,6 +61,8 @@ struct ipc_client_compositor
struct
{
uint64_t display_time_ns;
//! Id that we are currently using for submitting layers.
uint32_t slot_id;
@ -456,10 +458,14 @@ ipc_compositor_begin_frame(struct xrt_compositor *xc, int64_t frame_id)
}
static xrt_result_t
ipc_compositor_layer_begin(struct xrt_compositor *xc, int64_t frame_id, enum xrt_blend_mode env_blend_mode)
ipc_compositor_layer_begin(struct xrt_compositor *xc,
int64_t frame_id,
uint64_t display_time_ns,
enum xrt_blend_mode env_blend_mode)
{
struct ipc_client_compositor *icc = ipc_client_compositor(xc);
icc->layers.display_time_ns = display_time_ns;
icc->layers.env_blend_mode = env_blend_mode;
return XRT_SUCCESS;

View file

@ -875,7 +875,7 @@ main_loop(struct ipc_server *s)
broadcast_timings(s, predicted_display_time_ns, predicted_display_period_ns, diff_ns);
xrt_comp_begin_frame(xc, frame_id);
xrt_comp_layer_begin(xc, frame_id, 0);
xrt_comp_layer_begin(xc, frame_id, 0, 0);
_update_layers(s, xc);

View file

@ -1752,9 +1752,10 @@ oxr_session_frame_end(struct oxr_logger *log, struct oxr_session *sess, const Xr
frameEndInfo->displayTime);
}
int64_t timestamp = time_state_ts_to_monotonic_ns(sess->sys->inst->timekeeping, frameEndInfo->displayTime);
int64_t display_time_ns =
time_state_ts_to_monotonic_ns(sess->sys->inst->timekeeping, frameEndInfo->displayTime);
if (sess->frame_timing_spew) {
oxr_log(log, "End frame at %8.3fms with display time %8.3fms", ts_ms(sess), ns_to_ms(timestamp));
oxr_log(log, "End frame at %8.3fms with display time %8.3fms", ts_ms(sess), ns_to_ms(display_time_ns));
}
struct xrt_compositor *xc = sess->compositor;
@ -1885,7 +1886,7 @@ oxr_session_frame_end(struct oxr_logger *log, struct oxr_session *sess, const Xr
struct xrt_pose inv_offset = {0};
math_pose_invert(&xdev->tracking_origin->offset, &inv_offset);
CALL_CHK(xrt_comp_layer_begin(xc, sess->frame_id.begun, blend_mode));
CALL_CHK(xrt_comp_layer_begin(xc, sess->frame_id.begun, display_time_ns, blend_mode));
for (uint32_t i = 0; i < frameEndInfo->layerCount; i++) {
const XrCompositionLayerBaseHeader *layer = frameEndInfo->layers[i];