diff --git a/lib/graphics_engine/src/ge_vulkan_array_texture.cpp b/lib/graphics_engine/src/ge_vulkan_array_texture.cpp index d46b793b3..1005c1218 100644 --- a/lib/graphics_engine/src/ge_vulkan_array_texture.cpp +++ b/lib/graphics_engine/src/ge_vulkan_array_texture.cpp @@ -49,6 +49,7 @@ GEVulkanArrayTexture::GEVulkanArrayTexture(const std::vector& list, m_size_lock.lock(); m_image_view_lock.lock(); + m_thread_loading_lock.lock(); GEVulkanCommandLoader::addMultiThreadingCommand( [list, image_mani, this]() { @@ -251,6 +252,7 @@ destroy: vmaDestroyBuffer(m_vk->getVmaAllocator(), staging_buffer, staging_buffer_allocation); } + m_thread_loading_lock.unlock(); } // reloadInternal diff --git a/lib/graphics_engine/src/ge_vulkan_texture.cpp b/lib/graphics_engine/src/ge_vulkan_texture.cpp index 60761bdb3..92a696355 100644 --- a/lib/graphics_engine/src/ge_vulkan_texture.cpp +++ b/lib/graphics_engine/src/ge_vulkan_texture.cpp @@ -67,6 +67,7 @@ GEVulkanTexture::GEVulkanTexture(const std::string& path, m_size_lock.lock(); m_image_view_lock.lock(); + m_thread_loading_lock.lock(); GEVulkanCommandLoader::addMultiThreadingCommand( std::bind(&GEVulkanTexture::reloadInternal, this)); } // GEVulkanTexture @@ -129,7 +130,8 @@ GEVulkanTexture::GEVulkanTexture(const std::string& name, unsigned int size, // ---------------------------------------------------------------------------- GEVulkanTexture::~GEVulkanTexture() { - waitImageView(); + m_thread_loading_lock.lock(); + m_thread_loading_lock.unlock(); if (m_image_view || m_image != VK_NULL_HANDLE || m_vma_allocation != VK_NULL_HANDLE) @@ -512,6 +514,7 @@ void GEVulkanTexture::reloadInternal() texture_image->unlock(); texture_image->drop(); + m_thread_loading_lock.unlock(); } // reloadInternal // ---------------------------------------------------------------------------- @@ -839,6 +842,7 @@ void GEVulkanTexture::reload() { m_size_lock.lock(); m_image_view_lock.lock(); + m_thread_loading_lock.lock(); GEVulkanCommandLoader::addMultiThreadingCommand( std::bind(&GEVulkanTexture::reloadInternal, this)); } @@ -866,9 +870,10 @@ std::shared_ptr > GEVulkanTexture::getImageViewLive() c else { GEVulkanTexture* tex = const_cast(this); + tex->m_thread_loading_lock.lock(); + tex->m_ondemand_loading.store(true); GEVulkanCommandLoader::addMultiThreadingCommand( std::bind(&GEVulkanTexture::reloadInternal, tex)); - m_ondemand_loading.store(true); return m_placeholder_view; } } diff --git a/lib/graphics_engine/src/ge_vulkan_texture.hpp b/lib/graphics_engine/src/ge_vulkan_texture.hpp index 790d923c5..8a86fc75d 100644 --- a/lib/graphics_engine/src/ge_vulkan_texture.hpp +++ b/lib/graphics_engine/src/ge_vulkan_texture.hpp @@ -57,6 +57,8 @@ protected: GESpinLock m_image_view_lock; + GESpinLock m_thread_loading_lock; + io::path m_full_path; VkFormat m_internal_format; diff --git a/src/graphics/stk_tex_manager.cpp b/src/graphics/stk_tex_manager.cpp index 5467df63f..5d0c385dd 100644 --- a/src/graphics/stk_tex_manager.cpp +++ b/src/graphics/stk_tex_manager.cpp @@ -39,7 +39,7 @@ STKTexManager::~STKTexManager() GE::GEVulkanDriver* gevd = GE::getVKDriver(); if (gevd) { - gevd->waitIdle(/*flush_command_loader*/true); + gevd->waitIdle(/*flush_command_loader*/false); gevd->setDisableWaitIdle(true); } #endif