Fix data race when deleting GEVulkanTexture
This commit is contained in:
parent
4ceec85edc
commit
3db036d67f
@ -49,6 +49,7 @@ GEVulkanArrayTexture::GEVulkanArrayTexture(const std::vector<io::path>& 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
|
||||
|
||||
|
@ -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<std::atomic<VkImageView> > GEVulkanTexture::getImageViewLive() c
|
||||
else
|
||||
{
|
||||
GEVulkanTexture* tex = const_cast<GEVulkanTexture*>(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;
|
||||
}
|
||||
}
|
||||
|
@ -57,6 +57,8 @@ protected:
|
||||
|
||||
GESpinLock m_image_view_lock;
|
||||
|
||||
GESpinLock m_thread_loading_lock;
|
||||
|
||||
io::path m_full_path;
|
||||
|
||||
VkFormat m_internal_format;
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user