diff options
Diffstat (limited to 'src/video_core')
| -rw-r--r-- | src/video_core/buffer_cache/buffer_base.h | 2 | ||||
| -rw-r--r-- | src/video_core/buffer_cache/buffer_cache.h | 49 | ||||
| -rw-r--r-- | src/video_core/memory_manager.cpp | 4 | ||||
| -rw-r--r-- | src/video_core/query_cache.h | 12 | ||||
| -rw-r--r-- | src/video_core/rasterizer_accelerated.cpp | 17 | ||||
| -rw-r--r-- | src/video_core/shader_cache.cpp | 12 | ||||
| -rw-r--r-- | src/video_core/shader_cache.h | 4 | ||||
| -rw-r--r-- | src/video_core/texture_cache/texture_cache.h | 12 | ||||
| -rw-r--r-- | src/video_core/texture_cache/texture_cache_base.h | 10 |
9 files changed, 62 insertions, 60 deletions
diff --git a/src/video_core/buffer_cache/buffer_base.h b/src/video_core/buffer_cache/buffer_base.h index 3e20608ca..0b2bc67b1 100644 --- a/src/video_core/buffer_cache/buffer_base.h +++ b/src/video_core/buffer_cache/buffer_base.h | |||
| @@ -36,7 +36,7 @@ struct NullBufferParams {}; | |||
| 36 | template <class RasterizerInterface> | 36 | template <class RasterizerInterface> |
| 37 | class BufferBase { | 37 | class BufferBase { |
| 38 | static constexpr u64 PAGES_PER_WORD = 64; | 38 | static constexpr u64 PAGES_PER_WORD = 64; |
| 39 | static constexpr u64 BYTES_PER_PAGE = Core::Memory::PAGE_SIZE; | 39 | static constexpr u64 BYTES_PER_PAGE = Core::Memory::YUZU_PAGESIZE; |
| 40 | static constexpr u64 BYTES_PER_WORD = PAGES_PER_WORD * BYTES_PER_PAGE; | 40 | static constexpr u64 BYTES_PER_WORD = PAGES_PER_WORD * BYTES_PER_PAGE; |
| 41 | 41 | ||
| 42 | /// Vector tracking modified pages tightly packed with small vector optimization | 42 | /// Vector tracking modified pages tightly packed with small vector optimization |
diff --git a/src/video_core/buffer_cache/buffer_cache.h b/src/video_core/buffer_cache/buffer_cache.h index b74ad7900..f015dae56 100644 --- a/src/video_core/buffer_cache/buffer_cache.h +++ b/src/video_core/buffer_cache/buffer_cache.h | |||
| @@ -60,8 +60,8 @@ class BufferCache { | |||
| 60 | 60 | ||
| 61 | // Page size for caching purposes. | 61 | // Page size for caching purposes. |
| 62 | // This is unrelated to the CPU page size and it can be changed as it seems optimal. | 62 | // This is unrelated to the CPU page size and it can be changed as it seems optimal. |
| 63 | static constexpr u32 PAGE_BITS = 16; | 63 | static constexpr u32 YUZU_PAGEBITS = 16; |
| 64 | static constexpr u64 PAGE_SIZE = u64{1} << PAGE_BITS; | 64 | static constexpr u64 YUZU_PAGESIZE = u64{1} << YUZU_PAGEBITS; |
| 65 | 65 | ||
| 66 | static constexpr bool IS_OPENGL = P::IS_OPENGL; | 66 | static constexpr bool IS_OPENGL = P::IS_OPENGL; |
| 67 | static constexpr bool HAS_PERSISTENT_UNIFORM_BUFFER_BINDINGS = | 67 | static constexpr bool HAS_PERSISTENT_UNIFORM_BUFFER_BINDINGS = |
| @@ -216,8 +216,8 @@ private: | |||
| 216 | 216 | ||
| 217 | template <typename Func> | 217 | template <typename Func> |
| 218 | void ForEachBufferInRange(VAddr cpu_addr, u64 size, Func&& func) { | 218 | void ForEachBufferInRange(VAddr cpu_addr, u64 size, Func&& func) { |
| 219 | const u64 page_end = Common::DivCeil(cpu_addr + size, PAGE_SIZE); | 219 | const u64 page_end = Common::DivCeil(cpu_addr + size, YUZU_PAGESIZE); |
| 220 | for (u64 page = cpu_addr >> PAGE_BITS; page < page_end;) { | 220 | for (u64 page = cpu_addr >> YUZU_PAGEBITS; page < page_end;) { |
| 221 | const BufferId buffer_id = page_table[page]; | 221 | const BufferId buffer_id = page_table[page]; |
| 222 | if (!buffer_id) { | 222 | if (!buffer_id) { |
| 223 | ++page; | 223 | ++page; |
| @@ -227,7 +227,7 @@ private: | |||
| 227 | func(buffer_id, buffer); | 227 | func(buffer_id, buffer); |
| 228 | 228 | ||
| 229 | const VAddr end_addr = buffer.CpuAddr() + buffer.SizeBytes(); | 229 | const VAddr end_addr = buffer.CpuAddr() + buffer.SizeBytes(); |
| 230 | page = Common::DivCeil(end_addr, PAGE_SIZE); | 230 | page = Common::DivCeil(end_addr, YUZU_PAGESIZE); |
| 231 | } | 231 | } |
| 232 | } | 232 | } |
| 233 | 233 | ||
| @@ -262,8 +262,8 @@ private: | |||
| 262 | } | 262 | } |
| 263 | 263 | ||
| 264 | static bool IsRangeGranular(VAddr cpu_addr, size_t size) { | 264 | static bool IsRangeGranular(VAddr cpu_addr, size_t size) { |
| 265 | return (cpu_addr & ~Core::Memory::PAGE_MASK) == | 265 | return (cpu_addr & ~Core::Memory::YUZU_PAGEMASK) == |
| 266 | ((cpu_addr + size) & ~Core::Memory::PAGE_MASK); | 266 | ((cpu_addr + size) & ~Core::Memory::YUZU_PAGEMASK); |
| 267 | } | 267 | } |
| 268 | 268 | ||
| 269 | void RunGarbageCollector(); | 269 | void RunGarbageCollector(); |
| @@ -439,7 +439,7 @@ private: | |||
| 439 | u64 minimum_memory = 0; | 439 | u64 minimum_memory = 0; |
| 440 | u64 critical_memory = 0; | 440 | u64 critical_memory = 0; |
| 441 | 441 | ||
| 442 | std::array<BufferId, ((1ULL << 39) >> PAGE_BITS)> page_table; | 442 | std::array<BufferId, ((1ULL << 39) >> YUZU_PAGEBITS)> page_table; |
| 443 | }; | 443 | }; |
| 444 | 444 | ||
| 445 | template <class P> | 445 | template <class P> |
| @@ -926,8 +926,8 @@ void BufferCache<P>::PopAsyncFlushes() {} | |||
| 926 | 926 | ||
| 927 | template <class P> | 927 | template <class P> |
| 928 | bool BufferCache<P>::IsRegionGpuModified(VAddr addr, size_t size) { | 928 | bool BufferCache<P>::IsRegionGpuModified(VAddr addr, size_t size) { |
| 929 | const u64 page_end = Common::DivCeil(addr + size, PAGE_SIZE); | 929 | const u64 page_end = Common::DivCeil(addr + size, YUZU_PAGESIZE); |
| 930 | for (u64 page = addr >> PAGE_BITS; page < page_end;) { | 930 | for (u64 page = addr >> YUZU_PAGEBITS; page < page_end;) { |
| 931 | const BufferId image_id = page_table[page]; | 931 | const BufferId image_id = page_table[page]; |
| 932 | if (!image_id) { | 932 | if (!image_id) { |
| 933 | ++page; | 933 | ++page; |
| @@ -938,7 +938,7 @@ bool BufferCache<P>::IsRegionGpuModified(VAddr addr, size_t size) { | |||
| 938 | return true; | 938 | return true; |
| 939 | } | 939 | } |
| 940 | const VAddr end_addr = buffer.CpuAddr() + buffer.SizeBytes(); | 940 | const VAddr end_addr = buffer.CpuAddr() + buffer.SizeBytes(); |
| 941 | page = Common::DivCeil(end_addr, PAGE_SIZE); | 941 | page = Common::DivCeil(end_addr, YUZU_PAGESIZE); |
| 942 | } | 942 | } |
| 943 | return false; | 943 | return false; |
| 944 | } | 944 | } |
| @@ -946,8 +946,8 @@ bool BufferCache<P>::IsRegionGpuModified(VAddr addr, size_t size) { | |||
| 946 | template <class P> | 946 | template <class P> |
| 947 | bool BufferCache<P>::IsRegionRegistered(VAddr addr, size_t size) { | 947 | bool BufferCache<P>::IsRegionRegistered(VAddr addr, size_t size) { |
| 948 | const VAddr end_addr = addr + size; | 948 | const VAddr end_addr = addr + size; |
| 949 | const u64 page_end = Common::DivCeil(end_addr, PAGE_SIZE); | 949 | const u64 page_end = Common::DivCeil(end_addr, YUZU_PAGESIZE); |
| 950 | for (u64 page = addr >> PAGE_BITS; page < page_end;) { | 950 | for (u64 page = addr >> YUZU_PAGEBITS; page < page_end;) { |
| 951 | const BufferId buffer_id = page_table[page]; | 951 | const BufferId buffer_id = page_table[page]; |
| 952 | if (!buffer_id) { | 952 | if (!buffer_id) { |
| 953 | ++page; | 953 | ++page; |
| @@ -959,15 +959,15 @@ bool BufferCache<P>::IsRegionRegistered(VAddr addr, size_t size) { | |||
| 959 | if (buf_start_addr < end_addr && addr < buf_end_addr) { | 959 | if (buf_start_addr < end_addr && addr < buf_end_addr) { |
| 960 | return true; | 960 | return true; |
| 961 | } | 961 | } |
| 962 | page = Common::DivCeil(end_addr, PAGE_SIZE); | 962 | page = Common::DivCeil(end_addr, YUZU_PAGESIZE); |
| 963 | } | 963 | } |
| 964 | return false; | 964 | return false; |
| 965 | } | 965 | } |
| 966 | 966 | ||
| 967 | template <class P> | 967 | template <class P> |
| 968 | bool BufferCache<P>::IsRegionCpuModified(VAddr addr, size_t size) { | 968 | bool BufferCache<P>::IsRegionCpuModified(VAddr addr, size_t size) { |
| 969 | const u64 page_end = Common::DivCeil(addr + size, PAGE_SIZE); | 969 | const u64 page_end = Common::DivCeil(addr + size, YUZU_PAGESIZE); |
| 970 | for (u64 page = addr >> PAGE_BITS; page < page_end;) { | 970 | for (u64 page = addr >> YUZU_PAGEBITS; page < page_end;) { |
| 971 | const BufferId image_id = page_table[page]; | 971 | const BufferId image_id = page_table[page]; |
| 972 | if (!image_id) { | 972 | if (!image_id) { |
| 973 | ++page; | 973 | ++page; |
| @@ -978,7 +978,7 @@ bool BufferCache<P>::IsRegionCpuModified(VAddr addr, size_t size) { | |||
| 978 | return true; | 978 | return true; |
| 979 | } | 979 | } |
| 980 | const VAddr end_addr = buffer.CpuAddr() + buffer.SizeBytes(); | 980 | const VAddr end_addr = buffer.CpuAddr() + buffer.SizeBytes(); |
| 981 | page = Common::DivCeil(end_addr, PAGE_SIZE); | 981 | page = Common::DivCeil(end_addr, YUZU_PAGESIZE); |
| 982 | } | 982 | } |
| 983 | return false; | 983 | return false; |
| 984 | } | 984 | } |
| @@ -1472,7 +1472,7 @@ BufferId BufferCache<P>::FindBuffer(VAddr cpu_addr, u32 size) { | |||
| 1472 | if (cpu_addr == 0) { | 1472 | if (cpu_addr == 0) { |
| 1473 | return NULL_BUFFER_ID; | 1473 | return NULL_BUFFER_ID; |
| 1474 | } | 1474 | } |
| 1475 | const u64 page = cpu_addr >> PAGE_BITS; | 1475 | const u64 page = cpu_addr >> YUZU_PAGEBITS; |
| 1476 | const BufferId buffer_id = page_table[page]; | 1476 | const BufferId buffer_id = page_table[page]; |
| 1477 | if (!buffer_id) { | 1477 | if (!buffer_id) { |
| 1478 | return CreateBuffer(cpu_addr, size); | 1478 | return CreateBuffer(cpu_addr, size); |
| @@ -1493,8 +1493,9 @@ typename BufferCache<P>::OverlapResult BufferCache<P>::ResolveOverlaps(VAddr cpu | |||
| 1493 | VAddr end = cpu_addr + wanted_size; | 1493 | VAddr end = cpu_addr + wanted_size; |
| 1494 | int stream_score = 0; | 1494 | int stream_score = 0; |
| 1495 | bool has_stream_leap = false; | 1495 | bool has_stream_leap = false; |
| 1496 | for (; cpu_addr >> PAGE_BITS < Common::DivCeil(end, PAGE_SIZE); cpu_addr += PAGE_SIZE) { | 1496 | for (; cpu_addr >> YUZU_PAGEBITS < Common::DivCeil(end, YUZU_PAGESIZE); |
| 1497 | const BufferId overlap_id = page_table[cpu_addr >> PAGE_BITS]; | 1497 | cpu_addr += YUZU_PAGESIZE) { |
| 1498 | const BufferId overlap_id = page_table[cpu_addr >> YUZU_PAGEBITS]; | ||
| 1498 | if (!overlap_id) { | 1499 | if (!overlap_id) { |
| 1499 | continue; | 1500 | continue; |
| 1500 | } | 1501 | } |
| @@ -1520,11 +1521,11 @@ typename BufferCache<P>::OverlapResult BufferCache<P>::ResolveOverlaps(VAddr cpu | |||
| 1520 | // as a stream buffer. Increase the size to skip constantly recreating buffers. | 1521 | // as a stream buffer. Increase the size to skip constantly recreating buffers. |
| 1521 | has_stream_leap = true; | 1522 | has_stream_leap = true; |
| 1522 | if (expands_right) { | 1523 | if (expands_right) { |
| 1523 | begin -= PAGE_SIZE * 256; | 1524 | begin -= YUZU_PAGESIZE * 256; |
| 1524 | cpu_addr = begin; | 1525 | cpu_addr = begin; |
| 1525 | } | 1526 | } |
| 1526 | if (expands_left) { | 1527 | if (expands_left) { |
| 1527 | end += PAGE_SIZE * 256; | 1528 | end += YUZU_PAGESIZE * 256; |
| 1528 | } | 1529 | } |
| 1529 | } | 1530 | } |
| 1530 | } | 1531 | } |
| @@ -1598,8 +1599,8 @@ void BufferCache<P>::ChangeRegister(BufferId buffer_id) { | |||
| 1598 | } | 1599 | } |
| 1599 | const VAddr cpu_addr_begin = buffer.CpuAddr(); | 1600 | const VAddr cpu_addr_begin = buffer.CpuAddr(); |
| 1600 | const VAddr cpu_addr_end = cpu_addr_begin + size; | 1601 | const VAddr cpu_addr_end = cpu_addr_begin + size; |
| 1601 | const u64 page_begin = cpu_addr_begin / PAGE_SIZE; | 1602 | const u64 page_begin = cpu_addr_begin / YUZU_PAGESIZE; |
| 1602 | const u64 page_end = Common::DivCeil(cpu_addr_end, PAGE_SIZE); | 1603 | const u64 page_end = Common::DivCeil(cpu_addr_end, YUZU_PAGESIZE); |
| 1603 | for (u64 page = page_begin; page != page_end; ++page) { | 1604 | for (u64 page = page_begin; page != page_end; ++page) { |
| 1604 | if constexpr (insert) { | 1605 | if constexpr (insert) { |
| 1605 | page_table[page] = buffer_id; | 1606 | page_table[page] = buffer_id; |
diff --git a/src/video_core/memory_manager.cpp b/src/video_core/memory_manager.cpp index d373be0ba..bf9eb735d 100644 --- a/src/video_core/memory_manager.cpp +++ b/src/video_core/memory_manager.cpp | |||
| @@ -369,8 +369,8 @@ bool MemoryManager::IsGranularRange(GPUVAddr gpu_addr, std::size_t size) const { | |||
| 369 | if (!cpu_addr) { | 369 | if (!cpu_addr) { |
| 370 | return false; | 370 | return false; |
| 371 | } | 371 | } |
| 372 | const std::size_t page{(*cpu_addr & Core::Memory::PAGE_MASK) + size}; | 372 | const std::size_t page{(*cpu_addr & Core::Memory::YUZU_PAGEMASK) + size}; |
| 373 | return page <= Core::Memory::PAGE_SIZE; | 373 | return page <= Core::Memory::YUZU_PAGESIZE; |
| 374 | } | 374 | } |
| 375 | 375 | ||
| 376 | bool MemoryManager::IsContinousRange(GPUVAddr gpu_addr, std::size_t size) const { | 376 | bool MemoryManager::IsContinousRange(GPUVAddr gpu_addr, std::size_t size) const { |
diff --git a/src/video_core/query_cache.h b/src/video_core/query_cache.h index fcce87acb..889b606b3 100644 --- a/src/video_core/query_cache.h +++ b/src/video_core/query_cache.h | |||
| @@ -214,8 +214,8 @@ private: | |||
| 214 | return cache_begin < addr_end && addr_begin < cache_end; | 214 | return cache_begin < addr_end && addr_begin < cache_end; |
| 215 | }; | 215 | }; |
| 216 | 216 | ||
| 217 | const u64 page_end = addr_end >> PAGE_BITS; | 217 | const u64 page_end = addr_end >> YUZU_PAGEBITS; |
| 218 | for (u64 page = addr_begin >> PAGE_BITS; page <= page_end; ++page) { | 218 | for (u64 page = addr_begin >> YUZU_PAGEBITS; page <= page_end; ++page) { |
| 219 | const auto& it = cached_queries.find(page); | 219 | const auto& it = cached_queries.find(page); |
| 220 | if (it == std::end(cached_queries)) { | 220 | if (it == std::end(cached_queries)) { |
| 221 | continue; | 221 | continue; |
| @@ -235,14 +235,14 @@ private: | |||
| 235 | /// Registers the passed parameters as cached and returns a pointer to the stored cached query. | 235 | /// Registers the passed parameters as cached and returns a pointer to the stored cached query. |
| 236 | CachedQuery* Register(VideoCore::QueryType type, VAddr cpu_addr, u8* host_ptr, bool timestamp) { | 236 | CachedQuery* Register(VideoCore::QueryType type, VAddr cpu_addr, u8* host_ptr, bool timestamp) { |
| 237 | rasterizer.UpdatePagesCachedCount(cpu_addr, CachedQuery::SizeInBytes(timestamp), 1); | 237 | rasterizer.UpdatePagesCachedCount(cpu_addr, CachedQuery::SizeInBytes(timestamp), 1); |
| 238 | const u64 page = static_cast<u64>(cpu_addr) >> PAGE_BITS; | 238 | const u64 page = static_cast<u64>(cpu_addr) >> YUZU_PAGEBITS; |
| 239 | return &cached_queries[page].emplace_back(static_cast<QueryCache&>(*this), type, cpu_addr, | 239 | return &cached_queries[page].emplace_back(static_cast<QueryCache&>(*this), type, cpu_addr, |
| 240 | host_ptr); | 240 | host_ptr); |
| 241 | } | 241 | } |
| 242 | 242 | ||
| 243 | /// Tries to a get a cached query. Returns nullptr on failure. | 243 | /// Tries to a get a cached query. Returns nullptr on failure. |
| 244 | CachedQuery* TryGet(VAddr addr) { | 244 | CachedQuery* TryGet(VAddr addr) { |
| 245 | const u64 page = static_cast<u64>(addr) >> PAGE_BITS; | 245 | const u64 page = static_cast<u64>(addr) >> YUZU_PAGEBITS; |
| 246 | const auto it = cached_queries.find(page); | 246 | const auto it = cached_queries.find(page); |
| 247 | if (it == std::end(cached_queries)) { | 247 | if (it == std::end(cached_queries)) { |
| 248 | return nullptr; | 248 | return nullptr; |
| @@ -260,8 +260,8 @@ private: | |||
| 260 | uncommitted_flushes->push_back(addr); | 260 | uncommitted_flushes->push_back(addr); |
| 261 | } | 261 | } |
| 262 | 262 | ||
| 263 | static constexpr std::uintptr_t PAGE_SIZE = 4096; | 263 | static constexpr std::uintptr_t YUZU_PAGESIZE = 4096; |
| 264 | static constexpr unsigned PAGE_BITS = 12; | 264 | static constexpr unsigned YUZU_PAGEBITS = 12; |
| 265 | 265 | ||
| 266 | VideoCore::RasterizerInterface& rasterizer; | 266 | VideoCore::RasterizerInterface& rasterizer; |
| 267 | Tegra::Engines::Maxwell3D& maxwell3d; | 267 | Tegra::Engines::Maxwell3D& maxwell3d; |
diff --git a/src/video_core/rasterizer_accelerated.cpp b/src/video_core/rasterizer_accelerated.cpp index 87a29e144..4a197d65d 100644 --- a/src/video_core/rasterizer_accelerated.cpp +++ b/src/video_core/rasterizer_accelerated.cpp | |||
| @@ -24,8 +24,8 @@ void RasterizerAccelerated::UpdatePagesCachedCount(VAddr addr, u64 size, int del | |||
| 24 | u64 cache_bytes = 0; | 24 | u64 cache_bytes = 0; |
| 25 | 25 | ||
| 26 | std::atomic_thread_fence(std::memory_order_acquire); | 26 | std::atomic_thread_fence(std::memory_order_acquire); |
| 27 | const u64 page_end = Common::DivCeil(addr + size, PAGE_SIZE); | 27 | const u64 page_end = Common::DivCeil(addr + size, YUZU_PAGESIZE); |
| 28 | for (u64 page = addr >> PAGE_BITS; page != page_end; ++page) { | 28 | for (u64 page = addr >> YUZU_PAGEBITS; page != page_end; ++page) { |
| 29 | std::atomic_uint16_t& count = cached_pages.at(page >> 2).Count(page); | 29 | std::atomic_uint16_t& count = cached_pages.at(page >> 2).Count(page); |
| 30 | 30 | ||
| 31 | if (delta > 0) { | 31 | if (delta > 0) { |
| @@ -44,26 +44,27 @@ void RasterizerAccelerated::UpdatePagesCachedCount(VAddr addr, u64 size, int del | |||
| 44 | if (uncache_bytes == 0) { | 44 | if (uncache_bytes == 0) { |
| 45 | uncache_begin = page; | 45 | uncache_begin = page; |
| 46 | } | 46 | } |
| 47 | uncache_bytes += PAGE_SIZE; | 47 | uncache_bytes += YUZU_PAGESIZE; |
| 48 | } else if (uncache_bytes > 0) { | 48 | } else if (uncache_bytes > 0) { |
| 49 | cpu_memory.RasterizerMarkRegionCached(uncache_begin << PAGE_BITS, uncache_bytes, false); | 49 | cpu_memory.RasterizerMarkRegionCached(uncache_begin << YUZU_PAGEBITS, uncache_bytes, |
| 50 | false); | ||
| 50 | uncache_bytes = 0; | 51 | uncache_bytes = 0; |
| 51 | } | 52 | } |
| 52 | if (count.load(std::memory_order::relaxed) == 1 && delta > 0) { | 53 | if (count.load(std::memory_order::relaxed) == 1 && delta > 0) { |
| 53 | if (cache_bytes == 0) { | 54 | if (cache_bytes == 0) { |
| 54 | cache_begin = page; | 55 | cache_begin = page; |
| 55 | } | 56 | } |
| 56 | cache_bytes += PAGE_SIZE; | 57 | cache_bytes += YUZU_PAGESIZE; |
| 57 | } else if (cache_bytes > 0) { | 58 | } else if (cache_bytes > 0) { |
| 58 | cpu_memory.RasterizerMarkRegionCached(cache_begin << PAGE_BITS, cache_bytes, true); | 59 | cpu_memory.RasterizerMarkRegionCached(cache_begin << YUZU_PAGEBITS, cache_bytes, true); |
| 59 | cache_bytes = 0; | 60 | cache_bytes = 0; |
| 60 | } | 61 | } |
| 61 | } | 62 | } |
| 62 | if (uncache_bytes > 0) { | 63 | if (uncache_bytes > 0) { |
| 63 | cpu_memory.RasterizerMarkRegionCached(uncache_begin << PAGE_BITS, uncache_bytes, false); | 64 | cpu_memory.RasterizerMarkRegionCached(uncache_begin << YUZU_PAGEBITS, uncache_bytes, false); |
| 64 | } | 65 | } |
| 65 | if (cache_bytes > 0) { | 66 | if (cache_bytes > 0) { |
| 66 | cpu_memory.RasterizerMarkRegionCached(cache_begin << PAGE_BITS, cache_bytes, true); | 67 | cpu_memory.RasterizerMarkRegionCached(cache_begin << YUZU_PAGEBITS, cache_bytes, true); |
| 67 | } | 68 | } |
| 68 | } | 69 | } |
| 69 | 70 | ||
diff --git a/src/video_core/shader_cache.cpp b/src/video_core/shader_cache.cpp index 4b1101f7c..164e4ee0e 100644 --- a/src/video_core/shader_cache.cpp +++ b/src/video_core/shader_cache.cpp | |||
| @@ -123,8 +123,8 @@ void ShaderCache::Register(std::unique_ptr<ShaderInfo> data, VAddr addr, size_t | |||
| 123 | const VAddr addr_end = addr + size; | 123 | const VAddr addr_end = addr + size; |
| 124 | Entry* const entry = NewEntry(addr, addr_end, data.get()); | 124 | Entry* const entry = NewEntry(addr, addr_end, data.get()); |
| 125 | 125 | ||
| 126 | const u64 page_end = (addr_end + PAGE_SIZE - 1) >> PAGE_BITS; | 126 | const u64 page_end = (addr_end + YUZU_PAGESIZE - 1) >> YUZU_PAGEBITS; |
| 127 | for (u64 page = addr >> PAGE_BITS; page < page_end; ++page) { | 127 | for (u64 page = addr >> YUZU_PAGEBITS; page < page_end; ++page) { |
| 128 | invalidation_cache[page].push_back(entry); | 128 | invalidation_cache[page].push_back(entry); |
| 129 | } | 129 | } |
| 130 | 130 | ||
| @@ -135,8 +135,8 @@ void ShaderCache::Register(std::unique_ptr<ShaderInfo> data, VAddr addr, size_t | |||
| 135 | 135 | ||
| 136 | void ShaderCache::InvalidatePagesInRegion(VAddr addr, size_t size) { | 136 | void ShaderCache::InvalidatePagesInRegion(VAddr addr, size_t size) { |
| 137 | const VAddr addr_end = addr + size; | 137 | const VAddr addr_end = addr + size; |
| 138 | const u64 page_end = (addr_end + PAGE_SIZE - 1) >> PAGE_BITS; | 138 | const u64 page_end = (addr_end + YUZU_PAGESIZE - 1) >> YUZU_PAGEBITS; |
| 139 | for (u64 page = addr >> PAGE_BITS; page < page_end; ++page) { | 139 | for (u64 page = addr >> YUZU_PAGEBITS; page < page_end; ++page) { |
| 140 | auto it = invalidation_cache.find(page); | 140 | auto it = invalidation_cache.find(page); |
| 141 | if (it == invalidation_cache.end()) { | 141 | if (it == invalidation_cache.end()) { |
| 142 | continue; | 142 | continue; |
| @@ -189,8 +189,8 @@ void ShaderCache::InvalidatePageEntries(std::vector<Entry*>& entries, VAddr addr | |||
| 189 | } | 189 | } |
| 190 | 190 | ||
| 191 | void ShaderCache::RemoveEntryFromInvalidationCache(const Entry* entry) { | 191 | void ShaderCache::RemoveEntryFromInvalidationCache(const Entry* entry) { |
| 192 | const u64 page_end = (entry->addr_end + PAGE_SIZE - 1) >> PAGE_BITS; | 192 | const u64 page_end = (entry->addr_end + YUZU_PAGESIZE - 1) >> YUZU_PAGEBITS; |
| 193 | for (u64 page = entry->addr_start >> PAGE_BITS; page < page_end; ++page) { | 193 | for (u64 page = entry->addr_start >> YUZU_PAGEBITS; page < page_end; ++page) { |
| 194 | const auto entries_it = invalidation_cache.find(page); | 194 | const auto entries_it = invalidation_cache.find(page); |
| 195 | ASSERT(entries_it != invalidation_cache.end()); | 195 | ASSERT(entries_it != invalidation_cache.end()); |
| 196 | std::vector<Entry*>& entries = entries_it->second; | 196 | std::vector<Entry*>& entries = entries_it->second; |
diff --git a/src/video_core/shader_cache.h b/src/video_core/shader_cache.h index 1109cfe83..f67cea8c4 100644 --- a/src/video_core/shader_cache.h +++ b/src/video_core/shader_cache.h | |||
| @@ -29,8 +29,8 @@ struct ShaderInfo { | |||
| 29 | }; | 29 | }; |
| 30 | 30 | ||
| 31 | class ShaderCache { | 31 | class ShaderCache { |
| 32 | static constexpr u64 PAGE_BITS = 14; | 32 | static constexpr u64 YUZU_PAGEBITS = 14; |
| 33 | static constexpr u64 PAGE_SIZE = u64(1) << PAGE_BITS; | 33 | static constexpr u64 YUZU_PAGESIZE = u64(1) << YUZU_PAGEBITS; |
| 34 | 34 | ||
| 35 | static constexpr size_t NUM_PROGRAMS = 6; | 35 | static constexpr size_t NUM_PROGRAMS = 6; |
| 36 | 36 | ||
diff --git a/src/video_core/texture_cache/texture_cache.h b/src/video_core/texture_cache/texture_cache.h index cf3ca06a6..1dbe01bc0 100644 --- a/src/video_core/texture_cache/texture_cache.h +++ b/src/video_core/texture_cache/texture_cache.h | |||
| @@ -589,7 +589,7 @@ void TextureCache<P>::BlitImage(const Tegra::Engines::Fermi2D::Surface& dst, | |||
| 589 | template <class P> | 589 | template <class P> |
| 590 | typename P::ImageView* TextureCache<P>::TryFindFramebufferImageView(VAddr cpu_addr) { | 590 | typename P::ImageView* TextureCache<P>::TryFindFramebufferImageView(VAddr cpu_addr) { |
| 591 | // TODO: Properly implement this | 591 | // TODO: Properly implement this |
| 592 | const auto it = page_table.find(cpu_addr >> PAGE_BITS); | 592 | const auto it = page_table.find(cpu_addr >> YUZU_PAGEBITS); |
| 593 | if (it == page_table.end()) { | 593 | if (it == page_table.end()) { |
| 594 | return nullptr; | 594 | return nullptr; |
| 595 | } | 595 | } |
| @@ -1485,14 +1485,14 @@ void TextureCache<P>::UnregisterImage(ImageId image_id) { | |||
| 1485 | std::unordered_map<u64, std::vector<ImageId>, IdentityHash<u64>>& selected_page_table) { | 1485 | std::unordered_map<u64, std::vector<ImageId>, IdentityHash<u64>>& selected_page_table) { |
| 1486 | const auto page_it = selected_page_table.find(page); | 1486 | const auto page_it = selected_page_table.find(page); |
| 1487 | if (page_it == selected_page_table.end()) { | 1487 | if (page_it == selected_page_table.end()) { |
| 1488 | ASSERT_MSG(false, "Unregistering unregistered page=0x{:x}", page << PAGE_BITS); | 1488 | ASSERT_MSG(false, "Unregistering unregistered page=0x{:x}", page << YUZU_PAGEBITS); |
| 1489 | return; | 1489 | return; |
| 1490 | } | 1490 | } |
| 1491 | std::vector<ImageId>& image_ids = page_it->second; | 1491 | std::vector<ImageId>& image_ids = page_it->second; |
| 1492 | const auto vector_it = std::ranges::find(image_ids, image_id); | 1492 | const auto vector_it = std::ranges::find(image_ids, image_id); |
| 1493 | if (vector_it == image_ids.end()) { | 1493 | if (vector_it == image_ids.end()) { |
| 1494 | ASSERT_MSG(false, "Unregistering unregistered image in page=0x{:x}", | 1494 | ASSERT_MSG(false, "Unregistering unregistered image in page=0x{:x}", |
| 1495 | page << PAGE_BITS); | 1495 | page << YUZU_PAGEBITS); |
| 1496 | return; | 1496 | return; |
| 1497 | } | 1497 | } |
| 1498 | image_ids.erase(vector_it); | 1498 | image_ids.erase(vector_it); |
| @@ -1504,14 +1504,14 @@ void TextureCache<P>::UnregisterImage(ImageId image_id) { | |||
| 1504 | ForEachCPUPage(image.cpu_addr, image.guest_size_bytes, [this, map_id](u64 page) { | 1504 | ForEachCPUPage(image.cpu_addr, image.guest_size_bytes, [this, map_id](u64 page) { |
| 1505 | const auto page_it = page_table.find(page); | 1505 | const auto page_it = page_table.find(page); |
| 1506 | if (page_it == page_table.end()) { | 1506 | if (page_it == page_table.end()) { |
| 1507 | ASSERT_MSG(false, "Unregistering unregistered page=0x{:x}", page << PAGE_BITS); | 1507 | ASSERT_MSG(false, "Unregistering unregistered page=0x{:x}", page << YUZU_PAGEBITS); |
| 1508 | return; | 1508 | return; |
| 1509 | } | 1509 | } |
| 1510 | std::vector<ImageMapId>& image_map_ids = page_it->second; | 1510 | std::vector<ImageMapId>& image_map_ids = page_it->second; |
| 1511 | const auto vector_it = std::ranges::find(image_map_ids, map_id); | 1511 | const auto vector_it = std::ranges::find(image_map_ids, map_id); |
| 1512 | if (vector_it == image_map_ids.end()) { | 1512 | if (vector_it == image_map_ids.end()) { |
| 1513 | ASSERT_MSG(false, "Unregistering unregistered image in page=0x{:x}", | 1513 | ASSERT_MSG(false, "Unregistering unregistered image in page=0x{:x}", |
| 1514 | page << PAGE_BITS); | 1514 | page << YUZU_PAGEBITS); |
| 1515 | return; | 1515 | return; |
| 1516 | } | 1516 | } |
| 1517 | image_map_ids.erase(vector_it); | 1517 | image_map_ids.erase(vector_it); |
| @@ -1532,7 +1532,7 @@ void TextureCache<P>::UnregisterImage(ImageId image_id) { | |||
| 1532 | ForEachCPUPage(cpu_addr, size, [this, image_id](u64 page) { | 1532 | ForEachCPUPage(cpu_addr, size, [this, image_id](u64 page) { |
| 1533 | const auto page_it = page_table.find(page); | 1533 | const auto page_it = page_table.find(page); |
| 1534 | if (page_it == page_table.end()) { | 1534 | if (page_it == page_table.end()) { |
| 1535 | ASSERT_MSG(false, "Unregistering unregistered page=0x{:x}", page << PAGE_BITS); | 1535 | ASSERT_MSG(false, "Unregistering unregistered page=0x{:x}", page << YUZU_PAGEBITS); |
| 1536 | return; | 1536 | return; |
| 1537 | } | 1537 | } |
| 1538 | std::vector<ImageMapId>& image_map_ids = page_it->second; | 1538 | std::vector<ImageMapId>& image_map_ids = page_it->second; |
diff --git a/src/video_core/texture_cache/texture_cache_base.h b/src/video_core/texture_cache/texture_cache_base.h index e2f8f84c9..7e6c6cef2 100644 --- a/src/video_core/texture_cache/texture_cache_base.h +++ b/src/video_core/texture_cache/texture_cache_base.h | |||
| @@ -47,7 +47,7 @@ struct ImageViewInOut { | |||
| 47 | template <class P> | 47 | template <class P> |
| 48 | class TextureCache { | 48 | class TextureCache { |
| 49 | /// Address shift for caching images into a hash table | 49 | /// Address shift for caching images into a hash table |
| 50 | static constexpr u64 PAGE_BITS = 20; | 50 | static constexpr u64 YUZU_PAGEBITS = 20; |
| 51 | 51 | ||
| 52 | /// Enables debugging features to the texture cache | 52 | /// Enables debugging features to the texture cache |
| 53 | static constexpr bool ENABLE_VALIDATION = P::ENABLE_VALIDATION; | 53 | static constexpr bool ENABLE_VALIDATION = P::ENABLE_VALIDATION; |
| @@ -178,8 +178,8 @@ private: | |||
| 178 | template <typename Func> | 178 | template <typename Func> |
| 179 | static void ForEachCPUPage(VAddr addr, size_t size, Func&& func) { | 179 | static void ForEachCPUPage(VAddr addr, size_t size, Func&& func) { |
| 180 | static constexpr bool RETURNS_BOOL = std::is_same_v<std::invoke_result<Func, u64>, bool>; | 180 | static constexpr bool RETURNS_BOOL = std::is_same_v<std::invoke_result<Func, u64>, bool>; |
| 181 | const u64 page_end = (addr + size - 1) >> PAGE_BITS; | 181 | const u64 page_end = (addr + size - 1) >> YUZU_PAGEBITS; |
| 182 | for (u64 page = addr >> PAGE_BITS; page <= page_end; ++page) { | 182 | for (u64 page = addr >> YUZU_PAGEBITS; page <= page_end; ++page) { |
| 183 | if constexpr (RETURNS_BOOL) { | 183 | if constexpr (RETURNS_BOOL) { |
| 184 | if (func(page)) { | 184 | if (func(page)) { |
| 185 | break; | 185 | break; |
| @@ -193,8 +193,8 @@ private: | |||
| 193 | template <typename Func> | 193 | template <typename Func> |
| 194 | static void ForEachGPUPage(GPUVAddr addr, size_t size, Func&& func) { | 194 | static void ForEachGPUPage(GPUVAddr addr, size_t size, Func&& func) { |
| 195 | static constexpr bool RETURNS_BOOL = std::is_same_v<std::invoke_result<Func, u64>, bool>; | 195 | static constexpr bool RETURNS_BOOL = std::is_same_v<std::invoke_result<Func, u64>, bool>; |
| 196 | const u64 page_end = (addr + size - 1) >> PAGE_BITS; | 196 | const u64 page_end = (addr + size - 1) >> YUZU_PAGEBITS; |
| 197 | for (u64 page = addr >> PAGE_BITS; page <= page_end; ++page) { | 197 | for (u64 page = addr >> YUZU_PAGEBITS; page <= page_end; ++page) { |
| 198 | if constexpr (RETURNS_BOOL) { | 198 | if constexpr (RETURNS_BOOL) { |
| 199 | if (func(page)) { | 199 | if (func(page)) { |
| 200 | break; | 200 | break; |