From efea99b87c312a225b57f7d9fe8b47898933e10d Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 4 Sep 2023 14:47:55 +0200 Subject: [PATCH] Only recreate lightmap texture if its size changes --- src/common/rendering/vulkan/textures/vk_texture.cpp | 8 +++++++- src/common/rendering/vulkan/textures/vk_texture.h | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/common/rendering/vulkan/textures/vk_texture.cpp b/src/common/rendering/vulkan/textures/vk_texture.cpp index 13b5cb37b8..b37f53197a 100644 --- a/src/common/rendering/vulkan/textures/vk_texture.cpp +++ b/src/common/rendering/vulkan/textures/vk_texture.cpp @@ -189,8 +189,14 @@ void VkTextureManager::CreateLightmap() SetLightmap(1, 1, data); } -void VkTextureManager::CreateLightmap(int LMTextureSize, int LMTextureCount) +void VkTextureManager::CreateLightmap(int newLMTextureSize, int newLMTextureCount) { + if (LMTextureSize == newLMTextureSize && LMTextureCount == newLMTextureCount) + return; + + LMTextureSize = newLMTextureSize; + LMTextureCount = newLMTextureCount; + int w = LMTextureSize; int h = LMTextureSize; int count = LMTextureCount; diff --git a/src/common/rendering/vulkan/textures/vk_texture.h b/src/common/rendering/vulkan/textures/vk_texture.h index a2aa04bd87..da609b5b1d 100644 --- a/src/common/rendering/vulkan/textures/vk_texture.h +++ b/src/common/rendering/vulkan/textures/vk_texture.h @@ -40,6 +40,8 @@ public: VkTextureImage Shadowmap; VkTextureImage Lightmap; + int LMTextureSize = 0; + int LMTextureCount = 0; private: void CreateNullTexture();