mirror of
https://github.com/mikage-emu/mikage-dev.git
synced 2025-03-26 03:00:44 +01:00
Properly handle VK_SUBOPTIMAL_KHR
This commit is contained in:
parent
dd160374ea
commit
d76b0dd8ff
1 changed files with 12 additions and 2 deletions
|
@ -338,9 +338,15 @@ public:
|
|||
device->waitForFences({*current_frame->render_finished_fence}, true, std::numeric_limits<uint64_t>::max());
|
||||
|
||||
auto [result, next_image_index] = device->acquireNextImageKHR(*swapchain, std::numeric_limits<uint64_t>::max(), *current_frame->image_available_semaphore, vk::Fence { });
|
||||
if (result != vk::Result::eSuccess) {
|
||||
if (result != vk::Result::eSuccess && result != vk::Result::eSuboptimalKHR) {
|
||||
throw std::runtime_error(fmt::format("Unexpected error in vkAcquireNextImageKHR: {}", vk::to_string(result)));
|
||||
}
|
||||
if (result == vk::Result::eSuboptimalKHR) {
|
||||
device->waitIdle();
|
||||
CreateSwapchain();
|
||||
BeginFrame();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!current_frame->render_finished_fence_awaitable.IsReady(*device)) { // Reset CPUAwaitable
|
||||
throw std::runtime_error("Couldn't wait on previous UI frame");
|
||||
|
@ -462,7 +468,11 @@ public:
|
|||
|
||||
vk::PresentInfoKHR info { 1, &*current_frame->render_finished_semaphore, 1, &*swapchain, ¤t_frame->image_index };
|
||||
auto result = present_queue.presentKHR(info);
|
||||
if (result != vk::Result::eSuccess) {
|
||||
if (result == vk::Result::eSuboptimalKHR) {
|
||||
// TODO: Other drivers might actually return other error codes on resize
|
||||
device->waitIdle();
|
||||
CreateSwapchain();
|
||||
} else if (result != vk::Result::eSuccess) {
|
||||
// TODO: On VK_ERROR_OUT_OF_DATE_KHR, we should recreate the swap chain!
|
||||
logger->error("Error in vkQueuePresentKHR: {}", vk::to_string(result));
|
||||
throw std::runtime_error("Error in vkQueuePresentKHR");
|
||||
|
|
Loading…
Add table
Reference in a new issue