Skip to content

Commit 195264d

Browse files
committed
Move resetFences call to prevent deadlock on out of date swapchain
1 parent ac5882b commit 195264d

18 files changed

+17
-18
lines changed

attachments/17_swap_chain_recreation.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,6 @@ class HelloTriangleApplication
507507
// while renderFinishedSemaphores is indexed by imageIndex
508508
while (vk::Result::eTimeout == device.waitForFences(*inFlightFences[frameIndex], vk::True, UINT64_MAX))
509509
;
510-
device.resetFences(*inFlightFences[frameIndex]);
511510

512511
auto [result, imageIndex] = swapChain.acquireNextImage(UINT64_MAX, *presentCompleteSemaphores[frameIndex], nullptr);
513512

attachments/18_vertex_input.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,6 @@ class HelloTriangleApplication
526526
// while renderFinishedSemaphores is indexed by imageIndex
527527
while (vk::Result::eTimeout == device.waitForFences(*inFlightFences[frameIndex], vk::True, UINT64_MAX))
528528
;
529-
device.resetFences(*inFlightFences[frameIndex]);
530529

531530
auto [result, imageIndex] = swapChain.acquireNextImage(UINT64_MAX, *presentCompleteSemaphores[frameIndex], nullptr);
532531

@@ -540,6 +539,7 @@ class HelloTriangleApplication
540539
throw std::runtime_error("failed to acquire swap chain image!");
541540
}
542541

542+
device.resetFences(*inFlightFences[frameIndex]);
543543
commandBuffers[frameIndex].reset();
544544
recordCommandBuffer(imageIndex);
545545

attachments/19_vertex_buffer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,6 @@ class HelloTriangleApplication
562562
// while renderFinishedSemaphores is indexed by imageIndex
563563
while (vk::Result::eTimeout == device.waitForFences(*inFlightFences[frameIndex], vk::True, UINT64_MAX))
564564
;
565-
device.resetFences(*inFlightFences[frameIndex]);
566565

567566
auto [result, imageIndex] = swapChain.acquireNextImage(UINT64_MAX, *presentCompleteSemaphores[frameIndex], nullptr);
568567

@@ -576,6 +575,7 @@ class HelloTriangleApplication
576575
throw std::runtime_error("failed to acquire swap chain image!");
577576
}
578577

578+
device.resetFences(*inFlightFences[frameIndex]);
579579
commandBuffers[frameIndex].reset();
580580
recordCommandBuffer(imageIndex);
581581

attachments/20_staging_buffer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,6 @@ class HelloTriangleApplication
582582
// while renderFinishedSemaphores is indexed by imageIndex
583583
while (vk::Result::eTimeout == device.waitForFences(*inFlightFences[frameIndex], vk::True, UINT64_MAX))
584584
;
585-
device.resetFences(*inFlightFences[frameIndex]);
586585

587586
auto [result, imageIndex] = swapChain.acquireNextImage(UINT64_MAX, *presentCompleteSemaphores[frameIndex], nullptr);
588587

@@ -596,6 +595,7 @@ class HelloTriangleApplication
596595
throw std::runtime_error("failed to acquire swap chain image!");
597596
}
598597

598+
device.resetFences(*inFlightFences[frameIndex]);
599599
commandBuffers[frameIndex].reset();
600600
recordCommandBuffer(imageIndex);
601601

attachments/21_index_buffer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,6 @@ class HelloTriangleApplication
608608
// while renderFinishedSemaphores is indexed by imageIndex
609609
while (vk::Result::eTimeout == device.waitForFences(*inFlightFences[frameIndex], vk::True, UINT64_MAX))
610610
;
611-
device.resetFences(*inFlightFences[frameIndex]);
612611

613612
auto [result, imageIndex] = swapChain.acquireNextImage(UINT64_MAX, *presentCompleteSemaphores[frameIndex], nullptr);
614613

@@ -622,6 +621,7 @@ class HelloTriangleApplication
622621
throw std::runtime_error("failed to acquire swap chain image!");
623622
}
624623

624+
device.resetFences(*inFlightFences[frameIndex]);
625625
commandBuffers[frameIndex].reset();
626626
recordCommandBuffer(imageIndex);
627627

attachments/22_descriptor_layout.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,6 @@ class HelloTriangleApplication
667667
// while renderFinishedSemaphores is indexed by imageIndex
668668
while (vk::Result::eTimeout == device.waitForFences(*inFlightFences[frameIndex], vk::True, UINT64_MAX))
669669
;
670-
device.resetFences(*inFlightFences[frameIndex]);
671670

672671
auto [result, imageIndex] = swapChain.acquireNextImage(UINT64_MAX, *presentCompleteSemaphores[frameIndex], nullptr);
673672

@@ -682,6 +681,7 @@ class HelloTriangleApplication
682681
}
683682
updateUniformBuffer(frameIndex);
684683

684+
device.resetFences(*inFlightFences[frameIndex]);
685685
commandBuffers[frameIndex].reset();
686686
recordCommandBuffer(imageIndex);
687687

attachments/23_descriptor_sets.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,6 @@ class HelloTriangleApplication
695695
// while renderFinishedSemaphores is indexed by imageIndex
696696
while (vk::Result::eTimeout == device.waitForFences(*inFlightFences[frameIndex], vk::True, UINT64_MAX))
697697
;
698-
device.resetFences(*inFlightFences[frameIndex]);
699698

700699
auto [result, imageIndex] = swapChain.acquireNextImage(UINT64_MAX, *presentCompleteSemaphores[frameIndex], nullptr);
701700

@@ -710,6 +709,7 @@ class HelloTriangleApplication
710709
}
711710
updateUniformBuffer(frameIndex);
712711

712+
device.resetFences(*inFlightFences[frameIndex]);
713713
commandBuffers[frameIndex].reset();
714714
recordCommandBuffer(imageIndex);
715715

attachments/24_texture_image.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -804,7 +804,6 @@ class HelloTriangleApplication
804804
// while renderFinishedSemaphores is indexed by imageIndex
805805
while (vk::Result::eTimeout == device.waitForFences(*inFlightFences[frameIndex], vk::True, UINT64_MAX))
806806
;
807-
device.resetFences(*inFlightFences[frameIndex]);
808807

809808
auto [result, imageIndex] = swapChain.acquireNextImage(UINT64_MAX, *presentCompleteSemaphores[frameIndex], nullptr);
810809

@@ -819,6 +818,7 @@ class HelloTriangleApplication
819818
}
820819
updateUniformBuffer(frameIndex);
821820

821+
device.resetFences(*inFlightFences[frameIndex]);
822822
commandBuffers[frameIndex].reset();
823823
recordCommandBuffer(imageIndex);
824824

attachments/25_sampler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -840,7 +840,6 @@ class HelloTriangleApplication
840840
// while renderFinishedSemaphores is indexed by imageIndex
841841
while (vk::Result::eTimeout == device.waitForFences(*inFlightFences[frameIndex], vk::True, UINT64_MAX))
842842
;
843-
device.resetFences(*inFlightFences[frameIndex]);
844843

845844
auto [result, imageIndex] = swapChain.acquireNextImage(UINT64_MAX, *presentCompleteSemaphores[frameIndex], nullptr);
846845

@@ -855,6 +854,7 @@ class HelloTriangleApplication
855854
}
856855
updateUniformBuffer(frameIndex);
857856

857+
device.resetFences(*inFlightFences[frameIndex]);
858858
commandBuffers[frameIndex].reset();
859859
recordCommandBuffer(imageIndex);
860860

attachments/26_texture_mapping.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -905,7 +905,6 @@ class HelloTriangleApplication
905905
// while renderFinishedSemaphores is indexed by imageIndex
906906
while (vk::Result::eTimeout == device.waitForFences(*inFlightFences[frameIndex], vk::True, UINT64_MAX))
907907
;
908-
device.resetFences(*inFlightFences[frameIndex]);
909908

910909
auto [result, imageIndex] = swapChain.acquireNextImage(UINT64_MAX, *presentCompleteSemaphores[frameIndex], nullptr);
911910

@@ -920,6 +919,7 @@ class HelloTriangleApplication
920919
}
921920
updateUniformBuffer(frameIndex);
922921

922+
device.resetFences(*inFlightFences[frameIndex]);
923923
commandBuffers[frameIndex].reset();
924924
recordCommandBuffer(imageIndex);
925925

0 commit comments

Comments
 (0)