From 46c1f83aa6ba6216fb2fe83dac7612224d19b5aa Mon Sep 17 00:00:00 2001 From: Frederico Linhares Date: Mon, 30 Dec 2024 22:31:27 -0300 Subject: fixt Create method to prevent crashes --- src/blucat/renderer.cpp | 16 ++++++++++++---- src/blucat/renderer.hpp | 3 +++ 2 files changed, 15 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/blucat/renderer.cpp b/src/blucat/renderer.cpp index 5777203..18d3976 100644 --- a/src/blucat/renderer.cpp +++ b/src/blucat/renderer.cpp @@ -101,10 +101,7 @@ unload_command_pool(void *obj) { auto self = static_cast(obj); - vkWaitForFences(BluCat::core.vk_device_with_swapchain->device, - BluCat::Swapchain::max_frames_in_flight, - BluCat::core.vk_swapchain->in_flight_fences.data(), VK_TRUE, - std::numeric_limits::max()); + self->wait_frame(); vkDestroyCommandPool( self->queue_family->device->device, self->command_pool, nullptr); } @@ -164,6 +161,17 @@ Renderer::~Renderer() loader.revert(this); } +// FIXME: this is a workaround to prevent a code to free some resource while +// it still being rendered. +void +Renderer::wait_frame() +{ + vkWaitForFences(BluCat::core.vk_device_with_swapchain->device, + BluCat::Swapchain::max_frames_in_flight, + BluCat::core.vk_swapchain->in_flight_fences.data(), VK_TRUE, + std::numeric_limits::max()); +} + void Renderer::draw() { diff --git a/src/blucat/renderer.hpp b/src/blucat/renderer.hpp index 2da6ae9..55b0727 100644 --- a/src/blucat/renderer.hpp +++ b/src/blucat/renderer.hpp @@ -63,6 +63,9 @@ struct Renderer std::initializer_list> views_3d); ~Renderer(); + void + wait_frame(); + void draw(); }; -- cgit v1.2.3