Fix race condition

This commit is contained in:
Magnus Norddahl 2025-04-12 00:35:14 +02:00
commit 883e3ce907
2 changed files with 3 additions and 0 deletions

View file

@ -276,6 +276,7 @@ VkVertexFormat *VkRenderPassManager::GetVertexFormat(int index)
VulkanPipelineLayout* VkRenderPassManager::GetPipelineLayout(bool levelmesh, int UserUniformSize)
{
std::unique_lock lock(PipelineLayoutsMutex);
auto &layout = PipelineLayouts[levelmesh][UserUniformSize];
if (layout)
return layout.get();

View file

@ -11,6 +11,7 @@
#include <map>
#include <thread>
#include <condition_variable>
#include <mutex>
class VulkanRenderDevice;
class ColorBlendAttachmentBuilder;
@ -183,6 +184,7 @@ private:
VulkanRenderDevice* fb = nullptr;
std::map<VkRenderPassKey, std::unique_ptr<VkRenderPassSetup>> RenderPassSetup;
std::mutex PipelineLayoutsMutex;
std::map<int, std::unique_ptr<VulkanPipelineLayout>> PipelineLayouts[2];
std::vector<VkVertexFormat> VertexFormats;