From dd4c13b625a412b5cef9b881bc8880cd0863dd46 Mon Sep 17 00:00:00 2001 From: kd-11 Date: Sun, 10 Jun 2018 22:40:43 +0300 Subject: [PATCH] rsx: Avoid race conditions in unsynchronized unprotect --- rpcs3/Emu/RSX/Common/texture_cache.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/rpcs3/Emu/RSX/Common/texture_cache.h b/rpcs3/Emu/RSX/Common/texture_cache.h index c4e7474466..61eedbd96c 100644 --- a/rpcs3/Emu/RSX/Common/texture_cache.h +++ b/rpcs3/Emu/RSX/Common/texture_cache.h @@ -679,13 +679,17 @@ namespace rsx m_unreleased_texture_objects++; } - //Only unsynchronized (no-flush) sections should reach here, and only if the rendering thread is the caller + // Only unsynchronized (no-flush) sections should reach here, and only if the rendering thread is the caller if (discard_only) + { obj.first->discard(); + obj.second->remove_one(); + } else - obj.first->unprotect(); - - obj.second->remove_one(); + { + // Delay unprotect in case there are sections to flush + result.sections_to_unprotect.push_back(obj.first); + } } if (deferred_flush && result.sections_to_flush.size())