From 38b995bf612f8b4a9f15203e54cf4a671438addb Mon Sep 17 00:00:00 2001 From: Benau Date: Wed, 31 Aug 2022 11:08:48 +0800 Subject: [PATCH] Avoid hangs if reloading textures too much --- lib/graphics_engine/src/ge_vulkan_texture.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/graphics_engine/src/ge_vulkan_texture.cpp b/lib/graphics_engine/src/ge_vulkan_texture.cpp index d7dddfdad..163b279be 100644 --- a/lib/graphics_engine/src/ge_vulkan_texture.cpp +++ b/lib/graphics_engine/src/ge_vulkan_texture.cpp @@ -806,8 +806,18 @@ void GEVulkanTexture::bgraConversion(uint8_t* img_data) //----------------------------------------------------------------------------- void GEVulkanTexture::reload() { - if (!waitImageView()) - return; + // Copied from waitImageView + if (!m_ondemand_load) + { + m_image_view_lock.lock(); + m_image_view_lock.unlock(); + } + else + { + bool is_currently_loading = m_ondemand_loading.load(); + if (is_currently_loading || m_image == VK_NULL_HANDLE) + return; + } if (m_image_view || m_image != VK_NULL_HANDLE || m_vma_allocation != VK_NULL_HANDLE)