Don't wait for WSI fence unless it has been signalled.

This commit is contained in:
Themaister 2017-12-08 14:38:57 +01:00
parent d05c305210
commit 714684a4d3
3 changed files with 8 additions and 3 deletions

View File

@ -2275,16 +2275,18 @@ void vulkan_acquire_next_image(gfx_ctx_vulkan_data_t *vk)
vkCreateSemaphore(vk->context.device, &sem_info,
NULL, &vk->context.swapchain_semaphores[index]);
vkWaitForFences(vk->context.device, 1, &fence, true, UINT64_MAX);
if (err == VK_SUCCESS)
vkWaitForFences(vk->context.device, 1, &fence, true, UINT64_MAX);
vkDestroyFence(vk->context.device, fence, NULL);
next_fence = &vk->context.swapchain_fences[index];
if (*next_fence != VK_NULL_HANDLE)
{
vkWaitForFences(vk->context.device, 1, next_fence, true, UINT64_MAX);
if (vk->context.swapchain_fences_signalled[index])
vkWaitForFences(vk->context.device, 1, next_fence, true, UINT64_MAX);
vkResetFences(vk->context.device, 1, next_fence);
vk->context.swapchain_fences_signalled[index] = false;
}
else
vkCreateFence(vk->context.device, &fence_info, NULL, next_fence);

View File

@ -109,6 +109,7 @@ typedef struct vulkan_context
VkImage swapchain_images[VULKAN_MAX_SWAPCHAIN_IMAGES];
VkFence swapchain_fences[VULKAN_MAX_SWAPCHAIN_IMAGES];
bool swapchain_fences_signalled[VULKAN_MAX_SWAPCHAIN_IMAGES];
VkSemaphore swapchain_semaphores[VULKAN_MAX_SWAPCHAIN_IMAGES];
VkFormat swapchain_format;

View File

@ -1569,6 +1569,7 @@ static void vulkan_inject_black_frame(vk_t *vk, video_frame_info_t *video_info)
#endif
vkQueueSubmit(vk->context->queue, 1,
&submit_info, vk->context->swapchain_fences[frame_index]);
vk->context->swapchain_fences_signalled[frame_index] = true;
#ifdef HAVE_THREADS
slock_unlock(vk->context->queue_lock);
#endif
@ -1935,6 +1936,7 @@ static bool vulkan_frame(void *data, const void *frame,
#endif
vkQueueSubmit(vk->context->queue, 1,
&submit_info, vk->context->swapchain_fences[frame_index]);
vk->context->swapchain_fences_signalled[frame_index] = true;
#ifdef HAVE_THREADS
slock_unlock(vk->context->queue_lock);
#endif