diff options
Diffstat (limited to 'src/core/cpu_manager.h')
-rw-r--r-- | src/core/cpu_manager.h | 55 |
1 files changed, 27 insertions, 28 deletions
diff --git a/src/core/cpu_manager.h b/src/core/cpu_manager.h index 9d92d4af0..95ea3ef39 100644 --- a/src/core/cpu_manager.h +++ b/src/core/cpu_manager.h @@ -1,6 +1,5 @@ -// Copyright 2018 yuzu emulator team -// Licensed under GPLv2 or any later version -// Refer to the license.txt file included. +// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later #pragma once @@ -44,15 +43,25 @@ public: is_async_gpu = is_async; } + void OnGpuReady() { + gpu_barrier->Sync(); + } + void Initialize(); void Shutdown(); - void Pause(bool paused); - - static std::function<void(void*)> GetGuestThreadStartFunc(); - static std::function<void(void*)> GetIdleThreadStartFunc(); - static std::function<void(void*)> GetSuspendThreadStartFunc(); - void* GetStartFuncParamater(); + std::function<void()> GetGuestActivateFunc() { + return [this] { GuestActivate(); }; + } + std::function<void()> GetGuestThreadFunc() { + return [this] { GuestThreadFunction(); }; + } + std::function<void()> GetIdleThreadStartFunc() { + return [this] { IdleThreadFunction(); }; + } + std::function<void()> GetShutdownThreadStartFunc() { + return [this] { ShutdownThreadFunction(); }; + } void PreemptSingleCore(bool from_running_enviroment = true); @@ -61,46 +70,36 @@ public: } private: - static void GuestThreadFunction(void* cpu_manager); - static void GuestRewindFunction(void* cpu_manager); - static void IdleThreadFunction(void* cpu_manager); - static void SuspendThreadFunction(void* cpu_manager); + void GuestThreadFunction(); + void IdleThreadFunction(); + void ShutdownThreadFunction(); void MultiCoreRunGuestThread(); - void MultiCoreRunGuestLoop(); void MultiCoreRunIdleThread(); - void MultiCoreRunSuspendThread(); - void MultiCorePause(bool paused); void SingleCoreRunGuestThread(); - void SingleCoreRunGuestLoop(); void SingleCoreRunIdleThread(); - void SingleCoreRunSuspendThread(); - void SingleCorePause(bool paused); static void ThreadStart(std::stop_token stop_token, CpuManager& cpu_manager, std::size_t core); - void RunThread(std::stop_token stop_token, std::size_t core); + void GuestActivate(); + void HandleInterrupt(); + void ShutdownThread(); + void RunThread(std::size_t core); struct CoreData { std::shared_ptr<Common::Fiber> host_context; - std::unique_ptr<Common::Event> enter_barrier; - std::unique_ptr<Common::Event> exit_barrier; - std::atomic<bool> is_running; - std::atomic<bool> is_paused; - std::atomic<bool> initialized; std::jthread host_thread; }; - std::atomic<bool> running_mode{}; - std::atomic<bool> paused_state{}; - + std::unique_ptr<Common::Barrier> gpu_barrier{}; std::array<CoreData, Core::Hardware::NUM_CPU_CORES> core_data{}; bool is_async_gpu{}; bool is_multicore{}; std::atomic<std::size_t> current_core{}; std::size_t idle_count{}; + std::size_t num_cores{}; static constexpr std::size_t max_cycle_runs = 5; System& system; |