From 0afce53e5f110acea5451260dbabf12670696daa Mon Sep 17 00:00:00 2001 From: Gamer64 <76565986+Gamer64ytb@users.noreply.github.com> Date: Sat, 2 Aug 2025 04:04:39 +0200 Subject: [PATCH] Add more microprofile checks Thanks yuzu for spamming microprofile --- src/core/core.cpp | 8 ++++++++ src/core/core_timing.cpp | 4 ++++ src/core/cpu_manager.cpp | 4 ++++ src/yuzu_cmd/yuzu.cpp | 2 ++ 4 files changed, 18 insertions(+) diff --git a/src/core/core.cpp b/src/core/core.cpp index ae184f8a88..65a69d078c 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -289,10 +289,12 @@ struct System::Impl { exit_locked = false; exit_requested = false; +#if MICROPROFILE_ENABLED microprofile_cpu[0] = MICROPROFILE_TOKEN(ARM_CPU0); microprofile_cpu[1] = MICROPROFILE_TOKEN(ARM_CPU1); microprofile_cpu[2] = MICROPROFILE_TOKEN(ARM_CPU2); microprofile_cpu[3] = MICROPROFILE_TOKEN(ARM_CPU3); +#endif if (Settings::values.enable_renderdoc_hotkey) { renderdoc_api = std::make_unique(); @@ -573,7 +575,9 @@ struct System::Impl { std::stop_source stop_event; std::array dynarmic_ticks{}; +#if MICROPROFILE_ENABLED std::array microprofile_cpu{}; +#endif std::array gpu_dirty_memory_managers; @@ -953,13 +957,17 @@ void System::RegisterHostThread() { } void System::EnterCPUProfile() { +#if MICROPROFILE_ENABLED std::size_t core = impl->kernel.GetCurrentHostThreadID(); impl->dynarmic_ticks[core] = MicroProfileEnter(impl->microprofile_cpu[core]); +#endif } void System::ExitCPUProfile() { +#if MICROPROFILE_ENABLED std::size_t core = impl->kernel.GetCurrentHostThreadID(); MicroProfileLeave(impl->microprofile_cpu[core], impl->dynarmic_ticks[core]); +#endif } bool System::IsMulticore() const { diff --git a/src/core/core_timing.cpp b/src/core/core_timing.cpp index ed07e80ce2..b1a1247b44 100644 --- a/src/core/core_timing.cpp +++ b/src/core/core_timing.cpp @@ -56,12 +56,16 @@ CoreTiming::~CoreTiming() { void CoreTiming::ThreadEntry(CoreTiming& instance) { static constexpr char name[] = "HostTiming"; +#if MICROPROFILE_ENABLED MicroProfileOnThreadCreate(name); +#endif Common::SetCurrentThreadName(name); Common::SetCurrentThreadPriority(Common::ThreadPriority::High); instance.on_thread_init(); instance.ThreadLoop(); +#if MICROPROFILE_ENABLED MicroProfileOnThreadExit(); +#endif } void CoreTiming::Initialize(std::function&& on_thread_init_) { diff --git a/src/core/cpu_manager.cpp b/src/core/cpu_manager.cpp index 9b1c773877..1ee4e96002 100644 --- a/src/core/cpu_manager.cpp +++ b/src/core/cpu_manager.cpp @@ -192,7 +192,9 @@ void CpuManager::RunThread(std::stop_token token, std::size_t core) { } else { name = "CPUThread"; } +#if MICROPROFILE_ENABLED MicroProfileOnThreadCreate(name.c_str()); +#endif Common::SetCurrentThreadName(name.c_str()); Common::SetCurrentThreadPriority(Common::ThreadPriority::Critical); auto& data = core_data[core]; @@ -201,7 +203,9 @@ void CpuManager::RunThread(std::stop_token token, std::size_t core) { // Cleanup SCOPE_EXIT { data.host_context->Exit(); +#if MICROPROFILE_ENABLED MicroProfileOnThreadExit(); +#endif }; // Running diff --git a/src/yuzu_cmd/yuzu.cpp b/src/yuzu_cmd/yuzu.cpp index 79f01704d0..6acf7c0ace 100644 --- a/src/yuzu_cmd/yuzu.cpp +++ b/src/yuzu_cmd/yuzu.cpp @@ -335,10 +335,12 @@ int main(int argc, char** argv) { LocalFree(argv_w); #endif +#if MICROPROFILE_ENABLED MicroProfileOnThreadCreate("EmuThread"); SCOPE_EXIT { MicroProfileShutdown(); }; +#endif Common::ConfigureNvidiaEnvironmentFlags();