diff --git a/lib/graphics_engine/src/ge_vulkan_dynamic_buffer.cpp b/lib/graphics_engine/src/ge_vulkan_dynamic_buffer.cpp index 6fd69009c..9d8cb076c 100644 --- a/lib/graphics_engine/src/ge_vulkan_dynamic_buffer.cpp +++ b/lib/graphics_engine/src/ge_vulkan_dynamic_buffer.cpp @@ -139,7 +139,8 @@ void GEVulkanDynamicBuffer::destroy() // ---------------------------------------------------------------------------- bool GEVulkanDynamicBuffer::setCurrentData(const std::vector< std::pair >& data, - VkCommandBuffer custom_cmd) + VkCommandBuffer custom_cmd, + unsigned cur_frame) { GEVulkanDriver* vk = getVKDriver(); @@ -149,7 +150,12 @@ bool GEVulkanDynamicBuffer::setCurrentData(const std::vector< bool ret = resizeIfNeeded(size); m_real_size = size; - unsigned cur_frame = getVKDriver()->getCurrentFrame(); + bool forced_frame = true; + if (cur_frame == (unsigned)-1) + { + cur_frame = vk->getCurrentFrame(); + forced_frame = false; + } if (cur_frame >= m_mapped_addr.size()) cur_frame = 0; @@ -167,7 +173,9 @@ bool GEVulkanDynamicBuffer::setCurrentData(const std::vector< if (!m_local_buffer.empty()) { - unsigned cur_local_frame = getVKDriver()->getCurrentFrame(); + unsigned cur_local_frame = vk->getCurrentFrame(); + if (forced_frame) + cur_local_frame = cur_frame; if (cur_local_frame >= m_local_buffer.size()) cur_local_frame = 0; VkBufferCopy copy_region = {}; diff --git a/lib/graphics_engine/src/ge_vulkan_dynamic_buffer.hpp b/lib/graphics_engine/src/ge_vulkan_dynamic_buffer.hpp index 8d33e418d..921d2bfc0 100644 --- a/lib/graphics_engine/src/ge_vulkan_dynamic_buffer.hpp +++ b/lib/graphics_engine/src/ge_vulkan_dynamic_buffer.hpp @@ -42,11 +42,13 @@ public: ~GEVulkanDynamicBuffer(); // ------------------------------------------------------------------------ bool setCurrentData(const std::vector >& data, - VkCommandBuffer custom_cmd = VK_NULL_HANDLE); + VkCommandBuffer custom_cmd = VK_NULL_HANDLE, + unsigned cur_frame = -1); // ------------------------------------------------------------------------ bool setCurrentData(void* data, size_t size, - VkCommandBuffer custom_cmd = VK_NULL_HANDLE) - { return setCurrentData({{ data, size }}, custom_cmd); } + VkCommandBuffer custom_cmd = VK_NULL_HANDLE, + unsigned cur_frame = -1) + { return setCurrentData({{ data, size }}, custom_cmd, cur_frame); } // ------------------------------------------------------------------------ VkBuffer getCurrentBuffer() const; // ------------------------------------------------------------------------