Skip to content

Commit 5be959d

Browse files
committed
Move resetFences call to prevent deadlock on out of date swapchain
1 parent 682e879 commit 5be959d

18 files changed

+18
-18
lines changed

attachments/17_swap_chain_recreation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,6 @@ class HelloTriangleApplication
510510
{
511511
throw std::runtime_error("failed to wait for fence!");
512512
}
513-
device.resetFences(*inFlightFences[frameIndex]);
514513

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

@@ -524,6 +523,7 @@ class HelloTriangleApplication
524523
throw std::runtime_error("failed to acquire swap chain image!");
525524
}
526525

526+
device.resetFences(*inFlightFences[frameIndex]);
527527
commandBuffers[frameIndex].reset();
528528
recordCommandBuffer(imageIndex);
529529

attachments/18_vertex_input.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,6 @@ class HelloTriangleApplication
529529
{
530530
throw std::runtime_error("failed to wait for fence!");
531531
}
532-
device.resetFences(*inFlightFences[frameIndex]);
533532

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

@@ -543,6 +542,7 @@ class HelloTriangleApplication
543542
throw std::runtime_error("failed to acquire swap chain image!");
544543
}
545544

545+
device.resetFences(*inFlightFences[frameIndex]);
546546
commandBuffers[frameIndex].reset();
547547
recordCommandBuffer(imageIndex);
548548

attachments/19_vertex_buffer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,6 @@ class HelloTriangleApplication
565565
{
566566
throw std::runtime_error("failed to wait for fence!");
567567
}
568-
device.resetFences(*inFlightFences[frameIndex]);
569568

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

@@ -579,6 +578,7 @@ class HelloTriangleApplication
579578
throw std::runtime_error("failed to acquire swap chain image!");
580579
}
581580

581+
device.resetFences(*inFlightFences[frameIndex]);
582582
commandBuffers[frameIndex].reset();
583583
recordCommandBuffer(imageIndex);
584584

attachments/20_staging_buffer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,6 @@ class HelloTriangleApplication
585585
{
586586
throw std::runtime_error("failed to wait for fence!");
587587
}
588-
device.resetFences(*inFlightFences[frameIndex]);
589588

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

@@ -599,6 +598,7 @@ class HelloTriangleApplication
599598
throw std::runtime_error("failed to acquire swap chain image!");
600599
}
601600

601+
device.resetFences(*inFlightFences[frameIndex]);
602602
commandBuffers[frameIndex].reset();
603603
recordCommandBuffer(imageIndex);
604604

attachments/21_index_buffer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,6 @@ class HelloTriangleApplication
611611
{
612612
throw std::runtime_error("failed to wait for fence!");
613613
}
614-
device.resetFences(*inFlightFences[frameIndex]);
615614

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

@@ -625,6 +624,7 @@ class HelloTriangleApplication
625624
throw std::runtime_error("failed to acquire swap chain image!");
626625
}
627626

627+
device.resetFences(*inFlightFences[frameIndex]);
628628
commandBuffers[frameIndex].reset();
629629
recordCommandBuffer(imageIndex);
630630

attachments/22_descriptor_layout.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,6 @@ class HelloTriangleApplication
670670
{
671671
throw std::runtime_error("failed to wait for fence!");
672672
}
673-
device.resetFences(*inFlightFences[frameIndex]);
674673

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

@@ -685,6 +684,7 @@ class HelloTriangleApplication
685684
}
686685
updateUniformBuffer(frameIndex);
687686

687+
device.resetFences(*inFlightFences[frameIndex]);
688688
commandBuffers[frameIndex].reset();
689689
recordCommandBuffer(imageIndex);
690690

attachments/23_descriptor_sets.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,6 @@ class HelloTriangleApplication
698698
{
699699
throw std::runtime_error("failed to wait for fence!");
700700
}
701-
device.resetFences(*inFlightFences[frameIndex]);
702701

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

@@ -713,6 +712,7 @@ class HelloTriangleApplication
713712
}
714713
updateUniformBuffer(frameIndex);
715714

715+
device.resetFences(*inFlightFences[frameIndex]);
716716
commandBuffers[frameIndex].reset();
717717
recordCommandBuffer(imageIndex);
718718

attachments/24_texture_image.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -807,7 +807,6 @@ class HelloTriangleApplication
807807
{
808808
throw std::runtime_error("failed to wait for fence!");
809809
}
810-
device.resetFences(*inFlightFences[frameIndex]);
811810

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

@@ -822,6 +821,7 @@ class HelloTriangleApplication
822821
}
823822
updateUniformBuffer(frameIndex);
824823

824+
device.resetFences(*inFlightFences[frameIndex]);
825825
commandBuffers[frameIndex].reset();
826826
recordCommandBuffer(imageIndex);
827827

attachments/25_sampler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -843,7 +843,6 @@ class HelloTriangleApplication
843843
{
844844
throw std::runtime_error("failed to wait for fence!");
845845
}
846-
device.resetFences(*inFlightFences[frameIndex]);
847846

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

@@ -858,6 +857,7 @@ class HelloTriangleApplication
858857
}
859858
updateUniformBuffer(frameIndex);
860859

860+
device.resetFences(*inFlightFences[frameIndex]);
861861
commandBuffers[frameIndex].reset();
862862
recordCommandBuffer(imageIndex);
863863

attachments/26_texture_mapping.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -908,7 +908,6 @@ class HelloTriangleApplication
908908
{
909909
throw std::runtime_error("failed to wait for fence!");
910910
}
911-
device.resetFences(*inFlightFences[frameIndex]);
912911

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

@@ -923,6 +922,7 @@ class HelloTriangleApplication
923922
}
924923
updateUniformBuffer(frameIndex);
925924

925+
device.resetFences(*inFlightFences[frameIndex]);
926926
commandBuffers[frameIndex].reset();
927927
recordCommandBuffer(imageIndex);
928928

0 commit comments

Comments
 (0)