diff --git a/Backends/Graphics5/Vulkan/Sources/kinc/backend/graphics5/Vulkan.c.h b/Backends/Graphics5/Vulkan/Sources/kinc/backend/graphics5/Vulkan.c.h index 786dc64c2..d2d2928b0 100644 --- a/Backends/Graphics5/Vulkan/Sources/kinc/backend/graphics5/Vulkan.c.h +++ b/Backends/Graphics5/Vulkan/Sources/kinc/backend/graphics5/Vulkan.c.h @@ -976,12 +976,15 @@ void kinc_g5_internal_init() { assert(!err); } - VkSemaphoreCreateInfo presentCompleteSemaphoreCreateInfo = {0}; - presentCompleteSemaphoreCreateInfo.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; - presentCompleteSemaphoreCreateInfo.pNext = NULL; - presentCompleteSemaphoreCreateInfo.flags = 0; + VkSemaphoreCreateInfo semInfo = {0}; + semInfo.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; + semInfo.pNext = NULL; + semInfo.flags = 0; - err = vkCreateSemaphore(vk_ctx.device, &presentCompleteSemaphoreCreateInfo, NULL, &framebuffer_available); + err = vkCreateSemaphore(vk_ctx.device, &semInfo, NULL, &framebuffer_available); + assert(!err); + + err = vkCreateSemaphore(vk_ctx.device, &semInfo, NULL, &relay_semaphore); assert(!err); } @@ -1101,16 +1104,14 @@ void kinc_g5_begin(kinc_g5_render_target_t *renderTarget, int window_index) { } void kinc_g5_end(int window) { -#ifdef KORE_ANDROID - vkDeviceWaitIdle(vk_ctx.device); -#endif - VkPresentInfoKHR present = {0}; present.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR; present.pNext = NULL; present.swapchainCount = 1; present.pSwapchains = &vk_ctx.windows[vk_ctx.current_window].swapchain; present.pImageIndices = &vk_ctx.windows[vk_ctx.current_window].current_image; + present.pWaitSemaphores = &relay_semaphore; + present.waitSemaphoreCount = 1; VkResult err = vk.fpQueuePresentKHR(vk_ctx.queue, &present); if (err == VK_ERROR_SURFACE_LOST_KHR) { diff --git a/Backends/Graphics5/Vulkan/Sources/kinc/backend/graphics5/commandlist.c.h b/Backends/Graphics5/Vulkan/Sources/kinc/backend/graphics5/commandlist.c.h index 013fdcaa6..864cc3379 100644 --- a/Backends/Graphics5/Vulkan/Sources/kinc/backend/graphics5/commandlist.c.h +++ b/Backends/Graphics5/Vulkan/Sources/kinc/backend/graphics5/commandlist.c.h @@ -827,14 +827,14 @@ void kinc_g5_command_list_execute(kinc_g5_command_list_t *list) { wait_for_framebuffer = false; } else { - submit_info.waitSemaphoreCount = 0; - submit_info.pWaitSemaphores = NULL; + submit_info.waitSemaphoreCount = 1; + submit_info.pWaitSemaphores = &relay_semaphore; } submit_info.pWaitDstStageMask = &pipe_stage_flags; submit_info.commandBufferCount = 1; submit_info.pCommandBuffers = &list->impl._buffer; - submit_info.signalSemaphoreCount = 0; - submit_info.pSignalSemaphores = NULL; + submit_info.signalSemaphoreCount = 1; + submit_info.pSignalSemaphores = &relay_semaphore; err = vkQueueSubmit(vk_ctx.queue, 1, &submit_info, list->impl.fence); assert(!err); diff --git a/Backends/Graphics5/Vulkan/Sources/kinc/backend/graphics5/vulkanunit.c b/Backends/Graphics5/Vulkan/Sources/kinc/backend/graphics5/vulkanunit.c index 62c04bfac..a36e449ef 100644 --- a/Backends/Graphics5/Vulkan/Sources/kinc/backend/graphics5/vulkanunit.c +++ b/Backends/Graphics5/Vulkan/Sources/kinc/backend/graphics5/vulkanunit.c @@ -69,6 +69,7 @@ #include "vulkan.h" static VkSemaphore framebuffer_available; +static VkSemaphore relay_semaphore; static void command_list_should_wait_for_framebuffer(void); #include "Vulkan.c.h"