Fix validation warning when reloading textures

This commit is contained in:
Benau 2022-04-03 10:21:48 +08:00
parent 24a9c99e03
commit b6b565aabb
3 changed files with 11 additions and 6 deletions

View File

@ -286,7 +286,6 @@ namespace GE
VkMemoryPropertyFlags properties, VkBuffer& buffer, VkMemoryPropertyFlags properties, VkBuffer& buffer,
VkDeviceMemory& buffer_memory); VkDeviceMemory& buffer_memory);
VkPhysicalDevice getPhysicalDevice() const { return m_physical_device; } VkPhysicalDevice getPhysicalDevice() const { return m_physical_device; }
void waitIdle() { vkQueueWaitIdle(m_graphics_queue); }
const VkPhysicalDeviceFeatures& getPhysicalDeviceFeatures() const const VkPhysicalDeviceFeatures& getPhysicalDeviceFeatures() const
{ return m_features; } { return m_features; }
const VkPhysicalDeviceProperties& getPhysicalDeviceProperties() const const VkPhysicalDeviceProperties& getPhysicalDeviceProperties() const

View File

@ -19,7 +19,7 @@ GEVulkanTexture::GEVulkanTexture(const std::string& path,
m_image_view(VK_NULL_HANDLE), m_texture_size(0), m_image_view(VK_NULL_HANDLE), m_texture_size(0),
m_disable_reload(false), m_single_channel(false) m_disable_reload(false), m_single_channel(false)
{ {
reload(); reloadInternal();
} // GEVulkanTexture } // GEVulkanTexture
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -61,7 +61,7 @@ GEVulkanTexture::GEVulkanTexture(const std::string& name, unsigned int size,
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
GEVulkanTexture::~GEVulkanTexture() GEVulkanTexture::~GEVulkanTexture()
{ {
getVKDriver()->waitIdle(); vkDeviceWaitIdle(m_vulkan_device);
clearVulkanData(); clearVulkanData();
} // ~GEVulkanTexture } // ~GEVulkanTexture
@ -315,7 +315,7 @@ void GEVulkanTexture::clearVulkanData()
} // clearVulkanData } // clearVulkanData
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
void GEVulkanTexture::reload() void GEVulkanTexture::reloadInternal()
{ {
if (m_disable_reload) if (m_disable_reload)
return; return;
@ -333,7 +333,7 @@ void GEVulkanTexture::reload()
upload(data); upload(data);
texture_image->unlock(); texture_image->unlock();
texture_image->drop(); texture_image->drop();
} // reload } // reloadInternal
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
void GEVulkanTexture::upload(uint8_t* data) void GEVulkanTexture::upload(uint8_t* data)

View File

@ -50,6 +50,8 @@ private:
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
void clearVulkanData(); void clearVulkanData();
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
void reloadInternal();
// ------------------------------------------------------------------------
public: public:
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
GEVulkanTexture(const std::string& path, GEVulkanTexture(const std::string& path,
@ -95,7 +97,11 @@ public:
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
virtual unsigned int getTextureSize() const { return m_texture_size; } virtual unsigned int getTextureSize() const { return m_texture_size; }
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
virtual void reload(); virtual void reload()
{
vkDeviceWaitIdle(m_vulkan_device);
reloadInternal();
}
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
virtual void updateTexture(void* data, irr::video::ECOLOR_FORMAT format, virtual void updateTexture(void* data, irr::video::ECOLOR_FORMAT format,
u32 w, u32 h, u32 x, u32 y); u32 w, u32 h, u32 x, u32 y);