rsx: Fix cache skipping shaders on load+compile (#8633)

When on single worker mode (OpenGL or an hypothetical scenario of a 
single core PC with Vulkan), load and compile would skip 10% of the 
shaders on queue each stage.

Co-authored-by: kd-11 <karokidii@gmail.com>
This commit is contained in:
Ani 2020-07-26 08:47:50 +01:00 committed by GitHub
parent 9f829b375a
commit 74c8a44d84
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 0 deletions

View File

@ -439,6 +439,7 @@ namespace rsx
std::function<void(u32)> shader_load_worker = [&](u32 stop_at) std::function<void(u32)> shader_load_worker = [&](u32 stop_at)
{ {
u32 pos; u32 pos;
// Processed is incremented before work starts in order to avoid two workers working on the same shader
while (((pos = processed++) < stop_at) && !Emu.IsStopped()) while (((pos = processed++) < stop_at) && !Emu.IsStopped())
{ {
fs::dir_entry tmp = entries[pos]; fs::dir_entry tmp = entries[pos];
@ -459,6 +460,8 @@ namespace rsx
unpacked[unpacked.push_begin()] = entry; unpacked[unpacked.push_begin()] = entry;
} }
// Do not account for an extra shader that was never processed
processed--;
}; };
await_workers(nb_workers, 0, shader_load_worker, processed, entry_count, dlg); await_workers(nb_workers, 0, shader_load_worker, processed, entry_count, dlg);
@ -472,11 +475,14 @@ namespace rsx
std::function<void(u32)> shader_comp_worker = [&](u32 stop_at) std::function<void(u32)> shader_comp_worker = [&](u32 stop_at)
{ {
u32 pos; u32 pos;
// Processed is incremented before work starts in order to avoid two workers working on the same shader
while (((pos = processed++) < stop_at) && !Emu.IsStopped()) while (((pos = processed++) < stop_at) && !Emu.IsStopped())
{ {
auto& entry = unpacked[pos]; auto& entry = unpacked[pos];
m_storage.add_pipeline_entry(std::get<1>(entry), std::get<2>(entry), std::get<0>(entry), std::forward<Args>(args)...); m_storage.add_pipeline_entry(std::get<1>(entry), std::get<2>(entry), std::get<0>(entry), std::forward<Args>(args)...);
} }
// Do not account for an extra shader that was never processed
processed--;
}; };
await_workers(nb_workers, 1, shader_comp_worker, processed, entry_count, dlg); await_workers(nb_workers, 1, shader_comp_worker, processed, entry_count, dlg);
@ -535,6 +541,8 @@ namespace rsx
} }
} }
} }
verify(HERE), processed == entry_count;
} }
public: public: