Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use an extra semaphore to ensure swapchain image presentation waits f… #824

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Loading