diff --git a/src/common/rendering/vulkan/accelstructs/vk_lightmap.cpp b/src/common/rendering/vulkan/accelstructs/vk_lightmap.cpp index c0fd0e050..ec6075245 100644 --- a/src/common/rendering/vulkan/accelstructs/vk_lightmap.cpp +++ b/src/common/rendering/vulkan/accelstructs/vk_lightmap.cpp @@ -45,18 +45,17 @@ VkLightmap::~VkLightmap() lights.Buffer->Unmap(); } -void VkLightmap::Raytrace(LevelMesh* level, const TArray& surfaces) +void VkLightmap::SetLevelMesh(LevelMesh* level) { - bool newLevel = (mesh != level); mesh = level; - if (newLevel) - { - UpdateAccelStructDescriptors(); + UpdateAccelStructDescriptors(); - lightmapRaytrace.Reset(); - lightmapRaytraceLast.Reset(); - } + lightmapRaytrace.Reset(); + lightmapRaytraceLast.Reset(); +} +void VkLightmap::Raytrace(const TArray& surfaces) +{ if (surfaces.Size()) { lightmapRaytrace.active = true; diff --git a/src/common/rendering/vulkan/accelstructs/vk_lightmap.h b/src/common/rendering/vulkan/accelstructs/vk_lightmap.h index b8493172c..b1002cd2c 100644 --- a/src/common/rendering/vulkan/accelstructs/vk_lightmap.h +++ b/src/common/rendering/vulkan/accelstructs/vk_lightmap.h @@ -90,8 +90,8 @@ public: VkLightmap(VulkanRenderDevice* fb); ~VkLightmap(); - void Raytrace(LevelMesh* level, const TArray& surfaces); - + void Raytrace(const TArray& surfaces); + void SetLevelMesh(LevelMesh* level); private: void UpdateAccelStructDescriptors(); diff --git a/src/common/rendering/vulkan/vk_renderdevice.cpp b/src/common/rendering/vulkan/vk_renderdevice.cpp index a7500004f..aa9060ab1 100644 --- a/src/common/rendering/vulkan/vk_renderdevice.cpp +++ b/src/common/rendering/vulkan/vk_renderdevice.cpp @@ -474,6 +474,7 @@ void VulkanRenderDevice::BeginFrame() { levelMesh->UpdateLightLists(); GetTextureManager()->CreateLightmap(levelMesh->LMTextureSize, levelMesh->LMTextureCount); + GetLightmap()->SetLevelMesh(levelMesh); #if 0 // full lightmap generation TArray surfaces; @@ -483,9 +484,7 @@ void VulkanRenderDevice::BeginFrame() surfaces[i] = mesh->GetSurface(i); } - GetLightmap()->Raytrace(mesh, surfaces); -#else - GetLightmap()->Raytrace(levelMesh, {}); + GetLightmap()->Raytrace(surfaces); #endif } } @@ -562,12 +561,9 @@ void VulkanRenderDevice::SetLevelMesh(LevelMesh* mesh) void VulkanRenderDevice::UpdateLightmaps(const TArray& surfaces) { - if (surfaces.Size() > 0) + if (surfaces.Size() > 0 && levelMesh) { - if (levelMesh) - { - GetLightmap()->Raytrace(levelMesh, surfaces); - } + GetLightmap()->Raytrace(surfaces); } }