From 2f343bcab70e9c2dd238accd41aae28823a17ca6 Mon Sep 17 00:00:00 2001 From: Skyth <19259897+blueskythlikesclouds@users.noreply.github.com> Date: Thu, 28 Nov 2024 00:23:59 +0300 Subject: [PATCH] Dynamically create pipeline threads depending on hardware concurrency. --- UnleashedRecomp/gpu/video.cpp | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/UnleashedRecomp/gpu/video.cpp b/UnleashedRecomp/gpu/video.cpp index d9fab109..e9a01f85 100644 --- a/UnleashedRecomp/gpu/video.cpp +++ b/UnleashedRecomp/gpu/video.cpp @@ -4453,18 +4453,16 @@ static void PipelineCompilerThread() } } -static std::thread g_pipelineCompilerThread(PipelineCompilerThread); -static std::thread g_pipelineCompilerThread1(PipelineCompilerThread); -static std::thread g_pipelineCompilerThread2(PipelineCompilerThread); -static std::thread g_pipelineCompilerThread3(PipelineCompilerThread); -static std::thread g_pipelineCompilerThread4(PipelineCompilerThread); -static std::thread g_pipelineCompilerThread5(PipelineCompilerThread); -static std::thread g_pipelineCompilerThread6(PipelineCompilerThread); -static std::thread g_pipelineCompilerThread7(PipelineCompilerThread); -static std::thread g_pipelineCompilerThread8(PipelineCompilerThread); -static std::thread g_pipelineCompilerThread9(PipelineCompilerThread); -static std::thread g_pipelineCompilerThread10(PipelineCompilerThread); -static std::thread g_pipelineCompilerThread11(PipelineCompilerThread); +static std::vector> g_pipelineCompilerThreads = []() + { + size_t threadCount = std::max(2u, (std::thread::hardware_concurrency() * 2) / 3); + + std::vector> threads(threadCount); + for (auto& thread : threads) + thread = std::make_unique(PipelineCompilerThread); + + return threads; + }(); static constexpr uint32_t MODEL_DATA_VFTABLE = 0x82073A44; static constexpr uint32_t TERRAIN_MODEL_DATA_VFTABLE = 0x8211D25C;