diff options
author | Fernando Sahmkow <fsahmkow27@gmail.com> | 2022-10-21 01:46:51 +0200 |
---|---|---|
committer | Fernando Sahmkow <fsahmkow27@gmail.com> | 2023-01-01 22:43:57 +0100 |
commit | 93ac5a6a6d316966c1d288f8b83610bb48143a04 (patch) | |
tree | de24cc21ecb8b49d60d63356f18de6324be4cb38 /src/video_core/memory_manager.cpp | |
parent | MacroHLE: Refactor MacroHLE system. (diff) | |
download | yuzu-93ac5a6a6d316966c1d288f8b83610bb48143a04.tar yuzu-93ac5a6a6d316966c1d288f8b83610bb48143a04.tar.gz yuzu-93ac5a6a6d316966c1d288f8b83610bb48143a04.tar.bz2 yuzu-93ac5a6a6d316966c1d288f8b83610bb48143a04.tar.lz yuzu-93ac5a6a6d316966c1d288f8b83610bb48143a04.tar.xz yuzu-93ac5a6a6d316966c1d288f8b83610bb48143a04.tar.zst yuzu-93ac5a6a6d316966c1d288f8b83610bb48143a04.zip |
Diffstat (limited to '')
-rw-r--r-- | src/video_core/memory_manager.cpp | 53 |
1 files changed, 50 insertions, 3 deletions
diff --git a/src/video_core/memory_manager.cpp b/src/video_core/memory_manager.cpp index 8c8dfcca6..8f6c51045 100644 --- a/src/video_core/memory_manager.cpp +++ b/src/video_core/memory_manager.cpp @@ -325,9 +325,15 @@ template <bool is_big_pages, typename FuncMapped, typename FuncReserved, typenam inline void MemoryManager::MemoryOperation(GPUVAddr gpu_src_addr, std::size_t size, FuncMapped&& func_mapped, FuncReserved&& func_reserved, FuncUnmapped&& func_unmapped) const { - static constexpr bool BOOL_BREAK_MAPPED = std::is_same_v<FuncMapped, bool>; - static constexpr bool BOOL_BREAK_RESERVED = std::is_same_v<FuncReserved, bool>; - static constexpr bool BOOL_BREAK_UNMAPPED = std::is_same_v<FuncUnmapped, bool>; + using FuncMappedReturn = + typename std::invoke_result<FuncMapped, std::size_t, std::size_t, std::size_t>::type; + using FuncReservedReturn = + typename std::invoke_result<FuncReserved, std::size_t, std::size_t, std::size_t>::type; + using FuncUnmappedReturn = + typename std::invoke_result<FuncUnmapped, std::size_t, std::size_t, std::size_t>::type; + static constexpr bool BOOL_BREAK_MAPPED = std::is_same_v<FuncMappedReturn, bool>; + static constexpr bool BOOL_BREAK_RESERVED = std::is_same_v<FuncReservedReturn, bool>; + static constexpr bool BOOL_BREAK_UNMAPPED = std::is_same_v<FuncUnmappedReturn, bool>; u64 used_page_size; u64 used_page_mask; u64 used_page_bits; @@ -571,6 +577,47 @@ size_t MemoryManager::MaxContinousRange(GPUVAddr gpu_addr, size_t size) const { return range_so_far; } +size_t MemoryManager::GetMemoryLayoutSize(GPUVAddr gpu_addr) const { + PTEKind base_kind = GetPageKind(gpu_addr); + if (base_kind == PTEKind::INVALID) { + return 0; + } + size_t range_so_far = 0; + bool result{false}; + auto fail = [&]([[maybe_unused]] std::size_t page_index, [[maybe_unused]] std::size_t offset, + std::size_t copy_amount) { + result = true; + return true; + }; + auto short_check = [&](std::size_t page_index, std::size_t offset, std::size_t copy_amount) { + PTEKind base_kind_other = GetKind<false>((page_index << page_bits) + offset); + if (base_kind != base_kind_other) { + result = true; + return true; + } + range_so_far += copy_amount; + return false; + }; + auto big_check = [&](std::size_t page_index, std::size_t offset, std::size_t copy_amount) { + PTEKind base_kind_other = GetKind<true>((page_index << big_page_bits) + offset); + if (base_kind != base_kind_other) { + result = true; + return true; + } + range_so_far += copy_amount; + return false; + }; + auto check_short_pages = [&](std::size_t page_index, std::size_t offset, + std::size_t copy_amount) { + GPUVAddr base = (page_index << big_page_bits) + offset; + MemoryOperation<false>(base, copy_amount, short_check, fail, fail); + return result; + }; + MemoryOperation<true>(gpu_addr, address_space_size - gpu_addr, big_check, fail, + check_short_pages); + return range_so_far; +} + void MemoryManager::InvalidateRegion(GPUVAddr gpu_addr, size_t size) const { auto do_nothing = [&]([[maybe_unused]] std::size_t page_index, [[maybe_unused]] std::size_t offset, |