Skip to content

Commit

Permalink
Merge pull request #825 from Apprentice-Alchemist/bugfix/vk-relay-sem…
Browse files Browse the repository at this point in the history
…aphore

[vulkan] fix relay semaphore handling
  • Loading branch information
RobDangerous authored Nov 11, 2023
2 parents 791fcf0 + 601df79 commit 810a69b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1112,6 +1112,7 @@ void kinc_g5_end(int window) {
present.pImageIndices = &vk_ctx.windows[vk_ctx.current_window].current_image;
present.pWaitSemaphores = &relay_semaphore;
present.waitSemaphoreCount = 1;
wait_for_relay = false;

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 @@ -821,20 +821,32 @@ void kinc_g5_command_list_execute(kinc_g5_command_list_t *list) {
VkSubmitInfo submit_info = {0};
submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
submit_info.pNext = NULL;

VkSemaphore semaphores[2] = {
framebuffer_available,
relay_semaphore
};
VkPipelineStageFlags dst_stage_flags[2] = {
VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT
};
if (wait_for_framebuffer) {
submit_info.waitSemaphoreCount = 1;
submit_info.pWaitSemaphores = &framebuffer_available;
submit_info.pWaitSemaphores = semaphores;
submit_info.pWaitDstStageMask = dst_stage_flags;
submit_info.waitSemaphoreCount = wait_for_relay ? 2 : 1;
wait_for_framebuffer = false;
}
else {
else if(wait_for_relay) {
submit_info.waitSemaphoreCount = 1;
submit_info.pWaitSemaphores = &relay_semaphore;
submit_info.pWaitSemaphores = &semaphores[1];
submit_info.pWaitDstStageMask = &dst_stage_flags[1];
}
submit_info.pWaitDstStageMask = &pipe_stage_flags;

submit_info.commandBufferCount = 1;
submit_info.pCommandBuffers = &list->impl._buffer;
submit_info.signalSemaphoreCount = 1;
submit_info.pSignalSemaphores = &relay_semaphore;
wait_for_relay = true;

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 @@ -70,6 +70,7 @@

static VkSemaphore framebuffer_available;
static VkSemaphore relay_semaphore;
static bool wait_for_relay = false;
static void command_list_should_wait_for_framebuffer(void);

#include "Vulkan.c.h"
Expand Down

0 comments on commit 810a69b

Please sign in to comment.