From b534d49e48aeacf9fc2c3d8968940192d45cccbc Mon Sep 17 00:00:00 2001 From: Rui Pinheiro Date: Sat, 11 Aug 2018 22:50:57 +0100 Subject: [PATCH] Fix off-by-one error in get_intersecting_set When the trampled range changes, get_intersecting_set restarts the outer loop. However, due to an off-by-one error, it skips the first cache entry when doing so. This can cause a texture not to be correctly unlocked, which could lead to issues or even deadlocks. This commit fixes this off-by-one error. --- rpcs3/Emu/RSX/Common/texture_cache.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/rpcs3/Emu/RSX/Common/texture_cache.h b/rpcs3/Emu/RSX/Common/texture_cache.h index 8bb6f4bdf6..f6e4d4eb09 100644 --- a/rpcs3/Emu/RSX/Common/texture_cache.h +++ b/rpcs3/Emu/RSX/Common/texture_cache.h @@ -572,7 +572,8 @@ namespace rsx std::pair trampled_range = std::make_pair(address, address + range); const bool strict_range_check = g_cfg.video.write_color_buffers || g_cfg.video.write_depth_buffer; - for (auto It = m_cache.begin(); It != m_cache.end(); It++) + auto It = m_cache.begin(); + while(It != m_cache.end()) { auto &range_data = It->second; const u32 base = It->first; @@ -585,7 +586,10 @@ namespace rsx { //Only if a valid range, ignore empty sets if (trampled_range.first >= (range_data.max_addr + range_data.max_range) || range_data.min_addr >= trampled_range.second) + { + It++; continue; + } } for (int i = 0; i < range_data.data.size(); i++) @@ -621,6 +625,8 @@ namespace rsx last_dirty_block = base; It = m_cache.begin(); } + else + It++; } return result;