Fixup for multi-thread shader compilation (loading stage) (#9762)

* Multi-thread shader compilation

This offers a huge improvement in startup performance. With around 13,000 shaders we go from ~1:30 to under 10 seconds. It looks like this was the original intention of the author given the outer scope recompile variable.

Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
This commit is contained in:
Alex Saveau 2021-02-12 03:39:35 -08:00 committed by GitHub
parent b858fceb4f
commit 48296c2ba6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -195,7 +195,9 @@ protected:
std::tuple<const fragment_program_type&, bool> search_fragment_program(const RSXFragmentProgram& rsx_fp, bool force_load = true)
{
bool recompile = false;
typename binary_to_fragment_program::iterator it;
fragment_program_type* new_shader;
{
reader_lock lock(m_fragment_mutex);
@ -213,15 +215,14 @@ protected:
rsx_log.notice("FP not found in buffer!");
lock.upgrade();
auto [it, inserted] = m_fragment_shader_cache.try_emplace(rsx_fp);
std::tie(it, recompile) = m_fragment_shader_cache.try_emplace(rsx_fp);
new_shader = &(it->second);
recompile = inserted;
}
if (inserted)
{
it->first.clone_data();
backend_traits::recompile_fragment_program(rsx_fp, *new_shader, m_next_id++);
}
if (recompile)
{
it->first.clone_data();
backend_traits::recompile_fragment_program(rsx_fp, *new_shader, m_next_id++);
}
return std::forward_as_tuple(*new_shader, false);