VulkanSwapChain: Always allocate cmdbuffers+1 semaphores

This commit is contained in:
Stenzek
2024-05-25 13:32:57 +10:00
parent e6d8f0d4a0
commit 0f536b8680
2 changed files with 17 additions and 13 deletions

View File

@@ -9,6 +9,7 @@
#include "common/types.h"
#include <array>
#include <memory>
#include <optional>
#include <vector>
@@ -16,6 +17,11 @@
class VulkanSwapChain
{
public:
// We don't actually need +1 semaphores, or, more than one really.
// But, the validation layer gets cranky if we don't fence wait before the next image acquire.
// So, add an additional semaphore to ensure that we're never acquiring before fence waiting.
static constexpr u32 NUM_SEMAPHORES = 4; // Should be command buffers + 1
~VulkanSwapChain();
// Creates a vulkan-renderable surface for the specified window handle.
@@ -108,7 +114,7 @@ private:
VkSwapchainKHR m_swap_chain = VK_NULL_HANDLE;
std::vector<Image> m_images;
std::vector<ImageSemaphores> m_semaphores;
std::array<ImageSemaphores, NUM_SEMAPHORES> m_semaphores = {};
u32 m_current_image = 0;
u32 m_current_semaphore = 0;