From c8f31656cb1c5f5e3c83a5b977fd822e987cb596 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Thu, 27 Jul 2017 13:15:38 +1000 Subject: VideoBackends: Support a different number of threads for precompiling At runtime, we only really want a single shader compiler thread. However, for initial boots, we can use a higher number to speed things up. --- .../Core/VideoBackends/OGL/ProgramShaderCache.cpp | 23 ++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'Source/Core/VideoBackends/OGL/ProgramShaderCache.cpp') diff --git a/Source/Core/VideoBackends/OGL/ProgramShaderCache.cpp b/Source/Core/VideoBackends/OGL/ProgramShaderCache.cpp index 6cdc240ce6..e2d201e9b7 100644 --- a/Source/Core/VideoBackends/OGL/ProgramShaderCache.cpp +++ b/Source/Core/VideoBackends/OGL/ProgramShaderCache.cpp @@ -607,17 +607,8 @@ void ProgramShaderCache::Init() // on the main thread the first time they are used, causing stutter. Nouveau has been // reported to crash if draw calls are invoked on the shared context threads. For now, // disable asynchronous compilation on Mesa. - if (!DriverDetails::HasBug(DriverDetails::BUG_SHARED_CONTEXT_SHADER_COMPILATION) && - g_ActiveConfig.GetShaderCompilerThreads() > 0) - { + if (!DriverDetails::HasBug(DriverDetails::BUG_SHARED_CONTEXT_SHADER_COMPILATION)) s_async_compiler = std::make_unique(); - s_async_compiler->StartWorkerThreads(g_ActiveConfig.GetShaderCompilerThreads()); - if (!s_async_compiler->HasWorkerThreads()) - { - // No point using the async compiler without workers. - s_async_compiler.reset(); - } - } // Read our shader cache, only if supported and enabled if (g_ogl_config.bSupportsGLSLCache && g_ActiveConfig.bShaderCache) @@ -630,7 +621,19 @@ void ProgramShaderCache::Init() last_uber_entry = nullptr; if (g_ActiveConfig.CanPrecompileUberShaders()) + { + if (s_async_compiler) + s_async_compiler->ResizeWorkerThreads(g_ActiveConfig.GetShaderPrecompilerThreads()); PrecompileUberShaders(); + } + + if (s_async_compiler) + { + // No point using the async compiler without workers. + s_async_compiler->ResizeWorkerThreads(g_ActiveConfig.GetShaderCompilerThreads()); + if (!s_async_compiler->HasWorkerThreads()) + s_async_compiler.reset(); + } } void ProgramShaderCache::RetrieveAsyncShaders() -- cgit v1.2.3