diff --git a/src/xrt/state_trackers/oxr/oxr_swapchain.c b/src/xrt/state_trackers/oxr/oxr_swapchain.c index e98e69a4b..984a6592b 100644 --- a/src/xrt/state_trackers/oxr/oxr_swapchain.c +++ b/src/xrt/state_trackers/oxr/oxr_swapchain.c @@ -222,14 +222,23 @@ XrResult oxr_swapchain_common_wait(struct oxr_logger *log, struct oxr_swapchain *sc, XrDuration timeout) { uint32_t index = UINT32_MAX; - if (u_index_fifo_pop(&sc->acquired.fifo, &index) != 0) { - return oxr_error(log, XR_ERROR_RUNTIME_FAILURE, "u_index_fifo_pop: failed!"); + if (u_index_fifo_peek(&sc->acquired.fifo, &index) != 0) { + return oxr_error(log, XR_ERROR_RUNTIME_FAILURE, "u_index_fifo_peek: failed!"); } assert(index < INT32_MAX); struct xrt_swapchain *xsc = (struct xrt_swapchain *)sc->swapchain; xrt_result_t xret = xrt_swapchain_wait_image(xsc, timeout, index); + if (xret == XRT_TIMEOUT) { + oxr_warn(log, "call to xrt_swapchain_wait_image timeout"); + return XR_TIMEOUT_EXPIRED; + } + + if (u_index_fifo_pop(&sc->acquired.fifo, &index) != 0) { + return oxr_error(log, XR_ERROR_RUNTIME_FAILURE, "u_index_fifo_pop: failed!"); + } + OXR_CHECK_XRET(log, sc->sess, xret, xrt_swapchain_wait_image); // The app can only wait on one image. diff --git a/src/xrt/state_trackers/oxr/oxr_swapchain_vk.c b/src/xrt/state_trackers/oxr/oxr_swapchain_vk.c index ab276cdd1..f808291c6 100644 --- a/src/xrt/state_trackers/oxr/oxr_swapchain_vk.c +++ b/src/xrt/state_trackers/oxr/oxr_swapchain_vk.c @@ -61,9 +61,16 @@ vk_implicit_wait_image(struct oxr_logger *log, struct oxr_swapchain *sc, const X CHECK_OXR_RET(oxr_swapchain_verify_wait_state(log, sc)); uint32_t index = UINT32_MAX; - if (u_index_fifo_pop(&sc->acquired.fifo, &index) != 0) { - return oxr_error(log, XR_ERROR_RUNTIME_FAILURE, "u_index_fifo_pop: failed!"); + if (!WAIT_IN_ACQUIRE) { + if (u_index_fifo_peek(&sc->acquired.fifo, &index) != 0) { + return oxr_error(log, XR_ERROR_RUNTIME_FAILURE, "u_index_fifo_peek: failed!"); + } + } else { + if (u_index_fifo_pop(&sc->acquired.fifo, &index) != 0) { + return oxr_error(log, XR_ERROR_RUNTIME_FAILURE, "u_index_fifo_pop: failed!"); + } } + assert(index < INT32_MAX); struct xrt_swapchain *xsc = (struct xrt_swapchain *)sc->swapchain; @@ -73,6 +80,15 @@ vk_implicit_wait_image(struct oxr_logger *log, struct oxr_swapchain *sc, const X // We have already waited in acquire. xrt_result_t xret = xrt_swapchain_wait_image(xsc, timeout, index); + if (xret == XRT_TIMEOUT) { + oxr_warn(log, "call to xrt_swapchain_wait_image timeout"); + return XR_TIMEOUT_EXPIRED; + } + + if (u_index_fifo_pop(&sc->acquired.fifo, &index) != 0) { + return oxr_error(log, XR_ERROR_RUNTIME_FAILURE, "u_index_fifo_pop: failed!"); + } + OXR_CHECK_XRET(log, sc->sess, xret, xrt_swapchain_wait_image); }