diff options
author | Liam <byteslice@airmail.cc> | 2024-01-17 05:35:48 +0100 |
---|---|---|
committer | Fernando Sahmkow <fsahmkow27@gmail.com> | 2024-01-31 16:38:51 +0100 |
commit | 8f848f43e979ac4049237d3b6a161696dd85372b (patch) | |
tree | e218fcb939560362b4293ab035669d776d6e0cb0 /src/core | |
parent | Texture Cache: make sparse texture table per channel (diff) | |
download | yuzu-8f848f43e979ac4049237d3b6a161696dd85372b.tar yuzu-8f848f43e979ac4049237d3b6a161696dd85372b.tar.gz yuzu-8f848f43e979ac4049237d3b6a161696dd85372b.tar.bz2 yuzu-8f848f43e979ac4049237d3b6a161696dd85372b.tar.lz yuzu-8f848f43e979ac4049237d3b6a161696dd85372b.tar.xz yuzu-8f848f43e979ac4049237d3b6a161696dd85372b.tar.zst yuzu-8f848f43e979ac4049237d3b6a161696dd85372b.zip |
Diffstat (limited to '')
-rw-r--r-- | src/core/device_memory_manager.h | 3 | ||||
-rw-r--r-- | src/core/device_memory_manager.inc | 11 |
2 files changed, 3 insertions, 11 deletions
diff --git a/src/core/device_memory_manager.h b/src/core/device_memory_manager.h index ffeed46cc..63823602c 100644 --- a/src/core/device_memory_manager.h +++ b/src/core/device_memory_manager.h @@ -10,6 +10,7 @@ #include <mutex> #include "common/common_types.h" +#include "common/range_mutex.h" #include "common/scratch_buffer.h" #include "common/virtual_buffer.h" @@ -204,7 +205,7 @@ private: (1ULL << (device_virtual_bits - page_bits)) / subentries; using CachedPages = std::array<CounterEntry, num_counter_entries>; std::unique_ptr<CachedPages> cached_pages; - std::mutex counter_guard; + Common::RangeMutex counter_guard; std::mutex mapping_guard; }; diff --git a/src/core/device_memory_manager.inc b/src/core/device_memory_manager.inc index eab8a2731..0a59000aa 100644 --- a/src/core/device_memory_manager.inc +++ b/src/core/device_memory_manager.inc @@ -508,12 +508,7 @@ void DeviceMemoryManager<Traits>::UnregisterProcess(Asid asid) { template <typename Traits> void DeviceMemoryManager<Traits>::UpdatePagesCachedCount(DAddr addr, size_t size, s32 delta) { - std::unique_lock<std::mutex> lk(counter_guard, std::defer_lock); - const auto Lock = [&] { - if (!lk) { - lk.lock(); - } - }; + Common::ScopedRangeLock lk(counter_guard, addr, size); u64 uncache_begin = 0; u64 cache_begin = 0; u64 uncache_bytes = 0; @@ -548,7 +543,6 @@ void DeviceMemoryManager<Traits>::UpdatePagesCachedCount(DAddr addr, size_t size } uncache_bytes += Memory::YUZU_PAGESIZE; } else if (uncache_bytes > 0) { - Lock(); MarkRegionCaching(memory_device_inter, uncache_begin << Memory::YUZU_PAGEBITS, uncache_bytes, false); uncache_bytes = 0; @@ -559,7 +553,6 @@ void DeviceMemoryManager<Traits>::UpdatePagesCachedCount(DAddr addr, size_t size } cache_bytes += Memory::YUZU_PAGESIZE; } else if (cache_bytes > 0) { - Lock(); MarkRegionCaching(memory_device_inter, cache_begin << Memory::YUZU_PAGEBITS, cache_bytes, true); cache_bytes = 0; @@ -567,12 +560,10 @@ void DeviceMemoryManager<Traits>::UpdatePagesCachedCount(DAddr addr, size_t size vpage++; } if (uncache_bytes > 0) { - Lock(); MarkRegionCaching(memory_device_inter, uncache_begin << Memory::YUZU_PAGEBITS, uncache_bytes, false); } if (cache_bytes > 0) { - Lock(); MarkRegionCaching(memory_device_inter, cache_begin << Memory::YUZU_PAGEBITS, cache_bytes, true); } |