diff options
author | Frederico Linhares <fred@linhares.blue> | 2024-12-30 22:31:27 -0300 |
---|---|---|
committer | Frederico Linhares <fred@linhares.blue> | 2024-12-30 22:31:27 -0300 |
commit | 46c1f83aa6ba6216fb2fe83dac7612224d19b5aa (patch) | |
tree | 05cb2ec581a2e7810725a9c93e77a4703416dbfd | |
parent | 7f9cef62d446f0d82d8801185a38035cc2e5bc08 (diff) |
fixt Create method to prevent crashes
-rw-r--r-- | src/blucat/renderer.cpp | 16 | ||||
-rw-r--r-- | src/blucat/renderer.hpp | 3 |
2 files changed, 15 insertions, 4 deletions
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<BluCat::Renderer*>(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<uint64_t>::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<uint64_t>::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<std::shared_ptr<View3D>> views_3d); ~Renderer(); + void + wait_frame(); + void draw(); }; |