From 9d314ca4ca995354b7178663e918257491f51f1f Mon Sep 17 00:00:00 2001 From: kd-11 Date: Thu, 6 Jun 2019 13:26:33 +0300 Subject: [PATCH] rsx: Correctly count number of valid entries if there are broken entries in the cache --- rpcs3/Emu/RSX/rsx_cache.h | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/rpcs3/Emu/RSX/rsx_cache.h b/rpcs3/Emu/RSX/rsx_cache.h index e83a3834b0..c5d816384d 100644 --- a/rpcs3/Emu/RSX/rsx_cache.h +++ b/rpcs3/Emu/RSX/rsx_cache.h @@ -571,7 +571,7 @@ namespace rsx // Preload everything needed to compile the shaders // Can probably be parallelized too, but since it's mostly reading files it's probably not worth it - std::vector> unpackeds; + std::vector> unpacked; std::chrono::time_point last_update; u32 processed_since_last_update = 0; @@ -590,9 +590,9 @@ namespace rsx } f.read(bytes, f.size()); - auto unpacked = unpack(*(pipeline_data*)bytes.data()); - m_storage.preload_programs(std::get<1>(unpacked), std::get<2>(unpacked)); - unpackeds.push_back(unpacked); + auto entry = unpack(*(pipeline_data*)bytes.data()); + m_storage.preload_programs(std::get<1>(entry), std::get<2>(entry)); + unpacked.push_back(entry); // Only update the screen at about 10fps since updating it everytime slows down the process std::chrono::time_point now = std::chrono::steady_clock::now(); @@ -606,14 +606,17 @@ namespace rsx } } + // Account for any invalid entries + entry_count = u32(unpacked.size()); + atomic_t processed(0); std::function shader_comp_worker = [&](u32 index) { u32 pos; while (((pos = processed++) < entry_count) && !Emu.IsStopped()) { - auto unpacked = unpackeds[pos]; - m_storage.add_pipeline_entry(std::get<1>(unpacked), std::get<2>(unpacked), std::get<0>(unpacked), std::forward(args)...); + auto& entry = unpacked[pos]; + m_storage.add_pipeline_entry(std::get<1>(entry), std::get<2>(entry), std::get<0>(entry), std::forward(args)...); } }; @@ -653,8 +656,8 @@ namespace rsx u32 pos; while (((pos = processed++) < entry_count) && !Emu.IsStopped()) { - auto unpacked = unpackeds[pos]; - m_storage.add_pipeline_entry(std::get<1>(unpacked), std::get<2>(unpacked), std::get<0>(unpacked), std::forward(args)...); + auto& entry = unpacked[pos]; + m_storage.add_pipeline_entry(std::get<1>(entry), std::get<2>(entry), std::get<0>(entry), std::forward(args)...); // Update screen at about 10fps std::chrono::time_point now = std::chrono::steady_clock::now();