From f2a059a5c80cc391b26dbd8c052ceff62c6ac62f Mon Sep 17 00:00:00 2001 From: Georg Hagen Date: Mon, 30 Sep 2024 16:44:17 +0200 Subject: [PATCH] Update buffer pool handling to use less memory --- openVulkanoCpp/Vulkan/Renderer.cpp | 1 + openVulkanoCpp/Vulkan/Resources/ManagedBuffer.hpp | 3 +++ 2 files changed, 4 insertions(+) diff --git a/openVulkanoCpp/Vulkan/Renderer.cpp b/openVulkanoCpp/Vulkan/Renderer.cpp index a6f4a7b..30390b8 100644 --- a/openVulkanoCpp/Vulkan/Renderer.cpp +++ b/openVulkanoCpp/Vulkan/Renderer.cpp @@ -74,6 +74,7 @@ namespace OpenVulkano::Vulkan void Renderer::Tick() { + if (!scene) [[unlikely]] return; currentImageId = context.swapChain.AcquireNextImage(); scene->GetCamera()->SetSize(context.window->GetWidth(), context.window->GetHeight()); scene->GetCamera()->SetContentScaleFactor(context.window->GetContentScale()); diff --git a/openVulkanoCpp/Vulkan/Resources/ManagedBuffer.hpp b/openVulkanoCpp/Vulkan/Resources/ManagedBuffer.hpp index a7c78c7..b7d920c 100644 --- a/openVulkanoCpp/Vulkan/Resources/ManagedBuffer.hpp +++ b/openVulkanoCpp/Vulkan/Resources/ManagedBuffer.hpp @@ -48,6 +48,9 @@ namespace OpenVulkano::Vulkan [[nodiscard]] void* GetMappedMemory() const { return mapped; } + template + [[nodiscard]] T* GetMappedMemory() const { return static_cast(mapped); } + /** * \brief Maps the buffer into the memory of the host. * \tparam T The type of the buffers data.