Skip to content

Commit b903ed5

Browse files
committed
Fix swapchain recreation on some vulkan.hpp versions
1 parent 5e489fc commit b903ed5

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

src/Renderer.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ void Renderer::retrieveTimestamps() {
101101

102102
void Renderer::recreateSwapchain() {
103103
auto oldExtent = swapchain->swapchainExtent;
104+
spdlog::debug("Recreating swapchain");
104105
swapchain->recreate();
105106
if (swapchain->swapchainExtent == oldExtent) {
106107
return;
@@ -408,7 +409,13 @@ void Renderer::draw() {
408409
presentInfo.pSwapchains = &swapchain->swapchain.get();
409410
presentInfo.pImageIndices = &currentImageIndex;
410411

411-
ret = context->queues[VulkanContext::Queue::PRESENT].queue.presentKHR(presentInfo);
412+
try {
413+
ret = context->queues[VulkanContext::Queue::PRESENT].queue.presentKHR(presentInfo);
414+
} catch (vk::OutOfDateKHRError& e) {
415+
recreateSwapchain();
416+
return;
417+
}
418+
412419
if (ret == vk::Result::eErrorOutOfDateKHR || ret == vk::Result::eSuboptimalKHR) {
413420
recreateSwapchain();
414421
} else if (ret != vk::Result::eSuccess) {
@@ -527,7 +534,7 @@ bool Renderer::recordRenderCommandBuffer(uint32_t currentFrame) {
527534
}
528535

529536
uint32_t numInstances = totalSumBufferHost->readOne<uint32_t>();
530-
spdlog::debug("Num instances: {}", numInstances);
537+
// spdlog::debug("Num instances: {}", numInstances);
531538
guiManager.pushTextMetric("instances", numInstances);
532539
if (numInstances > scene->getNumVertices() * sortBufferSizeMultiplier) {
533540
auto old = sortBufferSizeMultiplier;

0 commit comments

Comments
 (0)