diff options
Diffstat (limited to 'src/video_core/rasterizer_accelerated.cpp')
| -rw-r--r-- | src/video_core/rasterizer_accelerated.cpp | 72 |
1 files changed, 0 insertions, 72 deletions
diff --git a/src/video_core/rasterizer_accelerated.cpp b/src/video_core/rasterizer_accelerated.cpp deleted file mode 100644 index f200a650f..000000000 --- a/src/video_core/rasterizer_accelerated.cpp +++ /dev/null | |||
| @@ -1,72 +0,0 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #include <atomic> | ||
| 5 | |||
| 6 | #include "common/assert.h" | ||
| 7 | #include "common/common_types.h" | ||
| 8 | #include "common/div_ceil.h" | ||
| 9 | #include "core/memory.h" | ||
| 10 | #include "video_core/rasterizer_accelerated.h" | ||
| 11 | |||
| 12 | namespace VideoCore { | ||
| 13 | |||
| 14 | using namespace Core::Memory; | ||
| 15 | |||
| 16 | RasterizerAccelerated::RasterizerAccelerated(Memory& cpu_memory_) | ||
| 17 | : cached_pages(std::make_unique<CachedPages>()), cpu_memory{cpu_memory_} {} | ||
| 18 | |||
| 19 | RasterizerAccelerated::~RasterizerAccelerated() = default; | ||
| 20 | |||
| 21 | void RasterizerAccelerated::UpdatePagesCachedCount(VAddr addr, u64 size, int delta) { | ||
| 22 | u64 uncache_begin = 0; | ||
| 23 | u64 cache_begin = 0; | ||
| 24 | u64 uncache_bytes = 0; | ||
| 25 | u64 cache_bytes = 0; | ||
| 26 | |||
| 27 | std::atomic_thread_fence(std::memory_order_acquire); | ||
| 28 | const u64 page_end = Common::DivCeil(addr + size, YUZU_PAGESIZE); | ||
| 29 | for (u64 page = addr >> YUZU_PAGEBITS; page != page_end; ++page) { | ||
| 30 | std::atomic_uint16_t& count = cached_pages->at(page >> 2).Count(page); | ||
| 31 | |||
| 32 | if (delta > 0) { | ||
| 33 | ASSERT_MSG(count.load(std::memory_order::relaxed) < UINT16_MAX, "Count may overflow!"); | ||
| 34 | } else if (delta < 0) { | ||
| 35 | ASSERT_MSG(count.load(std::memory_order::relaxed) > 0, "Count may underflow!"); | ||
| 36 | } else { | ||
| 37 | ASSERT_MSG(false, "Delta must be non-zero!"); | ||
| 38 | } | ||
| 39 | |||
| 40 | // Adds or subtracts 1, as count is a unsigned 8-bit value | ||
| 41 | count.fetch_add(static_cast<u16>(delta), std::memory_order_release); | ||
| 42 | |||
| 43 | // Assume delta is either -1 or 1 | ||
| 44 | if (count.load(std::memory_order::relaxed) == 0) { | ||
| 45 | if (uncache_bytes == 0) { | ||
| 46 | uncache_begin = page; | ||
| 47 | } | ||
| 48 | uncache_bytes += YUZU_PAGESIZE; | ||
| 49 | } else if (uncache_bytes > 0) { | ||
| 50 | cpu_memory.RasterizerMarkRegionCached(uncache_begin << YUZU_PAGEBITS, uncache_bytes, | ||
| 51 | false); | ||
| 52 | uncache_bytes = 0; | ||
| 53 | } | ||
| 54 | if (count.load(std::memory_order::relaxed) == 1 && delta > 0) { | ||
| 55 | if (cache_bytes == 0) { | ||
| 56 | cache_begin = page; | ||
| 57 | } | ||
| 58 | cache_bytes += YUZU_PAGESIZE; | ||
| 59 | } else if (cache_bytes > 0) { | ||
| 60 | cpu_memory.RasterizerMarkRegionCached(cache_begin << YUZU_PAGEBITS, cache_bytes, true); | ||
| 61 | cache_bytes = 0; | ||
| 62 | } | ||
| 63 | } | ||
| 64 | if (uncache_bytes > 0) { | ||
| 65 | cpu_memory.RasterizerMarkRegionCached(uncache_begin << YUZU_PAGEBITS, uncache_bytes, false); | ||
| 66 | } | ||
| 67 | if (cache_bytes > 0) { | ||
| 68 | cpu_memory.RasterizerMarkRegionCached(cache_begin << YUZU_PAGEBITS, cache_bytes, true); | ||
| 69 | } | ||
| 70 | } | ||
| 71 | |||
| 72 | } // namespace VideoCore | ||