The way we have reached several frames in flight is to have a fence for each swapchain frame buffer that you have. Then use vkWaitForFences , but wait for the ((n+1)%num_fences) fence.
Here is a sample code https://imgtec.com/tools/powervr-early-access-program/
uint32_t current_buffer = num_swaps_ % swapchain_fences.size(); vkQueueSubmit(graphics_queue, 1, &submit_info, swapchain_fences[current_buffer]); // Wait for a queuesubmit to finish so we can continue rendering if we are n-2 frames behind if(num_swaps_ > swapchain_fences.size() - 1) { uint32_t fence_to_wait_for = (num_swaps_ + 1) % swapchain_fences.size(); vkWaitForFences(device, 1, &swapchain_fences[fence_to_wait_for], true, UINT64_MAX); vkResetFences(device, 1, &swapchain_fences[current_buffer]); }
ashleysmithgpu
source share