@@ -158,7 +158,6 @@ class HelloTriangleApplication {
158158 std::vector<vk::raii::Fence> inFlightFences;
159159 vk::raii::Semaphore timelineSemaphore = nullptr ;
160160 uint64_t timelineValue = 0 ;
161- uint32_t semaphoreIndex = 0 ;
162161 uint32_t currentFrame = 0 ;
163162
164163 bool framebufferResized = false ;
@@ -313,7 +312,7 @@ class HelloTriangleApplication {
313312 debugMessenger = instance.createDebugUtilsMessengerEXT (debugUtilsMessengerCreateInfoEXT);
314313 } catch (vk::SystemError& err) {
315314 // If the debug utils extension is not available, this will fail
316- // That's okay, it just means validation layers aren't enabled
315+ // That's okay; it just means validation layers aren't enabled
317316 std::cout << " Debug messenger not available. Validation layers may not be enabled." << std::endl;
318317 }
319318 }
@@ -1300,9 +1299,6 @@ class HelloTriangleApplication {
13001299 std::array<vk::ClearValue, 2 > clearValues = { clearColor, clearDepth };
13011300
13021301 if (appInfo.dynamicRenderingSupported ) {
1303- // Use dynamic rendering
1304- std::cout << " Recording command buffer with dynamic rendering\n " ;
1305-
13061302 // Transition attachments to the correct layout
13071303 if (appInfo.synchronization2Supported ) {
13081304 // Use Synchronization2 API for image transitions
@@ -1551,7 +1547,7 @@ class HelloTriangleApplication {
15511547 void drawFrame () {
15521548 while (vk::Result::eTimeout == device.waitForFences (*inFlightFences[currentFrame], vk::True, FenceTimeout))
15531549 ;
1554- auto [result, imageIndex] = swapChain.acquireNextImage (UINT64_MAX, *presentCompleteSemaphore[semaphoreIndex ], nullptr );
1550+ auto [result, imageIndex] = swapChain.acquireNextImage (UINT64_MAX, *presentCompleteSemaphore[currentFrame ], nullptr );
15551551
15561552 if (result == vk::Result::eErrorOutOfDateKHR) {
15571553 recreateSwapChain ();
@@ -1577,11 +1573,11 @@ class HelloTriangleApplication {
15771573 .pSignalSemaphoreValues = &signalValue
15781574 };
15791575
1580- std::array<vk::Semaphore, 2 > waitSemaphores = { *presentCompleteSemaphore[semaphoreIndex ], *timelineSemaphore };
1576+ std::array<vk::Semaphore, 2 > waitSemaphores = { *presentCompleteSemaphore[currentFrame ], *timelineSemaphore };
15811577 std::array<vk::PipelineStageFlags, 2 > waitStages = { vk::PipelineStageFlagBits::eColorAttachmentOutput, vk::PipelineStageFlagBits::eVertexInput };
15821578 std::array<uint64_t , 2 > waitValues = { 0 , waitValue }; // Binary semaphore value is ignored
15831579
1584- std::array<vk::Semaphore, 2 > signalSemaphores = { *renderFinishedSemaphore[imageIndex ], *timelineSemaphore };
1580+ std::array<vk::Semaphore, 2 > signalSemaphores = { *renderFinishedSemaphore[currentFrame ], *timelineSemaphore };
15851581 std::array<uint64_t , 2 > signalValues = { 0 , signalValue }; // Binary semaphore value is ignored
15861582
15871583 timelineInfo.waitSemaphoreValueCount = 1 ; // Only for the timeline semaphore
@@ -1606,19 +1602,19 @@ class HelloTriangleApplication {
16061602 vk::PipelineStageFlags waitDestinationStageMask (vk::PipelineStageFlagBits::eColorAttachmentOutput);
16071603 const vk::SubmitInfo submitInfo{
16081604 .waitSemaphoreCount = 1 ,
1609- .pWaitSemaphores = &*presentCompleteSemaphore[semaphoreIndex ],
1605+ .pWaitSemaphores = &*presentCompleteSemaphore[currentFrame ],
16101606 .pWaitDstStageMask = &waitDestinationStageMask,
16111607 .commandBufferCount = 1 ,
16121608 .pCommandBuffers = &*commandBuffers[currentFrame],
16131609 .signalSemaphoreCount = 1 ,
1614- .pSignalSemaphores = &*renderFinishedSemaphore[imageIndex ]
1610+ .pSignalSemaphores = &*renderFinishedSemaphore[currentFrame ]
16151611 };
16161612 graphicsQueue.submit (submitInfo, *inFlightFences[currentFrame]);
16171613 }
16181614
16191615 const vk::PresentInfoKHR presentInfoKHR{
16201616 .waitSemaphoreCount = 1 ,
1621- .pWaitSemaphores = &*renderFinishedSemaphore[imageIndex ],
1617+ .pWaitSemaphores = &*renderFinishedSemaphore[currentFrame ],
16221618 .swapchainCount = 1 ,
16231619 .pSwapchains = &*swapChain,
16241620 .pImageIndices = &imageIndex
@@ -1630,7 +1626,6 @@ class HelloTriangleApplication {
16301626 } else if (result != vk::Result::eSuccess) {
16311627 throw std::runtime_error (" failed to present swap chain image!" );
16321628 }
1633- semaphoreIndex = (semaphoreIndex + 1 ) % presentCompleteSemaphore.size ();
16341629 currentFrame = (currentFrame + 1 ) % MAX_FRAMES_IN_FLIGHT;
16351630 }
16361631
0 commit comments