From b6f2013bc55ced6239906922eda128eb7a5f28d9 Mon Sep 17 00:00:00 2001 From: Benjamin Saunders Date: Tue, 30 Apr 2019 08:33:56 -0700 Subject: [PATCH] st/oxr: Frame end uses the most recently released image --- src/xrt/compositor/client/comp_gl_client.c | 4 ++-- src/xrt/compositor/client/comp_vk_client.c | 4 ++-- src/xrt/compositor/main/comp_compositor.c | 6 +++--- src/xrt/include/xrt/xrt_compositor.h | 2 +- src/xrt/state_trackers/oxr/oxr_objects.h | 1 + src/xrt/state_trackers/oxr/oxr_session.c | 6 +++--- src/xrt/state_trackers/oxr/oxr_swapchain.c | 2 ++ 7 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/xrt/compositor/client/comp_gl_client.c b/src/xrt/compositor/client/comp_gl_client.c index edaac04f7..4f853bafe 100644 --- a/src/xrt/compositor/client/comp_gl_client.c +++ b/src/xrt/compositor/client/comp_gl_client.c @@ -127,7 +127,7 @@ static void client_gl_compositor_end_frame(struct xrt_compositor *xc, enum xrt_blend_mode blend_mode, struct xrt_swapchain **xscs, - uint32_t *acquired_index, + uint32_t *image_index, uint32_t num_swapchains) { struct client_gl_compositor *c = client_gl_compositor(xc); @@ -145,7 +145,7 @@ client_gl_compositor_end_frame(struct xrt_compositor *xc, // Pipe down call into fd compositor. c->xcfd->base.end_frame(&c->xcfd->base, blend_mode, internal, - acquired_index, num_swapchains); + image_index, num_swapchains); } static int64_t diff --git a/src/xrt/compositor/client/comp_vk_client.c b/src/xrt/compositor/client/comp_vk_client.c index ad6a583ab..886e2c0a0 100644 --- a/src/xrt/compositor/client/comp_vk_client.c +++ b/src/xrt/compositor/client/comp_vk_client.c @@ -147,7 +147,7 @@ static void client_vk_compositor_end_frame(struct xrt_compositor *xc, enum xrt_blend_mode blend_mode, struct xrt_swapchain **xscs, - uint32_t *acquired_index, + uint32_t *image_index, uint32_t num_swapchains) { struct client_vk_compositor *c = client_vk_compositor(xc); @@ -165,7 +165,7 @@ client_vk_compositor_end_frame(struct xrt_compositor *xc, // Pipe down call into fd compositor. c->xcfd->base.end_frame(&c->xcfd->base, blend_mode, internal, - acquired_index, num_swapchains); + image_index, num_swapchains); } static struct xrt_swapchain * diff --git a/src/xrt/compositor/main/comp_compositor.c b/src/xrt/compositor/main/comp_compositor.c index 46323efc5..7d3234e13 100644 --- a/src/xrt/compositor/main/comp_compositor.c +++ b/src/xrt/compositor/main/comp_compositor.c @@ -109,7 +109,7 @@ static void compositor_end_frame(struct xrt_compositor *xc, enum xrt_blend_mode blend_mode, struct xrt_swapchain **xscs, - uint32_t *acquired_index, + uint32_t *image_index, uint32_t num_swapchains) { struct comp_compositor *c = comp_compositor(xc); @@ -120,8 +120,8 @@ compositor_end_frame(struct xrt_compositor *xc, // Stereo! if (num_swapchains == 2) { - left = &comp_swapchain(xscs[0])->images[acquired_index[0]]; - right = &comp_swapchain(xscs[1])->images[acquired_index[1]]; + left = &comp_swapchain(xscs[0])->images[image_index[0]]; + right = &comp_swapchain(xscs[1])->images[image_index[1]]; comp_renderer_frame(c->r, left, right); } else { COMP_ERROR(c, "non-stereo rendering not supported"); diff --git a/src/xrt/include/xrt/xrt_compositor.h b/src/xrt/include/xrt/xrt_compositor.h index 23707fc6f..69c1daaee 100644 --- a/src/xrt/include/xrt/xrt_compositor.h +++ b/src/xrt/include/xrt/xrt_compositor.h @@ -185,7 +185,7 @@ struct xrt_compositor void (*end_frame)(struct xrt_compositor *xc, enum xrt_blend_mode blend_mode, struct xrt_swapchain **xscs, - uint32_t *acquired_index, + uint32_t *image_index, uint32_t num_swapchains); /*! diff --git a/src/xrt/state_trackers/oxr/oxr_objects.h b/src/xrt/state_trackers/oxr/oxr_objects.h index ff01dfd38..8f3979749 100644 --- a/src/xrt/state_trackers/oxr/oxr_objects.h +++ b/src/xrt/state_trackers/oxr/oxr_objects.h @@ -679,6 +679,7 @@ struct oxr_swapchain //! Actual state tracked! :D int acquired_index; + int released_index; XrResult (*destroy)(struct oxr_logger *, struct oxr_swapchain *); diff --git a/src/xrt/state_trackers/oxr/oxr_session.c b/src/xrt/state_trackers/oxr/oxr_session.c index d362a98fe..11e50bd6b 100644 --- a/src/xrt/state_trackers/oxr/oxr_session.c +++ b/src/xrt/state_trackers/oxr/oxr_session.c @@ -463,7 +463,7 @@ oxr_session_frame_end(struct oxr_logger *log, */ struct xrt_swapchain *chains[2]; - uint32_t acquired_index[2]; + uint32_t image_index[2]; uint32_t num_chains = ARRAY_SIZE(chains); for (uint32_t i = 0; i < num_chains; i++) { @@ -471,10 +471,10 @@ oxr_session_frame_end(struct oxr_logger *log, struct oxr_swapchain *sc = (struct oxr_swapchain *)proj->views[i].subImage.swapchain; chains[i] = sc->swapchain; - acquired_index[i] = proj->views[i].subImage.imageArrayIndex; + image_index[i] = sc->released_index; } - xc->end_frame(xc, blend_mode, chains, acquired_index, num_chains); + xc->end_frame(xc, blend_mode, chains, image_index, num_chains); sess->frame_started = false; diff --git a/src/xrt/state_trackers/oxr/oxr_swapchain.c b/src/xrt/state_trackers/oxr/oxr_swapchain.c index 76948eb1f..accd09718 100644 --- a/src/xrt/state_trackers/oxr/oxr_swapchain.c +++ b/src/xrt/state_trackers/oxr/oxr_swapchain.c @@ -78,6 +78,7 @@ oxr_swapchain_release_image(struct oxr_logger *log, return oxr_error(log, XR_ERROR_RUNTIME_FAILURE, " call to xsc->release_image failed"); } + sc->released_index = sc->acquired_index; sc->acquired_index = -1; return XR_SUCCESS; @@ -119,6 +120,7 @@ oxr_create_swapchain(struct oxr_logger *log, sc->wait_image = oxr_swapchain_wait_image; sc->release_image = oxr_swapchain_release_image; sc->acquired_index = -1; + sc->released_index = -1; *out_swapchain = sc;