Skip to content

Commit e7473b1

Browse files
committed
Correctly fence acquire semaphore
1 parent f85825e commit e7473b1

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

src/main.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,13 @@ void renderApplication() {
8989
if (greenChannel > 1.0f) greenChannel = 0.0f;
9090
uint32_t imageIndex = 0;
9191
static uint32_t frameIndex = 0;
92-
VK(vkAcquireNextImageKHR(context->device, swapchain.swapchain, UINT64_MAX, acquireSemaphores[frameIndex], 0, &imageIndex));
9392

93+
// Wait for the n-2 frame to finish to be able to reuse its acquireSemaphore in vkAcquireNextImageKHR
9494
VKA(vkWaitForFences(context->device, 1, &fences[frameIndex], VK_TRUE, UINT64_MAX));
9595
VKA(vkResetFences(context->device, 1, &fences[frameIndex]));
96+
97+
VK(vkAcquireNextImageKHR(context->device, swapchain.swapchain, UINT64_MAX, acquireSemaphores[frameIndex], 0, &imageIndex));
98+
9699
VKA(vkResetCommandPool(context->device, commandPools[frameIndex], 0));
97100

98101
VkCommandBufferBeginInfo beginInfo = { VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO };

0 commit comments

Comments
 (0)