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_size_lock.lock();
|
||||||
m_image_view_lock.lock();
|
m_image_view_lock.lock();
|
||||||
|
m_thread_loading_lock.lock();
|
||||||
GEVulkanCommandLoader::addMultiThreadingCommand(
|
GEVulkanCommandLoader::addMultiThreadingCommand(
|
||||||
[list, image_mani, this]()
|
[list, image_mani, this]()
|
||||||
{
|
{
|
||||||
@ -251,6 +252,7 @@ destroy:
|
|||||||
vmaDestroyBuffer(m_vk->getVmaAllocator(), staging_buffer,
|
vmaDestroyBuffer(m_vk->getVmaAllocator(), staging_buffer,
|
||||||
staging_buffer_allocation);
|
staging_buffer_allocation);
|
||||||
}
|
}
|
||||||
|
m_thread_loading_lock.unlock();
|
||||||
|
|
||||||
} // reloadInternal
|
} // reloadInternal
|
||||||
|
|
||||||
|
@ -67,6 +67,7 @@ GEVulkanTexture::GEVulkanTexture(const std::string& path,
|
|||||||
|
|
||||||
m_size_lock.lock();
|
m_size_lock.lock();
|
||||||
m_image_view_lock.lock();
|
m_image_view_lock.lock();
|
||||||
|
m_thread_loading_lock.lock();
|
||||||
GEVulkanCommandLoader::addMultiThreadingCommand(
|
GEVulkanCommandLoader::addMultiThreadingCommand(
|
||||||
std::bind(&GEVulkanTexture::reloadInternal, this));
|
std::bind(&GEVulkanTexture::reloadInternal, this));
|
||||||
} // GEVulkanTexture
|
} // GEVulkanTexture
|
||||||
@ -129,7 +130,8 @@ GEVulkanTexture::GEVulkanTexture(const std::string& name, unsigned int size,
|
|||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
GEVulkanTexture::~GEVulkanTexture()
|
GEVulkanTexture::~GEVulkanTexture()
|
||||||
{
|
{
|
||||||
waitImageView();
|
m_thread_loading_lock.lock();
|
||||||
|
m_thread_loading_lock.unlock();
|
||||||
|
|
||||||
if (m_image_view || m_image != VK_NULL_HANDLE ||
|
if (m_image_view || m_image != VK_NULL_HANDLE ||
|
||||||
m_vma_allocation != VK_NULL_HANDLE)
|
m_vma_allocation != VK_NULL_HANDLE)
|
||||||
@ -512,6 +514,7 @@ void GEVulkanTexture::reloadInternal()
|
|||||||
|
|
||||||
texture_image->unlock();
|
texture_image->unlock();
|
||||||
texture_image->drop();
|
texture_image->drop();
|
||||||
|
m_thread_loading_lock.unlock();
|
||||||
} // reloadInternal
|
} // reloadInternal
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@ -839,6 +842,7 @@ void GEVulkanTexture::reload()
|
|||||||
{
|
{
|
||||||
m_size_lock.lock();
|
m_size_lock.lock();
|
||||||
m_image_view_lock.lock();
|
m_image_view_lock.lock();
|
||||||
|
m_thread_loading_lock.lock();
|
||||||
GEVulkanCommandLoader::addMultiThreadingCommand(
|
GEVulkanCommandLoader::addMultiThreadingCommand(
|
||||||
std::bind(&GEVulkanTexture::reloadInternal, this));
|
std::bind(&GEVulkanTexture::reloadInternal, this));
|
||||||
}
|
}
|
||||||
@ -866,9 +870,10 @@ std::shared_ptr<std::atomic<VkImageView> > GEVulkanTexture::getImageViewLive() c
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
GEVulkanTexture* tex = const_cast<GEVulkanTexture*>(this);
|
GEVulkanTexture* tex = const_cast<GEVulkanTexture*>(this);
|
||||||
|
tex->m_thread_loading_lock.lock();
|
||||||
|
tex->m_ondemand_loading.store(true);
|
||||||
GEVulkanCommandLoader::addMultiThreadingCommand(
|
GEVulkanCommandLoader::addMultiThreadingCommand(
|
||||||
std::bind(&GEVulkanTexture::reloadInternal, tex));
|
std::bind(&GEVulkanTexture::reloadInternal, tex));
|
||||||
m_ondemand_loading.store(true);
|
|
||||||
return m_placeholder_view;
|
return m_placeholder_view;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,6 +57,8 @@ protected:
|
|||||||
|
|
||||||
GESpinLock m_image_view_lock;
|
GESpinLock m_image_view_lock;
|
||||||
|
|
||||||
|
GESpinLock m_thread_loading_lock;
|
||||||
|
|
||||||
io::path m_full_path;
|
io::path m_full_path;
|
||||||
|
|
||||||
VkFormat m_internal_format;
|
VkFormat m_internal_format;
|
||||||
|
@ -39,7 +39,7 @@ STKTexManager::~STKTexManager()
|
|||||||
GE::GEVulkanDriver* gevd = GE::getVKDriver();
|
GE::GEVulkanDriver* gevd = GE::getVKDriver();
|
||||||
if (gevd)
|
if (gevd)
|
||||||
{
|
{
|
||||||
gevd->waitIdle(/*flush_command_loader*/true);
|
gevd->waitIdle(/*flush_command_loader*/false);
|
||||||
gevd->setDisableWaitIdle(true);
|
gevd->setDisableWaitIdle(true);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user