renderer_vulkan: Fix present mailbox shutdown sequence

This commit is contained in:
GPUCode
2023-02-05 21:56:12 +02:00
parent 582c438441
commit 09350f71e8
3 changed files with 5 additions and 5 deletions

View File

@@ -142,7 +142,7 @@ RendererVulkan::~RendererVulkan() {
vmaDestroyImage(instance.GetAllocator(), info.texture.image, info.texture.allocation);
}
render_window.mailbox.reset();
mailbox.reset();
}
void RendererVulkan::Sync() {

View File

@@ -49,9 +49,6 @@ PresentMailbox::PresentMailbox(const Instance& instance_, Swapchain& swapchain_,
}
PresentMailbox::~PresentMailbox() {
free_queue.Clear();
present_queue.Clear();
const vk::Device device = instance.GetDevice();
device.destroyCommandPool(command_pool);
for (auto& frame : swap_chain) {
@@ -180,6 +177,9 @@ void PresentMailbox::PresentThread(std::stop_token token) {
Common::SetCurrentThreadName("VulkanPresent");
do {
Frame* frame = present_queue.PopWait(token);
if (token.stop_requested()) {
continue;
}
CopyToSwapchain(frame);
free_queue.Push(frame);
} while (!token.stop_requested());

View File

@@ -55,10 +55,10 @@ private:
RenderpassCache& renderpass_cache;
vk::CommandPool command_pool;
vk::Queue graphics_queue;
std::jthread present_thread;
std::array<Frame, SWAP_CHAIN_SIZE> swap_chain{};
Common::SPSCQueue<Frame*> free_queue{};
Common::SPSCQueue<Frame*, true> present_queue{};
std::jthread present_thread;
std::mutex swapchain_mutex;
std::condition_variable swapchain_cv;
};