From b6b565aabb0ec5e4483171330b2b7dc03ffc35bd Mon Sep 17 00:00:00 2001 From: Benau Date: Sun, 3 Apr 2022 10:21:48 +0800 Subject: [PATCH] Fix validation warning when reloading textures --- lib/graphics_engine/include/ge_vulkan_driver.hpp | 1 - lib/graphics_engine/src/ge_vulkan_texture.cpp | 8 ++++---- lib/graphics_engine/src/ge_vulkan_texture.hpp | 8 +++++++- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/graphics_engine/include/ge_vulkan_driver.hpp b/lib/graphics_engine/include/ge_vulkan_driver.hpp index e4cb1a11b..b1742a923 100644 --- a/lib/graphics_engine/include/ge_vulkan_driver.hpp +++ b/lib/graphics_engine/include/ge_vulkan_driver.hpp @@ -286,7 +286,6 @@ namespace GE VkMemoryPropertyFlags properties, VkBuffer& buffer, VkDeviceMemory& buffer_memory); VkPhysicalDevice getPhysicalDevice() const { return m_physical_device; } - void waitIdle() { vkQueueWaitIdle(m_graphics_queue); } const VkPhysicalDeviceFeatures& getPhysicalDeviceFeatures() const { return m_features; } const VkPhysicalDeviceProperties& getPhysicalDeviceProperties() const diff --git a/lib/graphics_engine/src/ge_vulkan_texture.cpp b/lib/graphics_engine/src/ge_vulkan_texture.cpp index a285d9410..4af7ac04a 100644 --- a/lib/graphics_engine/src/ge_vulkan_texture.cpp +++ b/lib/graphics_engine/src/ge_vulkan_texture.cpp @@ -19,7 +19,7 @@ GEVulkanTexture::GEVulkanTexture(const std::string& path, m_image_view(VK_NULL_HANDLE), m_texture_size(0), m_disable_reload(false), m_single_channel(false) { - reload(); + reloadInternal(); } // GEVulkanTexture // ---------------------------------------------------------------------------- @@ -61,7 +61,7 @@ GEVulkanTexture::GEVulkanTexture(const std::string& name, unsigned int size, // ---------------------------------------------------------------------------- GEVulkanTexture::~GEVulkanTexture() { - getVKDriver()->waitIdle(); + vkDeviceWaitIdle(m_vulkan_device); clearVulkanData(); } // ~GEVulkanTexture @@ -315,7 +315,7 @@ void GEVulkanTexture::clearVulkanData() } // clearVulkanData // ---------------------------------------------------------------------------- -void GEVulkanTexture::reload() +void GEVulkanTexture::reloadInternal() { if (m_disable_reload) return; @@ -333,7 +333,7 @@ void GEVulkanTexture::reload() upload(data); texture_image->unlock(); texture_image->drop(); -} // reload +} // reloadInternal // ---------------------------------------------------------------------------- void GEVulkanTexture::upload(uint8_t* data) diff --git a/lib/graphics_engine/src/ge_vulkan_texture.hpp b/lib/graphics_engine/src/ge_vulkan_texture.hpp index deee7a900..efa13a24e 100644 --- a/lib/graphics_engine/src/ge_vulkan_texture.hpp +++ b/lib/graphics_engine/src/ge_vulkan_texture.hpp @@ -50,6 +50,8 @@ private: // ------------------------------------------------------------------------ void clearVulkanData(); // ------------------------------------------------------------------------ + void reloadInternal(); + // ------------------------------------------------------------------------ public: // ------------------------------------------------------------------------ GEVulkanTexture(const std::string& path, @@ -95,7 +97,11 @@ public: // ------------------------------------------------------------------------ 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, u32 w, u32 h, u32 x, u32 y);