Fix pipelines getting dropped.

This commit is contained in:
Skyth 2024-11-26 21:25:09 +03:00
parent 6f313ed5a8
commit f1eb4992ab

View file

@ -4298,22 +4298,17 @@ static void CreateGraphicsPipelineInPipelineThread(const PipelineState& pipeline
{ {
XXH64_hash_t hash = XXH3_64bits(&pipelineState, sizeof(pipelineState)); XXH64_hash_t hash = XXH3_64bits(&pipelineState, sizeof(pipelineState));
bool found = false; bool shouldCompile = false;
{ {
std::lock_guard lock(g_asyncPipelineMutex); std::lock_guard lock(g_asyncPipelineMutex);
found = g_asyncPipelines.contains(hash); shouldCompile = g_asyncPipelines.emplace(hash).second;
} }
if (!found) if (shouldCompile)
{ {
auto pipeline = CreateGraphicsPipeline(pipelineState); auto pipeline = CreateGraphicsPipeline(pipelineState);
pipeline->setName(std::format("Async Pipeline {:X}", hash)); pipeline->setName(std::format("Async Pipeline {:X}", hash));
{
std::lock_guard lock(g_asyncPipelineMutex);
g_asyncPipelines.emplace(hash);
}
// Will get dropped in render thread if a different thread already managed to compile this. // Will get dropped in render thread if a different thread already managed to compile this.
RenderCommand cmd; RenderCommand cmd;
cmd.type = RenderCommandType::AddPipeline; cmd.type = RenderCommandType::AddPipeline;