mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2024-12-29 11:06:18 +00:00
xrt: Introduce xrt_layer_frame_data
This commit is contained in:
parent
bec9a30bfe
commit
50838f5801
|
@ -506,15 +506,12 @@ client_d3d11_compositor_discard_frame(struct xrt_compositor *xc, int64_t frame_i
|
|||
}
|
||||
|
||||
static xrt_result_t
|
||||
client_d3d11_compositor_layer_begin(struct xrt_compositor *xc,
|
||||
int64_t frame_id,
|
||||
uint64_t display_time_ns,
|
||||
enum xrt_blend_mode env_blend_mode)
|
||||
client_d3d11_compositor_layer_begin(struct xrt_compositor *xc, const struct xrt_layer_frame_data *data)
|
||||
{
|
||||
struct client_d3d11_compositor *c = as_client_d3d11_compositor(xc);
|
||||
|
||||
// Pipe down call into native compositor.
|
||||
return xrt_comp_layer_begin(&c->xcn->base, frame_id, display_time_ns, env_blend_mode);
|
||||
return xrt_comp_layer_begin(&c->xcn->base, data);
|
||||
}
|
||||
|
||||
static xrt_result_t
|
||||
|
@ -638,9 +635,7 @@ client_d3d11_compositor_layer_equirect2(struct xrt_compositor *xc,
|
|||
}
|
||||
|
||||
static xrt_result_t
|
||||
client_d3d11_compositor_layer_commit(struct xrt_compositor *xc,
|
||||
int64_t frame_id,
|
||||
xrt_graphics_sync_handle_t sync_handle)
|
||||
client_d3d11_compositor_layer_commit(struct xrt_compositor *xc, xrt_graphics_sync_handle_t sync_handle)
|
||||
{
|
||||
struct client_d3d11_compositor *c = as_client_d3d11_compositor(xc);
|
||||
|
||||
|
@ -655,19 +650,25 @@ client_d3d11_compositor_layer_commit(struct xrt_compositor *xc,
|
|||
char buf[kErrorBufSize];
|
||||
formatMessage(hr, buf);
|
||||
D3D_ERROR(c, "Error signaling fence: %s", buf);
|
||||
return xrt_comp_layer_commit(&c->xcn->base, frame_id, XRT_GRAPHICS_SYNC_HANDLE_INVALID);
|
||||
return xrt_comp_layer_commit(&c->xcn->base, XRT_GRAPHICS_SYNC_HANDLE_INVALID);
|
||||
}
|
||||
}
|
||||
|
||||
if (c->timeline_semaphore) {
|
||||
// We got this from the native compositor, so we can pass it back
|
||||
return xrt_comp_layer_commit_with_semaphore(&c->xcn->base, frame_id, c->timeline_semaphore.get(),
|
||||
c->timeline_semaphore_value);
|
||||
return xrt_comp_layer_commit_with_semaphore( //
|
||||
&c->xcn->base, //
|
||||
c->timeline_semaphore.get(), //
|
||||
c->timeline_semaphore_value); //
|
||||
}
|
||||
|
||||
if (c->fence) {
|
||||
// Wait on it ourselves, if we have it and didn't tell the native compositor to wait on it.
|
||||
xret = xrt::auxiliary::d3d::d3d11::waitOnFenceWithTimeout(c->fence, c->local_wait_event,
|
||||
c->timeline_semaphore_value, kFenceTimeout);
|
||||
xret = xrt::auxiliary::d3d::d3d11::waitOnFenceWithTimeout( //
|
||||
c->fence, //
|
||||
c->local_wait_event, //
|
||||
c->timeline_semaphore_value, //
|
||||
kFenceTimeout); //
|
||||
if (xret != XRT_SUCCESS) {
|
||||
struct u_pp_sink_stack_only sink; // Not inited, very large.
|
||||
u_pp_delegate_t dg = u_pp_sink_stack_only_init(&sink);
|
||||
|
@ -679,7 +680,7 @@ client_d3d11_compositor_layer_commit(struct xrt_compositor *xc,
|
|||
}
|
||||
}
|
||||
|
||||
return xrt_comp_layer_commit(&c->xcn->base, frame_id, XRT_GRAPHICS_SYNC_HANDLE_INVALID);
|
||||
return xrt_comp_layer_commit(&c->xcn->base, XRT_GRAPHICS_SYNC_HANDLE_INVALID);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -607,15 +607,12 @@ client_d3d12_compositor_discard_frame(struct xrt_compositor *xc, int64_t frame_i
|
|||
}
|
||||
|
||||
static xrt_result_t
|
||||
client_d3d12_compositor_layer_begin(struct xrt_compositor *xc,
|
||||
int64_t frame_id,
|
||||
uint64_t display_time_ns,
|
||||
enum xrt_blend_mode env_blend_mode)
|
||||
client_d3d12_compositor_layer_begin(struct xrt_compositor *xc, const struct xrt_layer_frame_data *data)
|
||||
{
|
||||
struct client_d3d12_compositor *c = as_client_d3d12_compositor(xc);
|
||||
|
||||
// Pipe down call into native compositor.
|
||||
return xrt_comp_layer_begin(&c->xcn->base, frame_id, display_time_ns, env_blend_mode);
|
||||
return xrt_comp_layer_begin(&c->xcn->base, data);
|
||||
}
|
||||
|
||||
static xrt_result_t
|
||||
|
@ -739,9 +736,7 @@ client_d3d12_compositor_layer_equirect2(struct xrt_compositor *xc,
|
|||
}
|
||||
|
||||
static xrt_result_t
|
||||
client_d3d12_compositor_layer_commit(struct xrt_compositor *xc,
|
||||
int64_t frame_id,
|
||||
xrt_graphics_sync_handle_t sync_handle)
|
||||
client_d3d12_compositor_layer_commit(struct xrt_compositor *xc, xrt_graphics_sync_handle_t sync_handle)
|
||||
{
|
||||
struct client_d3d12_compositor *c = as_client_d3d12_compositor(xc);
|
||||
|
||||
|
@ -756,19 +751,24 @@ client_d3d12_compositor_layer_commit(struct xrt_compositor *xc,
|
|||
char buf[kErrorBufSize];
|
||||
formatMessage(hr, buf);
|
||||
D3D_ERROR(c, "Error signaling fence: %s", buf);
|
||||
return xrt_comp_layer_commit(&c->xcn->base, frame_id, XRT_GRAPHICS_SYNC_HANDLE_INVALID);
|
||||
return xrt_comp_layer_commit(&c->xcn->base, XRT_GRAPHICS_SYNC_HANDLE_INVALID);
|
||||
}
|
||||
}
|
||||
if (c->timeline_semaphore) {
|
||||
// We got this from the native compositor, so we can pass it back
|
||||
return xrt_comp_layer_commit_with_semaphore(&c->xcn->base, frame_id, c->timeline_semaphore.get(),
|
||||
c->timeline_semaphore_value);
|
||||
return xrt_comp_layer_commit_with_semaphore( //
|
||||
&c->xcn->base, //
|
||||
c->timeline_semaphore.get(), //
|
||||
c->timeline_semaphore_value); //
|
||||
}
|
||||
|
||||
if (c->fence) {
|
||||
// Wait on it ourselves, if we have it and didn't tell the native compositor to wait on it.
|
||||
xret = xrt::auxiliary::d3d::d3d12::waitOnFenceWithTimeout(c->fence, c->local_wait_event,
|
||||
c->timeline_semaphore_value, kFenceTimeout);
|
||||
xret = xrt::auxiliary::d3d::d3d12::waitOnFenceWithTimeout( //
|
||||
c->fence, //
|
||||
c->local_wait_event, //
|
||||
c->timeline_semaphore_value, //
|
||||
kFenceTimeout); //
|
||||
if (xret != XRT_SUCCESS) {
|
||||
struct u_pp_sink_stack_only sink; // Not inited, very large.
|
||||
u_pp_delegate_t dg = u_pp_sink_stack_only_init(&sink);
|
||||
|
@ -780,7 +780,7 @@ client_d3d12_compositor_layer_commit(struct xrt_compositor *xc,
|
|||
}
|
||||
}
|
||||
|
||||
return xrt_comp_layer_commit(&c->xcn->base, frame_id, XRT_GRAPHICS_SYNC_HANDLE_INVALID);
|
||||
return xrt_comp_layer_commit(&c->xcn->base, XRT_GRAPHICS_SYNC_HANDLE_INVALID);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -215,14 +215,11 @@ 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,
|
||||
uint64_t display_time_ns,
|
||||
enum xrt_blend_mode env_blend_mode)
|
||||
client_gl_compositor_layer_begin(struct xrt_compositor *xc, const struct xrt_layer_frame_data *data)
|
||||
{
|
||||
struct client_gl_compositor *c = client_gl_compositor(xc);
|
||||
|
||||
return xrt_comp_layer_begin(&c->xcn->base, frame_id, display_time_ns, env_blend_mode);
|
||||
return xrt_comp_layer_begin(&c->xcn->base, data);
|
||||
}
|
||||
|
||||
static xrt_result_t
|
||||
|
@ -371,7 +368,7 @@ client_gl_compositor_layer_equirect2(struct xrt_compositor *xc,
|
|||
}
|
||||
|
||||
static xrt_result_t
|
||||
client_gl_compositor_layer_commit(struct xrt_compositor *xc, int64_t frame_id, xrt_graphics_sync_handle_t sync_handle)
|
||||
client_gl_compositor_layer_commit(struct xrt_compositor *xc, xrt_graphics_sync_handle_t sync_handle)
|
||||
{
|
||||
COMP_TRACE_MARKER();
|
||||
|
||||
|
@ -390,7 +387,7 @@ client_gl_compositor_layer_commit(struct xrt_compositor *xc, int64_t frame_id, x
|
|||
|
||||
COMP_TRACE_IDENT(layer_commit);
|
||||
|
||||
return xrt_comp_layer_commit(&c->xcn->base, frame_id, sync_handle);
|
||||
return xrt_comp_layer_commit(&c->xcn->base, sync_handle);
|
||||
}
|
||||
|
||||
static xrt_result_t
|
||||
|
|
|
@ -84,10 +84,7 @@ setup_semaphore(struct client_vk_compositor *c)
|
|||
*/
|
||||
|
||||
static bool
|
||||
submit_handle(struct client_vk_compositor *c,
|
||||
int64_t frame_id,
|
||||
xrt_graphics_sync_handle_t sync_handle,
|
||||
xrt_result_t *out_xret)
|
||||
submit_handle(struct client_vk_compositor *c, xrt_graphics_sync_handle_t sync_handle, xrt_result_t *out_xret)
|
||||
{
|
||||
// Did we get a ready made handle, assume it's in the command stream and call commit directly.
|
||||
if (!xrt_graphics_sync_handle_is_valid(sync_handle)) {
|
||||
|
@ -95,12 +92,12 @@ submit_handle(struct client_vk_compositor *c,
|
|||
}
|
||||
|
||||
// Commit consumes the sync_handle.
|
||||
*out_xret = xrt_comp_layer_commit(&c->xcn->base, frame_id, sync_handle);
|
||||
*out_xret = xrt_comp_layer_commit(&c->xcn->base, sync_handle);
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
submit_semaphore(struct client_vk_compositor *c, int64_t frame_id, xrt_result_t *out_xret)
|
||||
submit_semaphore(struct client_vk_compositor *c, xrt_result_t *out_xret)
|
||||
{
|
||||
#ifdef VK_KHR_timeline_semaphore
|
||||
if (c->sync.xcsem == NULL) {
|
||||
|
@ -144,7 +141,6 @@ submit_semaphore(struct client_vk_compositor *c, int64_t frame_id, xrt_result_t
|
|||
|
||||
*out_xret = xrt_comp_layer_commit_with_semaphore( //
|
||||
&c->xcn->base, // xc
|
||||
frame_id, // frame_id
|
||||
c->sync.xcsem, // xcsem
|
||||
values[0]); // value
|
||||
|
||||
|
@ -155,7 +151,7 @@ submit_semaphore(struct client_vk_compositor *c, int64_t frame_id, xrt_result_t
|
|||
}
|
||||
|
||||
static bool
|
||||
submit_fence(struct client_vk_compositor *c, int64_t frame_id, xrt_result_t *out_xret)
|
||||
submit_fence(struct client_vk_compositor *c, xrt_result_t *out_xret)
|
||||
{
|
||||
xrt_graphics_sync_handle_t sync_handle = XRT_GRAPHICS_SYNC_HANDLE_INVALID;
|
||||
struct vk_bundle *vk = &c->vk;
|
||||
|
@ -186,12 +182,12 @@ submit_fence(struct client_vk_compositor *c, int64_t frame_id, xrt_result_t *out
|
|||
}
|
||||
}
|
||||
|
||||
*out_xret = xrt_comp_layer_commit(&c->xcn->base, frame_id, sync_handle);
|
||||
*out_xret = xrt_comp_layer_commit(&c->xcn->base, sync_handle);
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
submit_fallback(struct client_vk_compositor *c, int64_t frame_id, xrt_result_t *out_xret)
|
||||
submit_fallback(struct client_vk_compositor *c, xrt_result_t *out_xret)
|
||||
{
|
||||
struct vk_bundle *vk = &c->vk;
|
||||
|
||||
|
@ -202,7 +198,7 @@ submit_fallback(struct client_vk_compositor *c, int64_t frame_id, xrt_result_t *
|
|||
vk->vkDeviceWaitIdle(vk->device);
|
||||
}
|
||||
|
||||
*out_xret = xrt_comp_layer_commit(&c->xcn->base, frame_id, XRT_GRAPHICS_SYNC_HANDLE_INVALID);
|
||||
*out_xret = xrt_comp_layer_commit(&c->xcn->base, XRT_GRAPHICS_SYNC_HANDLE_INVALID);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -431,16 +427,13 @@ 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,
|
||||
uint64_t display_time_ns,
|
||||
enum xrt_blend_mode env_blend_mode)
|
||||
client_vk_compositor_layer_begin(struct xrt_compositor *xc, const struct xrt_layer_frame_data *data)
|
||||
{
|
||||
COMP_TRACE_MARKER();
|
||||
|
||||
struct client_vk_compositor *c = client_vk_compositor(xc);
|
||||
|
||||
return xrt_comp_layer_begin(&c->xcn->base, frame_id, display_time_ns, env_blend_mode);
|
||||
return xrt_comp_layer_begin(&c->xcn->base, data);
|
||||
}
|
||||
|
||||
static xrt_result_t
|
||||
|
@ -569,20 +562,20 @@ client_vk_compositor_layer_equirect2(struct xrt_compositor *xc,
|
|||
}
|
||||
|
||||
static xrt_result_t
|
||||
client_vk_compositor_layer_commit(struct xrt_compositor *xc, int64_t frame_id, xrt_graphics_sync_handle_t sync_handle)
|
||||
client_vk_compositor_layer_commit(struct xrt_compositor *xc, xrt_graphics_sync_handle_t sync_handle)
|
||||
{
|
||||
COMP_TRACE_MARKER();
|
||||
|
||||
struct client_vk_compositor *c = client_vk_compositor(xc);
|
||||
|
||||
xrt_result_t xret = XRT_SUCCESS;
|
||||
if (submit_handle(c, frame_id, sync_handle, &xret)) {
|
||||
if (submit_handle(c, sync_handle, &xret)) {
|
||||
return xret;
|
||||
} else if (submit_semaphore(c, frame_id, &xret)) {
|
||||
} else if (submit_semaphore(c, &xret)) {
|
||||
return xret;
|
||||
} else if (submit_fence(c, frame_id, &xret)) {
|
||||
} else if (submit_fence(c, &xret)) {
|
||||
return xret;
|
||||
} else if (submit_fallback(c, frame_id, &xret)) {
|
||||
} else if (submit_fallback(c, &xret)) {
|
||||
return xret;
|
||||
} else {
|
||||
// Really bad state.
|
||||
|
|
|
@ -370,7 +370,7 @@ can_do_one_projection_layer_fast_path(struct comp_compositor *c)
|
|||
}
|
||||
|
||||
static xrt_result_t
|
||||
compositor_layer_commit(struct xrt_compositor *xc, int64_t frame_id, xrt_graphics_sync_handle_t sync_handle)
|
||||
compositor_layer_commit(struct xrt_compositor *xc, xrt_graphics_sync_handle_t sync_handle)
|
||||
{
|
||||
COMP_TRACE_MARKER();
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ slot_clear_locked(struct multi_compositor *mc, struct multi_layer_slot *slot)
|
|||
{
|
||||
if (slot->active) {
|
||||
uint64_t now_ns = os_monotonic_get_ns();
|
||||
u_pa_retired(mc->upa, slot->frame_id, now_ns);
|
||||
u_pa_retired(mc->upa, slot->data.frame_id, now_ns);
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < slot->layer_count; i++) {
|
||||
|
@ -59,7 +59,7 @@ slot_clear_locked(struct multi_compositor *mc, struct multi_layer_slot *slot)
|
|||
}
|
||||
|
||||
U_ZERO(slot);
|
||||
slot->frame_id = -1;
|
||||
slot->data.frame_id = -1;
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -69,13 +69,13 @@ static void
|
|||
slot_move_into_cleared(struct multi_layer_slot *dst, struct multi_layer_slot *src)
|
||||
{
|
||||
assert(!dst->active);
|
||||
assert(dst->frame_id == -1);
|
||||
assert(dst->data.frame_id == -1);
|
||||
|
||||
// All references are kept.
|
||||
*dst = *src;
|
||||
|
||||
U_ZERO(src);
|
||||
src->frame_id = -1;
|
||||
src->data.frame_id = -1;
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -219,14 +219,14 @@ wait_for_scheduled_free(struct multi_compositor *mc)
|
|||
while (v_mc->scheduled.active) {
|
||||
|
||||
// This frame is for the next frame, drop the old one no matter what.
|
||||
if (time_is_within_half_ms(mc->progress.display_time_ns, mc->slot_next_frame_display)) {
|
||||
if (time_is_within_half_ms(mc->progress.data.display_time_ns, mc->slot_next_frame_display)) {
|
||||
U_LOG_W("Dropping old missed frame in favour for completed new frame");
|
||||
break;
|
||||
}
|
||||
|
||||
// Replace the scheduled frame if it's in the past.
|
||||
uint64_t now_ns = os_monotonic_get_ns();
|
||||
if (v_mc->scheduled.display_time_ns < now_ns) {
|
||||
if (v_mc->scheduled.data.display_time_ns < now_ns) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -237,12 +237,12 @@ wait_for_scheduled_free(struct multi_compositor *mc)
|
|||
"\n\tprogress: %fms (%" PRIu64
|
||||
") (latest completed frame)"
|
||||
"\n\tscheduled: %fms (%" PRIu64 ") (oldest waiting frame)",
|
||||
time_ns_to_ms_f((int64_t)v_mc->slot_next_frame_display - now_ns), //
|
||||
v_mc->slot_next_frame_display, //
|
||||
time_ns_to_ms_f((int64_t)v_mc->progress.display_time_ns - now_ns), //
|
||||
v_mc->progress.display_time_ns, //
|
||||
time_ns_to_ms_f((int64_t)v_mc->scheduled.display_time_ns - now_ns), //
|
||||
v_mc->scheduled.display_time_ns); //
|
||||
time_ns_to_ms_f((int64_t)v_mc->slot_next_frame_display - now_ns), //
|
||||
v_mc->slot_next_frame_display, //
|
||||
time_ns_to_ms_f((int64_t)v_mc->progress.data.display_time_ns - now_ns), //
|
||||
v_mc->progress.data.display_time_ns, //
|
||||
time_ns_to_ms_f((int64_t)v_mc->scheduled.data.display_time_ns - now_ns), //
|
||||
v_mc->scheduled.data.display_time_ns); //
|
||||
|
||||
os_mutex_unlock(&mc->slot_lock);
|
||||
|
||||
|
@ -647,17 +647,14 @@ multi_compositor_discard_frame(struct xrt_compositor *xc, int64_t frame_id)
|
|||
}
|
||||
|
||||
static xrt_result_t
|
||||
multi_compositor_layer_begin(struct xrt_compositor *xc,
|
||||
int64_t frame_id,
|
||||
uint64_t display_time_ns,
|
||||
enum xrt_blend_mode env_blend_mode)
|
||||
multi_compositor_layer_begin(struct xrt_compositor *xc, const struct xrt_layer_frame_data *data)
|
||||
{
|
||||
struct multi_compositor *mc = multi_compositor(xc);
|
||||
|
||||
// As early as possible.
|
||||
uint64_t now_ns = os_monotonic_get_ns();
|
||||
os_mutex_lock(&mc->msc->list_and_timing_lock);
|
||||
u_pa_mark_delivered(mc->upa, frame_id, now_ns, display_time_ns);
|
||||
u_pa_mark_delivered(mc->upa, data->frame_id, now_ns, data->display_time_ns);
|
||||
os_mutex_unlock(&mc->msc->list_and_timing_lock);
|
||||
|
||||
/*
|
||||
|
@ -676,9 +673,7 @@ multi_compositor_layer_begin(struct xrt_compositor *xc,
|
|||
U_ZERO(&mc->progress);
|
||||
|
||||
mc->progress.active = true;
|
||||
mc->progress.frame_id = frame_id;
|
||||
mc->progress.display_time_ns = display_time_ns;
|
||||
mc->progress.env_blend_mode = env_blend_mode;
|
||||
mc->progress.data = *data;
|
||||
|
||||
return XRT_SUCCESS;
|
||||
}
|
||||
|
@ -805,12 +800,13 @@ multi_compositor_layer_equirect2(struct xrt_compositor *xc,
|
|||
}
|
||||
|
||||
static xrt_result_t
|
||||
multi_compositor_layer_commit(struct xrt_compositor *xc, int64_t frame_id, xrt_graphics_sync_handle_t sync_handle)
|
||||
multi_compositor_layer_commit(struct xrt_compositor *xc, xrt_graphics_sync_handle_t sync_handle)
|
||||
{
|
||||
COMP_TRACE_MARKER();
|
||||
|
||||
struct multi_compositor *mc = multi_compositor(xc);
|
||||
struct xrt_compositor_fence *xcf = NULL;
|
||||
int64_t frame_id = mc->progress.data.frame_id;
|
||||
|
||||
do {
|
||||
if (!xrt_graphics_sync_handle_is_valid(sync_handle)) {
|
||||
|
@ -851,13 +847,13 @@ multi_compositor_layer_commit(struct xrt_compositor *xc, int64_t frame_id, xrt_g
|
|||
|
||||
static xrt_result_t
|
||||
multi_compositor_layer_commit_with_semaphore(struct xrt_compositor *xc,
|
||||
int64_t frame_id,
|
||||
struct xrt_compositor_semaphore *xcsem,
|
||||
uint64_t value)
|
||||
{
|
||||
COMP_TRACE_MARKER();
|
||||
|
||||
struct multi_compositor *mc = multi_compositor(xc);
|
||||
int64_t frame_id = mc->progress.data.frame_id;
|
||||
|
||||
push_semaphore_to_wait_thread(mc, frame_id, xcsem, value);
|
||||
|
||||
|
@ -933,7 +929,7 @@ multi_compositor_deliver_any_frames(struct multi_compositor *mc, uint64_t displa
|
|||
return;
|
||||
}
|
||||
|
||||
if (time_is_greater_then_or_within_half_ms(display_time_ns, mc->scheduled.display_time_ns)) {
|
||||
if (time_is_greater_then_or_within_half_ms(display_time_ns, mc->scheduled.data.display_time_ns)) {
|
||||
slot_move_and_clear_locked(mc, &mc->delivered, &mc->scheduled);
|
||||
}
|
||||
|
||||
|
@ -943,7 +939,7 @@ multi_compositor_deliver_any_frames(struct multi_compositor *mc, uint64_t displa
|
|||
void
|
||||
multi_compositor_latch_frame_locked(struct multi_compositor *mc, uint64_t when_ns, int64_t system_frame_id)
|
||||
{
|
||||
u_pa_latched(mc->upa, mc->delivered.frame_id, when_ns, system_frame_id);
|
||||
u_pa_latched(mc->upa, mc->delivered.data.frame_id, when_ns, system_frame_id);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -68,9 +68,7 @@ struct multi_layer_entry
|
|||
*/
|
||||
struct multi_layer_slot
|
||||
{
|
||||
int64_t frame_id;
|
||||
uint64_t display_time_ns; //!< When should this be shown, @see XrFrameEndInfo::displayTime.
|
||||
enum xrt_blend_mode env_blend_mode;
|
||||
struct xrt_layer_frame_data data;
|
||||
uint32_t layer_count;
|
||||
struct multi_layer_entry layers[MULTI_MAX_LAYERS];
|
||||
bool active;
|
||||
|
|
|
@ -283,7 +283,7 @@ transfer_layers_locked(struct multi_system_compositor *msc, uint64_t display_tim
|
|||
struct multi_compositor *mc = array[k];
|
||||
assert(mc != NULL);
|
||||
|
||||
uint64_t frame_time_ns = mc->delivered.display_time_ns;
|
||||
uint64_t frame_time_ns = mc->delivered.data.display_time_ns;
|
||||
if (!time_is_within_half_ms(frame_time_ns, display_time_ns)) {
|
||||
log_frame_time_diff(frame_time_ns, display_time_ns);
|
||||
}
|
||||
|
@ -493,16 +493,24 @@ multi_main_loop(struct multi_system_compositor *msc)
|
|||
|
||||
//! @todo Pick the blend mode from primary client.
|
||||
enum xrt_blend_mode blend_mode = XRT_BLEND_MODE_OPAQUE;
|
||||
|
||||
//! @todo Pick a good display time.
|
||||
uint64_t display_time_ns = 0;
|
||||
xrt_comp_layer_begin(xc, frame_id, display_time_ns, blend_mode);
|
||||
|
||||
// Prepare data.
|
||||
struct xrt_layer_frame_data data = {
|
||||
.frame_id = frame_id,
|
||||
.display_time_ns = display_time_ns,
|
||||
.env_blend_mode = blend_mode,
|
||||
};
|
||||
xrt_comp_layer_begin(xc, &data);
|
||||
|
||||
// Make sure that the clients doesn't go away while we transfer layers.
|
||||
os_mutex_lock(&msc->list_and_timing_lock);
|
||||
transfer_layers_locked(msc, predicted_display_time_ns, frame_id);
|
||||
os_mutex_unlock(&msc->list_and_timing_lock);
|
||||
|
||||
xrt_comp_layer_commit(xc, frame_id, XRT_GRAPHICS_SYNC_HANDLE_INVALID);
|
||||
xrt_comp_layer_commit(xc, XRT_GRAPHICS_SYNC_HANDLE_INVALID);
|
||||
|
||||
// Re-lock the thread for check in while statement.
|
||||
os_thread_helper_lock(&msc->oth);
|
||||
|
|
|
@ -406,13 +406,15 @@ null_compositor_discard_frame(struct xrt_compositor *xc, int64_t frame_id)
|
|||
}
|
||||
|
||||
static xrt_result_t
|
||||
null_compositor_layer_commit(struct xrt_compositor *xc, int64_t frame_id, xrt_graphics_sync_handle_t sync_handle)
|
||||
null_compositor_layer_commit(struct xrt_compositor *xc, xrt_graphics_sync_handle_t sync_handle)
|
||||
{
|
||||
COMP_TRACE_MARKER();
|
||||
|
||||
struct null_compositor *c = null_compositor(xc);
|
||||
NULL_TRACE(c, "LAYER_COMMIT");
|
||||
|
||||
int64_t frame_id = c->base.slot.data.frame_id;
|
||||
|
||||
/*
|
||||
* The null compositor doesn't render and frames, but needs to do
|
||||
* minimal bookkeeping and handling of arguments. If using the null
|
||||
|
|
|
@ -104,14 +104,11 @@ base_create_semaphore(struct xrt_compositor *xc,
|
|||
}
|
||||
|
||||
static xrt_result_t
|
||||
base_layer_begin(struct xrt_compositor *xc,
|
||||
int64_t frame_id,
|
||||
uint64_t display_time_ns,
|
||||
enum xrt_blend_mode env_blend_mode)
|
||||
base_layer_begin(struct xrt_compositor *xc, const struct xrt_layer_frame_data *data)
|
||||
{
|
||||
struct comp_base *cb = comp_base(xc);
|
||||
|
||||
cb->slot.env_blend_mode = env_blend_mode;
|
||||
cb->slot.data = *data;
|
||||
cb->slot.layer_count = 0;
|
||||
|
||||
return XRT_SUCCESS;
|
||||
|
|
|
@ -49,8 +49,8 @@ struct comp_layer
|
|||
*/
|
||||
struct comp_layer_slot
|
||||
{
|
||||
//! What environmental blend mode did the app use.
|
||||
enum xrt_blend_mode env_blend_mode;
|
||||
//! The per frame data.
|
||||
struct xrt_layer_frame_data data;
|
||||
|
||||
//! All of the layers.
|
||||
struct comp_layer layers[COMP_MAX_LAYERS];
|
||||
|
|
|
@ -334,6 +334,17 @@ struct xrt_layer_data
|
|||
};
|
||||
};
|
||||
|
||||
/*!
|
||||
* Per frame data for the layer submission calls, used in
|
||||
* @ref xrt_compositor::layer_begin.
|
||||
*/
|
||||
struct xrt_layer_frame_data
|
||||
{
|
||||
int64_t frame_id;
|
||||
uint64_t display_time_ns;
|
||||
enum xrt_blend_mode env_blend_mode;
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
|
@ -982,10 +993,7 @@ struct xrt_compositor
|
|||
* 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,
|
||||
uint64_t display_time_ns,
|
||||
enum xrt_blend_mode env_blend_mode);
|
||||
xrt_result_t (*layer_begin)(struct xrt_compositor *xc, const struct xrt_layer_frame_data *data);
|
||||
|
||||
/*!
|
||||
* @brief Adds a stereo projection layer for submissions.
|
||||
|
@ -1117,9 +1125,7 @@ struct xrt_compositor
|
|||
*
|
||||
* Only after this call will the compositor actually use the layers.
|
||||
*/
|
||||
xrt_result_t (*layer_commit)(struct xrt_compositor *xc,
|
||||
int64_t frame_id,
|
||||
xrt_graphics_sync_handle_t sync_handle);
|
||||
xrt_result_t (*layer_commit)(struct xrt_compositor *xc, xrt_graphics_sync_handle_t sync_handle);
|
||||
|
||||
/*!
|
||||
* @brief Commits all of the submitted layers, with a semaphore.
|
||||
|
@ -1132,7 +1138,6 @@ struct xrt_compositor
|
|||
* @param value Semaphore value upone completion of GPU work.
|
||||
*/
|
||||
xrt_result_t (*layer_commit_with_semaphore)(struct xrt_compositor *xc,
|
||||
int64_t frame_id,
|
||||
struct xrt_compositor_semaphore *xcsem,
|
||||
uint64_t value);
|
||||
|
||||
|
@ -1387,12 +1392,9 @@ 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,
|
||||
uint64_t display_time_ns,
|
||||
enum xrt_blend_mode env_blend_mode)
|
||||
xrt_comp_layer_begin(struct xrt_compositor *xc, const struct xrt_layer_frame_data *data)
|
||||
{
|
||||
return xc->layer_begin(xc, frame_id, display_time_ns, env_blend_mode);
|
||||
return xc->layer_begin(xc, data);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -1520,9 +1522,9 @@ xrt_comp_layer_equirect2(struct xrt_compositor *xc,
|
|||
* @public @memberof xrt_compositor
|
||||
*/
|
||||
static inline xrt_result_t
|
||||
xrt_comp_layer_commit(struct xrt_compositor *xc, int64_t frame_id, xrt_graphics_sync_handle_t sync_handle)
|
||||
xrt_comp_layer_commit(struct xrt_compositor *xc, xrt_graphics_sync_handle_t sync_handle)
|
||||
{
|
||||
return xc->layer_commit(xc, frame_id, sync_handle);
|
||||
return xc->layer_commit(xc, sync_handle);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -1533,12 +1535,9 @@ xrt_comp_layer_commit(struct xrt_compositor *xc, int64_t frame_id, xrt_graphics_
|
|||
* @public @memberof xrt_compositor
|
||||
*/
|
||||
static inline xrt_result_t
|
||||
xrt_comp_layer_commit_with_semaphore(struct xrt_compositor *xc,
|
||||
int64_t frame_id,
|
||||
struct xrt_compositor_semaphore *xcsem,
|
||||
uint64_t value)
|
||||
xrt_comp_layer_commit_with_semaphore(struct xrt_compositor *xc, struct xrt_compositor_semaphore *xcsem, uint64_t value)
|
||||
{
|
||||
return xc->layer_commit_with_semaphore(xc, frame_id, xcsem, value);
|
||||
return xc->layer_commit_with_semaphore(xc, xcsem, value);
|
||||
}
|
||||
|
||||
/*! @} */
|
||||
|
|
|
@ -545,18 +545,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,
|
||||
uint64_t display_time_ns,
|
||||
enum xrt_blend_mode env_blend_mode)
|
||||
ipc_compositor_layer_begin(struct xrt_compositor *xc, const struct xrt_layer_frame_data *data)
|
||||
{
|
||||
struct ipc_client_compositor *icc = ipc_client_compositor(xc);
|
||||
|
||||
struct ipc_shared_memory *ism = icc->ipc_c->ism;
|
||||
struct ipc_layer_slot *slot = &ism->slots[icc->layers.slot_id];
|
||||
|
||||
slot->display_time_ns = display_time_ns;
|
||||
slot->env_blend_mode = env_blend_mode;
|
||||
slot->data = *data;
|
||||
|
||||
return XRT_SUCCESS;
|
||||
}
|
||||
|
@ -700,7 +696,7 @@ ipc_compositor_layer_equirect2(struct xrt_compositor *xc,
|
|||
}
|
||||
|
||||
static xrt_result_t
|
||||
ipc_compositor_layer_commit(struct xrt_compositor *xc, int64_t frame_id, xrt_graphics_sync_handle_t sync_handle)
|
||||
ipc_compositor_layer_commit(struct xrt_compositor *xc, xrt_graphics_sync_handle_t sync_handle)
|
||||
{
|
||||
struct ipc_client_compositor *icc = ipc_client_compositor(xc);
|
||||
|
||||
|
@ -714,7 +710,6 @@ ipc_compositor_layer_commit(struct xrt_compositor *xc, int64_t frame_id, xrt_gra
|
|||
|
||||
IPC_CALL_CHK(ipc_call_compositor_layer_sync( //
|
||||
icc->ipc_c, //
|
||||
frame_id, //
|
||||
icc->layers.slot_id, //
|
||||
&sync_handle, //
|
||||
valid_sync ? 1 : 0, //
|
||||
|
@ -733,7 +728,6 @@ ipc_compositor_layer_commit(struct xrt_compositor *xc, int64_t frame_id, xrt_gra
|
|||
|
||||
static xrt_result_t
|
||||
ipc_compositor_layer_commit_with_semaphore(struct xrt_compositor *xc,
|
||||
int64_t frame_id,
|
||||
struct xrt_compositor_semaphore *xcsem,
|
||||
uint64_t value)
|
||||
{
|
||||
|
@ -748,7 +742,6 @@ ipc_compositor_layer_commit_with_semaphore(struct xrt_compositor *xc,
|
|||
|
||||
IPC_CALL_CHK(ipc_call_compositor_layer_sync_with_semaphore( //
|
||||
icc->ipc_c, //
|
||||
frame_id, //
|
||||
icc->layers.slot_id, //
|
||||
iccs->id, //
|
||||
value, //
|
||||
|
|
|
@ -790,7 +790,6 @@ _update_layers(volatile struct ipc_client_state *ics, struct xrt_compositor *xc,
|
|||
|
||||
xrt_result_t
|
||||
ipc_handle_compositor_layer_sync(volatile struct ipc_client_state *ics,
|
||||
int64_t frame_id,
|
||||
uint32_t slot_id,
|
||||
uint32_t *out_free_slot_id,
|
||||
const xrt_graphics_sync_handle_t *handles,
|
||||
|
@ -826,11 +825,11 @@ ipc_handle_compositor_layer_sync(volatile struct ipc_client_state *ics,
|
|||
* Transfer data to underlying compositor.
|
||||
*/
|
||||
|
||||
xrt_comp_layer_begin(ics->xc, frame_id, copy.display_time_ns, copy.env_blend_mode);
|
||||
xrt_comp_layer_begin(ics->xc, ©.data);
|
||||
|
||||
_update_layers(ics, ics->xc, ©);
|
||||
|
||||
xrt_comp_layer_commit(ics->xc, frame_id, sync_handle);
|
||||
xrt_comp_layer_commit(ics->xc, sync_handle);
|
||||
|
||||
|
||||
/*
|
||||
|
@ -849,7 +848,6 @@ ipc_handle_compositor_layer_sync(volatile struct ipc_client_state *ics,
|
|||
|
||||
xrt_result_t
|
||||
ipc_handle_compositor_layer_sync_with_semaphore(volatile struct ipc_client_state *ics,
|
||||
int64_t frame_id,
|
||||
uint32_t slot_id,
|
||||
uint32_t semaphore_id,
|
||||
uint64_t semaphore_value,
|
||||
|
@ -883,11 +881,11 @@ ipc_handle_compositor_layer_sync_with_semaphore(volatile struct ipc_client_state
|
|||
* Transfer data to underlying compositor.
|
||||
*/
|
||||
|
||||
xrt_comp_layer_begin(ics->xc, frame_id, copy.display_time_ns, copy.env_blend_mode);
|
||||
xrt_comp_layer_begin(ics->xc, ©.data);
|
||||
|
||||
_update_layers(ics, ics->xc, ©);
|
||||
|
||||
xrt_comp_layer_commit_with_semaphore(ics->xc, frame_id, xcsem, semaphore_value);
|
||||
xrt_comp_layer_commit_with_semaphore(ics->xc, xcsem, semaphore_value);
|
||||
|
||||
|
||||
/*
|
||||
|
|
|
@ -161,8 +161,7 @@ struct ipc_layer_entry
|
|||
*/
|
||||
struct ipc_layer_slot
|
||||
{
|
||||
uint64_t display_time_ns;
|
||||
enum xrt_blend_mode env_blend_mode;
|
||||
struct xrt_layer_frame_data data;
|
||||
uint32_t layer_count;
|
||||
struct ipc_layer_entry layers[IPC_MAX_LAYERS];
|
||||
};
|
||||
|
|
|
@ -164,7 +164,6 @@
|
|||
|
||||
"compositor_layer_sync": {
|
||||
"in": [
|
||||
{"name": "frame_id", "type": "int64_t"},
|
||||
{"name": "slot_id", "type": "uint32_t"}
|
||||
],
|
||||
"in_handles": {"type": "xrt_graphics_sync_handle_t"},
|
||||
|
@ -175,7 +174,6 @@
|
|||
|
||||
"compositor_layer_sync_with_semaphore": {
|
||||
"in": [
|
||||
{"name": "frame_id", "type": "int64_t"},
|
||||
{"name": "slot_id", "type": "uint32_t"},
|
||||
{"name": "semaphore_id", "type": "uint32_t"},
|
||||
{"name": "semaphore_value", "type": "uint64_t"}
|
||||
|
|
|
@ -1402,8 +1402,14 @@ 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);
|
||||
|
||||
struct xrt_layer_frame_data data = {
|
||||
.frame_id = sess->frame_id.begun,
|
||||
.display_time_ns = xrt_display_time_ns,
|
||||
.env_blend_mode = blend_mode,
|
||||
};
|
||||
|
||||
xrt_result_t xret;
|
||||
xret = xrt_comp_layer_begin(xc, sess->frame_id.begun, xrt_display_time_ns, blend_mode);
|
||||
xret = xrt_comp_layer_begin(xc, &data);
|
||||
OXR_CHECK_XRET(log, sess, xret, xrt_comp_layer_begin);
|
||||
|
||||
for (uint32_t i = 0; i < frameEndInfo->layerCount; i++) {
|
||||
|
@ -1439,7 +1445,7 @@ oxr_session_frame_end(struct oxr_logger *log, struct oxr_session *sess, const Xr
|
|||
}
|
||||
}
|
||||
|
||||
xret = xrt_comp_layer_commit(xc, sess->frame_id.begun, XRT_GRAPHICS_SYNC_HANDLE_INVALID);
|
||||
xret = xrt_comp_layer_commit(xc, XRT_GRAPHICS_SYNC_HANDLE_INVALID);
|
||||
OXR_CHECK_XRET(log, sess, xret, xrt_comp_layer_commit);
|
||||
|
||||
sess->frame_id.begun = -1;
|
||||
|
|
|
@ -417,12 +417,13 @@ sdl_compositor_discard_frame(struct xrt_compositor *xc, int64_t frame_id)
|
|||
}
|
||||
|
||||
static xrt_result_t
|
||||
sdl_compositor_layer_commit(struct xrt_compositor *xc, int64_t frame_id, xrt_graphics_sync_handle_t sync_handle)
|
||||
sdl_compositor_layer_commit(struct xrt_compositor *xc, xrt_graphics_sync_handle_t sync_handle)
|
||||
{
|
||||
COMP_TRACE_MARKER();
|
||||
|
||||
struct sdl_program *sp = from_comp(xc);
|
||||
struct sdl_compositor *c = &sp->c;
|
||||
int64_t frame_id = c->base.slot.data.frame_id;
|
||||
|
||||
SC_TRACE(c, "LAYER_COMMIT");
|
||||
|
||||
|
|
Loading…
Reference in a new issue