diff options
author | Liam <byteslice@airmail.cc> | 2024-01-16 03:56:38 +0100 |
---|---|---|
committer | Liam <byteslice@airmail.cc> | 2024-01-19 03:12:30 +0100 |
commit | 748465f5a578fcd99f91e0591ac773940172a72e (patch) | |
tree | 864bf003edf609f1ddcf16ec9f580a8e583da929 /src | |
parent | nvhost_vic: use map erase by key (diff) | |
download | yuzu-748465f5a578fcd99f91e0591ac773940172a72e.tar yuzu-748465f5a578fcd99f91e0591ac773940172a72e.tar.gz yuzu-748465f5a578fcd99f91e0591ac773940172a72e.tar.bz2 yuzu-748465f5a578fcd99f91e0591ac773940172a72e.tar.lz yuzu-748465f5a578fcd99f91e0591ac773940172a72e.tar.xz yuzu-748465f5a578fcd99f91e0591ac773940172a72e.tar.zst yuzu-748465f5a578fcd99f91e0591ac773940172a72e.zip |
Diffstat (limited to 'src')
-rw-r--r-- | src/core/device_memory_manager.inc | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/src/core/device_memory_manager.inc b/src/core/device_memory_manager.inc index f6e4ad874..8ce122872 100644 --- a/src/core/device_memory_manager.inc +++ b/src/core/device_memory_manager.inc @@ -509,18 +509,12 @@ void DeviceMemoryManager<Traits>::UnregisterProcess(Asid asid) { template <typename Traits> void DeviceMemoryManager<Traits>::UpdatePagesCachedCount(DAddr addr, size_t size, s32 delta) { - bool locked = false; - auto lock = [&] { - if (!locked) { - counter_guard.lock(); - locked = true; + std::unique_lock<std::mutex> lk(counter_guard, std::defer_lock); + const auto Lock = [&] { + if (!lk) { + lk.lock(); } }; - SCOPE_EXIT({ - if (locked) { - counter_guard.unlock(); - } - }); u64 uncache_begin = 0; u64 cache_begin = 0; u64 uncache_bytes = 0; @@ -555,7 +549,7 @@ void DeviceMemoryManager<Traits>::UpdatePagesCachedCount(DAddr addr, size_t size } uncache_bytes += Memory::YUZU_PAGESIZE; } else if (uncache_bytes > 0) { - lock(); + Lock(); MarkRegionCaching(memory_device_inter, uncache_begin << Memory::YUZU_PAGEBITS, uncache_bytes, false); uncache_bytes = 0; @@ -566,7 +560,7 @@ void DeviceMemoryManager<Traits>::UpdatePagesCachedCount(DAddr addr, size_t size } cache_bytes += Memory::YUZU_PAGESIZE; } else if (cache_bytes > 0) { - lock(); + Lock(); MarkRegionCaching(memory_device_inter, cache_begin << Memory::YUZU_PAGEBITS, cache_bytes, true); cache_bytes = 0; @@ -574,12 +568,12 @@ void DeviceMemoryManager<Traits>::UpdatePagesCachedCount(DAddr addr, size_t size vpage++; } if (uncache_bytes > 0) { - lock(); + Lock(); MarkRegionCaching(memory_device_inter, uncache_begin << Memory::YUZU_PAGEBITS, uncache_bytes, false); } if (cache_bytes > 0) { - lock(); + Lock(); MarkRegionCaching(memory_device_inter, cache_begin << Memory::YUZU_PAGEBITS, cache_bytes, true); } |