Vulkan: Multithreaded creation of UID pipeline caches

Should give a decent speedup to boot time.
This commit is contained in:
Stenzek 2017-07-20 15:25:38 +10:00
parent 81b4ed2a81
commit 33f6668544
3 changed files with 19 additions and 7 deletions

View File

@ -113,9 +113,6 @@ bool Renderer::Initialize()
m_bounding_box->GetGPUBufferSize());
}
// Ensure all pipelines previously used by the game have been created.
StateTracker::GetInstance()->ReloadPipelineUIDCache();
// Initialize post processing.
m_post_processor = std::make_unique<VulkanPostProcessing>();
if (!static_cast<VulkanPostProcessing*>(m_post_processor.get())

View File

@ -156,6 +156,10 @@ void StateTracker::ReloadPipelineUIDCache()
PipelineInserter inserter(this);
m_uid_cache.OpenAndRead(filename, inserter);
}
// If we were using background compilation, ensure everything is ready before continuing.
if (g_ActiveConfig.bBackgroundShaderCompiling)
g_shader_cache->WaitForBackgroundCompilesToComplete();
}
void StateTracker::AppendToPipelineUIDCache(const PipelineInfo& info)
@ -212,11 +216,19 @@ bool StateTracker::PrecachePipelineUID(const SerializedPipelineUID& uid)
pinfo.blend_state.hex = uid.blend_state_bits;
pinfo.primitive_topology = uid.primitive_topology;
VkPipeline pipeline = g_shader_cache->GetPipeline(pinfo);
if (pipeline == VK_NULL_HANDLE)
if (g_ActiveConfig.bBackgroundShaderCompiling)
{
WARN_LOG(VIDEO, "Failed to get pipeline from cached UID.");
return false;
// Use async for multithreaded compilation.
g_shader_cache->GetPipelineWithCacheResultAsync(pinfo);
}
else
{
VkPipeline pipeline = g_shader_cache->GetPipeline(pinfo);
if (pipeline == VK_NULL_HANDLE)
{
WARN_LOG(VIDEO, "Failed to get pipeline from cached UID.");
return false;
}
}
// We don't need to do anything with this pipeline, just make sure it exists.

View File

@ -263,6 +263,9 @@ bool VideoBackend::Initialize(void* window_handle)
return false;
}
// Ensure all pipelines previously used by the game have been created.
StateTracker::GetInstance()->ReloadPipelineUIDCache();
// Lastly, precompile ubershaders, if requested.
// This has to be done after the texture cache and shader cache are initialized.
if (g_ActiveConfig.CanPrecompileUberShaders())