mirror of
https://git.eden-emu.dev/eden-emu/eden.git
synced 2025-10-12 00:47:49 +00:00
Add cmake option to enable microprofile (#179)
Backported from dd9c743041
.
Co-authored-by: PabloMK7 <hackyglitch2@gmail.com>
Co-authored-by: Shinmegumi <shinmegumi@eden-emu.dev>
Co-authored-by: Gamer64 <76565986+Gamer64ytb@users.noreply.github.com>
Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/179
Co-authored-by: Gamer64 <gamer64@eden-emu.dev>
Co-committed-by: Gamer64 <gamer64@eden-emu.dev>
This commit is contained in:
parent
b32a667d6f
commit
1f34d836b4
17 changed files with 64 additions and 11 deletions
|
@ -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<Tools::RenderdocAPI>();
|
||||
|
@ -573,7 +575,9 @@ struct System::Impl {
|
|||
std::stop_source stop_event;
|
||||
|
||||
std::array<u64, Core::Hardware::NUM_CPU_CORES> dynarmic_ticks{};
|
||||
#if MICROPROFILE_ENABLED
|
||||
std::array<MicroProfileToken, Core::Hardware::NUM_CPU_CORES> microprofile_cpu{};
|
||||
#endif
|
||||
|
||||
std::array<Core::GPUDirtyMemoryManager, Core::Hardware::NUM_CPU_CORES>
|
||||
gpu_dirty_memory_managers;
|
||||
|
@ -952,6 +956,7 @@ void System::RegisterHostThread() {
|
|||
impl->kernel.RegisterHostThread();
|
||||
}
|
||||
|
||||
#if MICROPROFILE_ENABLED
|
||||
void System::EnterCPUProfile() {
|
||||
std::size_t core = impl->kernel.GetCurrentHostThreadID();
|
||||
impl->dynarmic_ticks[core] = MicroProfileEnter(impl->microprofile_cpu[core]);
|
||||
|
@ -961,6 +966,7 @@ void System::ExitCPUProfile() {
|
|||
std::size_t core = impl->kernel.GetCurrentHostThreadID();
|
||||
MicroProfileLeave(impl->microprofile_cpu[core], impl->dynarmic_ticks[core]);
|
||||
}
|
||||
#endif
|
||||
|
||||
bool System::IsMulticore() const {
|
||||
return impl->is_multicore;
|
||||
|
|
|
@ -396,11 +396,13 @@ public:
|
|||
/// Register a host thread as an auxiliary thread.
|
||||
void RegisterHostThread();
|
||||
|
||||
#if MICROPROFILE_ENABLED
|
||||
/// Enter CPU Microprofile
|
||||
void EnterCPUProfile();
|
||||
|
||||
/// Exit CPU Microprofile
|
||||
void ExitCPUProfile();
|
||||
#endif
|
||||
|
||||
/// Tells if system is running on multicore.
|
||||
[[nodiscard]] bool IsMulticore() const;
|
||||
|
|
|
@ -61,7 +61,9 @@ void CoreTiming::ThreadEntry(CoreTiming& instance) {
|
|||
Common::SetCurrentThreadPriority(Common::ThreadPriority::High);
|
||||
instance.on_thread_init();
|
||||
instance.ThreadLoop();
|
||||
#if MICROPROFILE_ENABLED
|
||||
MicroProfileOnThreadExit();
|
||||
#endif
|
||||
}
|
||||
|
||||
void CoreTiming::Initialize(std::function<void()>&& on_thread_init_) {
|
||||
|
|
|
@ -201,7 +201,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
|
||||
|
|
|
@ -1278,6 +1278,7 @@ void KernelCore::ExceptionalExitApplication() {
|
|||
SuspendEmulation(true);
|
||||
}
|
||||
|
||||
#if MICROPROFILE_ENABLED
|
||||
void KernelCore::EnterSVCProfile() {
|
||||
impl->svc_ticks[CurrentPhysicalCoreIndex()] = MicroProfileEnter(MICROPROFILE_TOKEN(Kernel_SVC));
|
||||
}
|
||||
|
@ -1285,6 +1286,7 @@ void KernelCore::EnterSVCProfile() {
|
|||
void KernelCore::ExitSVCProfile() {
|
||||
MicroProfileLeave(MICROPROFILE_TOKEN(Kernel_SVC), impl->svc_ticks[CurrentPhysicalCoreIndex()]);
|
||||
}
|
||||
#endif
|
||||
|
||||
Init::KSlabResourceCounts& KernelCore::SlabResourceCounts() {
|
||||
return impl->slab_resource_counts;
|
||||
|
|
|
@ -271,9 +271,11 @@ public:
|
|||
|
||||
bool IsShuttingDown() const;
|
||||
|
||||
#if MICROPROFILE_ENABLED
|
||||
void EnterSVCProfile();
|
||||
|
||||
void ExitSVCProfile();
|
||||
#endif
|
||||
|
||||
/// Workaround for single-core mode when preempting threads while idle.
|
||||
bool IsPhantomModeForSingleCore() const;
|
||||
|
|
|
@ -27,7 +27,9 @@ void PhysicalCore::RunThread(Kernel::KThread* thread) {
|
|||
interface->Initialize();
|
||||
|
||||
const auto EnterContext = [&]() {
|
||||
#if MICROPROFILE_ENABLED
|
||||
system.EnterCPUProfile();
|
||||
#endif
|
||||
|
||||
// Lock the core context.
|
||||
std::scoped_lock lk{m_guard};
|
||||
|
@ -59,7 +61,9 @@ void PhysicalCore::RunThread(Kernel::KThread* thread) {
|
|||
m_arm_interface = nullptr;
|
||||
m_current_thread = nullptr;
|
||||
|
||||
#if MICROPROFILE_ENABLED
|
||||
system.ExitCPUProfile();
|
||||
#endif
|
||||
};
|
||||
|
||||
while (true) {
|
||||
|
|
|
@ -4428,7 +4428,9 @@ void Call(Core::System& system, u32 imm) {
|
|||
|
||||
std::array<uint64_t, 8> args;
|
||||
kernel.CurrentPhysicalCore().SaveSvcArguments(process, args);
|
||||
#if MICROPROFILE_ENABLED
|
||||
kernel.EnterSVCProfile();
|
||||
#endif
|
||||
|
||||
if (process.Is64Bit()) {
|
||||
Call64(system, imm, args);
|
||||
|
@ -4436,7 +4438,9 @@ void Call(Core::System& system, u32 imm) {
|
|||
Call32(system, imm, args);
|
||||
}
|
||||
|
||||
#if MICROPROFILE_ENABLED
|
||||
kernel.ExitSVCProfile();
|
||||
#endif
|
||||
kernel.CurrentPhysicalCore().LoadSvcArguments(process, args);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue