From ec391a47395fdc433c3b25a54af2fcc1264b89ec Mon Sep 17 00:00:00 2001 From: Lander Gallastegi Date: Sat, 17 May 2025 20:49:21 +0200 Subject: [PATCH] Added profiling (will be removed) --- src/video_core/buffer_cache/memory_tracker_base.h | 2 ++ src/video_core/buffer_cache/word_manager.h | 7 +++++++ src/video_core/page_manager.cpp | 4 ++++ 3 files changed, 13 insertions(+) diff --git a/src/video_core/buffer_cache/memory_tracker_base.h b/src/video_core/buffer_cache/memory_tracker_base.h index 410b2c69d..c60aa9c80 100644 --- a/src/video_core/buffer_cache/memory_tracker_base.h +++ b/src/video_core/buffer_cache/memory_tracker_base.h @@ -7,6 +7,7 @@ #include #include #include +#include "common/debug.h" #include "common/types.h" #include "video_core/buffer_cache/word_manager.h" @@ -85,6 +86,7 @@ private: */ template bool IteratePages(VAddr cpu_address, size_t size, Func&& func) { + RENDERER_TRACE; using FuncReturn = typename std::invoke_result::type; static constexpr bool BOOL_BREAK = std::is_same_v; std::size_t remaining_size{size}; diff --git a/src/video_core/buffer_cache/word_manager.h b/src/video_core/buffer_cache/word_manager.h index e912b4f79..51a912c62 100644 --- a/src/video_core/buffer_cache/word_manager.h +++ b/src/video_core/buffer_cache/word_manager.h @@ -13,6 +13,7 @@ #else #include "common/spin_lock.h" #endif +#include "common/debug.h" #include "common/types.h" #include "video_core/page_manager.h" @@ -74,6 +75,7 @@ public: template void IterateWords(size_t offset, size_t size, Func&& func) const { + RENDERER_TRACE; using FuncReturn = std::invoke_result_t; static constexpr bool BOOL_BREAK = std::is_same_v; const size_t start = static_cast(std::max(static_cast(offset), 0LL)); @@ -106,6 +108,7 @@ public: } void IteratePages(u64 mask, auto&& func) const { + RENDERER_TRACE; size_t offset = 0; while (mask != 0) { const size_t empty_bits = std::countr_zero(mask); @@ -157,6 +160,7 @@ public: */ template void ForEachModifiedRange(VAddr query_cpu_range, s64 size, auto&& func) { + RENDERER_TRACE; std::scoped_lock lk{lock}; static_assert(type != Type::Untracked); @@ -170,6 +174,7 @@ public: (pending_pointer - pending_offset) * BYTES_PER_PAGE); }; IterateWords(offset, size, [&](size_t index, u64 mask) { + RENDERER_TRACE; if constexpr (type == Type::GPU) { mask &= ~untracked[index]; } @@ -183,6 +188,7 @@ public: } const size_t base_offset = index * PAGES_PER_WORD; IteratePages(word, [&](size_t pages_offset, size_t pages_size) { + RENDERER_TRACE; const auto reset = [&]() { pending_offset = base_offset + pages_offset; pending_pointer = base_offset + pages_offset + pages_size; @@ -243,6 +249,7 @@ private: */ template void UpdateProtection(u64 word_index, u64 current_bits, u64 new_bits) const { + RENDERER_TRACE; constexpr s32 delta = add_to_tracker ? 1 : -1; u64 changed_bits = (add_to_tracker ? current_bits : ~current_bits) & new_bits; VAddr addr = cpu_addr + word_index * BYTES_PER_WORD; diff --git a/src/video_core/page_manager.cpp b/src/video_core/page_manager.cpp index 172c9f848..36145d0c5 100644 --- a/src/video_core/page_manager.cpp +++ b/src/video_core/page_manager.cpp @@ -3,6 +3,7 @@ #include #include "common/assert.h" +#include "common/debug.h" #include "common/signal_context.h" #include "core/memory.h" #include "core/signals.h" @@ -174,6 +175,7 @@ struct PageManager::Impl { } void Protect(VAddr address, size_t size, Core::MemoryPermission perms) { + RENDERER_TRACE; auto* memory = Core::Memory::Instance(); auto& impl = memory->GetAddressSpace(); impl.Protect(address, size, perms); @@ -190,6 +192,7 @@ struct PageManager::Impl { #endif template void UpdatePageWatchers(VAddr addr, u64 size) { + RENDERER_TRACE; boost::container::small_vector update_ranges; { std::scoped_lock lk(lock); @@ -201,6 +204,7 @@ struct PageManager::Impl { const auto release_pending = [&] { if (range_bytes > 0) { + RENDERER_TRACE; // Add pending (un)protect action update_ranges.push_back({range_begin << PAGE_BITS, range_bytes, perms}); range_bytes = 0;