Fixing incorrect swapchain release timing
Applied a couple of checks suggested by @dhoverml for when the
XrResult is not XR_SUCCESS but is also not a failure. Also simplified
checks from @BastiaanOlij feedback.
(cherry picked from commit 771ec958af
)
This commit is contained in:
parent
11f9e35c06
commit
de6e7c070c
|
@ -1670,14 +1670,27 @@ bool OpenXRAPI::acquire_image(OpenXRSwapChainInfo &p_swapchain) {
|
||||||
ERR_FAIL_COND_V(p_swapchain.image_acquired, true); // This was not released when it should be, error out and reuse...
|
ERR_FAIL_COND_V(p_swapchain.image_acquired, true); // This was not released when it should be, error out and reuse...
|
||||||
|
|
||||||
XrResult result;
|
XrResult result;
|
||||||
XrSwapchainImageAcquireInfo swapchain_image_acquire_info = {
|
|
||||||
XR_TYPE_SWAPCHAIN_IMAGE_ACQUIRE_INFO, // type
|
if (!p_swapchain.skip_acquire_swapchain) {
|
||||||
nullptr // next
|
XrSwapchainImageAcquireInfo swapchain_image_acquire_info = {
|
||||||
};
|
XR_TYPE_SWAPCHAIN_IMAGE_ACQUIRE_INFO, // type
|
||||||
result = xrAcquireSwapchainImage(p_swapchain.swapchain, &swapchain_image_acquire_info, &p_swapchain.image_index);
|
nullptr // next
|
||||||
if (XR_FAILED(result)) {
|
};
|
||||||
print_line("OpenXR: failed to acquire swapchain image [", get_error_string(result), "]");
|
|
||||||
return false;
|
result = xrAcquireSwapchainImage(p_swapchain.swapchain, &swapchain_image_acquire_info, &p_swapchain.image_index);
|
||||||
|
if (!XR_UNQUALIFIED_SUCCESS(result)) {
|
||||||
|
// Make sure end_frame knows we need to submit an empty frame
|
||||||
|
frame_state.shouldRender = false;
|
||||||
|
|
||||||
|
if (XR_FAILED(result)) {
|
||||||
|
// Unexpected failure, log this!
|
||||||
|
print_line("OpenXR: failed to acquire swapchain image [", get_error_string(result), "]");
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
// In this scenario we silently fail, the XR runtime is simply not ready yet to acquire the swapchain.
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
XrSwapchainImageWaitInfo swapchain_image_wait_info = {
|
XrSwapchainImageWaitInfo swapchain_image_wait_info = {
|
||||||
|
@ -1687,9 +1700,21 @@ bool OpenXRAPI::acquire_image(OpenXRSwapChainInfo &p_swapchain) {
|
||||||
};
|
};
|
||||||
|
|
||||||
result = xrWaitSwapchainImage(p_swapchain.swapchain, &swapchain_image_wait_info);
|
result = xrWaitSwapchainImage(p_swapchain.swapchain, &swapchain_image_wait_info);
|
||||||
if (XR_FAILED(result)) {
|
if (!XR_UNQUALIFIED_SUCCESS(result)) {
|
||||||
print_line("OpenXR: failed to wait for swapchain image [", get_error_string(result), "]");
|
// Make sure end_frame knows we need to submit an empty frame
|
||||||
return false;
|
frame_state.shouldRender = false;
|
||||||
|
|
||||||
|
if (XR_FAILED(result)) {
|
||||||
|
// Unexpected failure, log this!
|
||||||
|
print_line("OpenXR: failed to wait for swapchain image [", get_error_string(result), "]");
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
// Make sure to skip trying to acquire the swapchain image in the next frame
|
||||||
|
p_swapchain.skip_acquire_swapchain = true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
p_swapchain.skip_acquire_swapchain = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -140,6 +140,7 @@ private:
|
||||||
void *swapchain_graphics_data = nullptr;
|
void *swapchain_graphics_data = nullptr;
|
||||||
uint32_t image_index = 0;
|
uint32_t image_index = 0;
|
||||||
bool image_acquired = false;
|
bool image_acquired = false;
|
||||||
|
bool skip_acquire_swapchain = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
OpenXRSwapChainInfo swapchains[OPENXR_SWAPCHAIN_MAX];
|
OpenXRSwapChainInfo swapchains[OPENXR_SWAPCHAIN_MAX];
|
||||||
|
|
Loading…
Reference in New Issue