Skip to content

Commit

Permalink
[backend] if re-acquiring swapchain, re-new semaphores
Browse files Browse the repository at this point in the history
+ it looks like we cannot simply re-use semaphores if acquisition failed
- instead we should reset semaphores which may be in signalled state;
since binary semaphores cannot be reset, we must destroy the semaphores,
and create new ones in their stead.
  • Loading branch information
tgfrerer committed Oct 1, 2024
1 parent 68167e9 commit cdac1d3
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions modules/le_backend_vk/le_backend_vk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5102,6 +5102,15 @@ static void backend_acquire_swapchain_resources( le_backend_o* self, size_t fram
.flags = 0, // optional
};

// We must re-create semaphores as they might be in signalled state.
// for binary semaphores, there is unfortunately no other way to reset
// them.
vkDestroySemaphore( device, local_swapchain_state.present_complete, nullptr );
vkDestroySemaphore( device, local_swapchain_state.render_complete, nullptr );

vkCreateSemaphore( device, &create_info, nullptr, &local_swapchain_state.present_complete );
vkCreateSemaphore( device, &create_info, nullptr, &local_swapchain_state.render_complete );

if ( swapchain_i.acquire_next_image( new_swapchain,
local_swapchain_state.present_complete,
&local_swapchain_state.image_idx ) ) {
Expand Down

0 comments on commit cdac1d3

Please sign in to comment.