diff options
| -rw-r--r-- | src/core/core.cpp | 3 | ||||
| -rw-r--r-- | src/core/cpu_manager.cpp | 11 | ||||
| -rw-r--r-- | src/core/cpu_manager.h | 7 | ||||
| -rw-r--r-- | src/video_core/gpu.h | 6 | ||||
| -rw-r--r-- | src/video_core/gpu_asynch.cpp | 9 | ||||
| -rw-r--r-- | src/video_core/gpu_asynch.h | 2 | ||||
| -rw-r--r-- | src/video_core/gpu_synch.cpp | 8 | ||||
| -rw-r--r-- | src/video_core/gpu_synch.h | 2 | ||||
| -rw-r--r-- | src/yuzu/bootmanager.cpp | 29 |
9 files changed, 45 insertions, 32 deletions
diff --git a/src/core/core.cpp b/src/core/core.cpp index 40eea297e..3393c33eb 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp | |||
| @@ -151,7 +151,6 @@ struct System::Impl { | |||
| 151 | cpu_manager.SetMulticore(is_multicore); | 151 | cpu_manager.SetMulticore(is_multicore); |
| 152 | cpu_manager.SetAsyncGpu(is_async_gpu); | 152 | cpu_manager.SetAsyncGpu(is_async_gpu); |
| 153 | core_timing.SetMulticore(is_multicore); | 153 | core_timing.SetMulticore(is_multicore); |
| 154 | cpu_manager.SetRenderWindow(emu_window); | ||
| 155 | 154 | ||
| 156 | core_timing.Initialize([&system]() { system.RegisterHostThread(); }); | 155 | core_timing.Initialize([&system]() { system.RegisterHostThread(); }); |
| 157 | kernel.Initialize(); | 156 | kernel.Initialize(); |
| @@ -435,7 +434,7 @@ bool System::IsPoweredOn() const { | |||
| 435 | } | 434 | } |
| 436 | 435 | ||
| 437 | void System::PrepareReschedule() { | 436 | void System::PrepareReschedule() { |
| 438 | //impl->CurrentPhysicalCore().Stop(); | 437 | // impl->CurrentPhysicalCore().Stop(); |
| 439 | } | 438 | } |
| 440 | 439 | ||
| 441 | void System::PrepareReschedule(const u32 core_index) { | 440 | void System::PrepareReschedule(const u32 core_index) { |
diff --git a/src/core/cpu_manager.cpp b/src/core/cpu_manager.cpp index b7c2a7832..63c578852 100644 --- a/src/core/cpu_manager.cpp +++ b/src/core/cpu_manager.cpp | |||
| @@ -9,12 +9,12 @@ | |||
| 9 | #include "core/core.h" | 9 | #include "core/core.h" |
| 10 | #include "core/core_timing.h" | 10 | #include "core/core_timing.h" |
| 11 | #include "core/cpu_manager.h" | 11 | #include "core/cpu_manager.h" |
| 12 | #include "core/frontend/emu_window.h" | ||
| 13 | #include "core/gdbstub/gdbstub.h" | 12 | #include "core/gdbstub/gdbstub.h" |
| 14 | #include "core/hle/kernel/kernel.h" | 13 | #include "core/hle/kernel/kernel.h" |
| 15 | #include "core/hle/kernel/physical_core.h" | 14 | #include "core/hle/kernel/physical_core.h" |
| 16 | #include "core/hle/kernel/scheduler.h" | 15 | #include "core/hle/kernel/scheduler.h" |
| 17 | #include "core/hle/kernel/thread.h" | 16 | #include "core/hle/kernel/thread.h" |
| 17 | #include "video_core/gpu.h" | ||
| 18 | 18 | ||
| 19 | namespace Core { | 19 | namespace Core { |
| 20 | 20 | ||
| @@ -25,10 +25,6 @@ void CpuManager::ThreadStart(CpuManager& cpu_manager, std::size_t core) { | |||
| 25 | cpu_manager.RunThread(core); | 25 | cpu_manager.RunThread(core); |
| 26 | } | 26 | } |
| 27 | 27 | ||
| 28 | void CpuManager::SetRenderWindow(Core::Frontend::EmuWindow& render_window) { | ||
| 29 | this->render_window = &render_window; | ||
| 30 | } | ||
| 31 | |||
| 32 | void CpuManager::Initialize() { | 28 | void CpuManager::Initialize() { |
| 33 | running_mode = true; | 29 | running_mode = true; |
| 34 | if (is_multicore) { | 30 | if (is_multicore) { |
| @@ -354,7 +350,7 @@ void CpuManager::RunThread(std::size_t core) { | |||
| 354 | data.is_running = false; | 350 | data.is_running = false; |
| 355 | data.enter_barrier->Wait(); | 351 | data.enter_barrier->Wait(); |
| 356 | if (sc_sync_first_use) { | 352 | if (sc_sync_first_use) { |
| 357 | render_window->MakeCurrent(); | 353 | system.GPU().ObtainContext(); |
| 358 | sc_sync_first_use = false; | 354 | sc_sync_first_use = false; |
| 359 | } | 355 | } |
| 360 | auto& scheduler = system.Kernel().CurrentScheduler(); | 356 | auto& scheduler = system.Kernel().CurrentScheduler(); |
| @@ -366,9 +362,6 @@ void CpuManager::RunThread(std::size_t core) { | |||
| 366 | data.exit_barrier->Wait(); | 362 | data.exit_barrier->Wait(); |
| 367 | data.is_paused = false; | 363 | data.is_paused = false; |
| 368 | } | 364 | } |
| 369 | if (sc_sync) { | ||
| 370 | render_window->DoneCurrent(); | ||
| 371 | } | ||
| 372 | /// Time to cleanup | 365 | /// Time to cleanup |
| 373 | data.host_context->Exit(); | 366 | data.host_context->Exit(); |
| 374 | data.enter_barrier.reset(); | 367 | data.enter_barrier.reset(); |
diff --git a/src/core/cpu_manager.h b/src/core/cpu_manager.h index ae55d6427..35929ed94 100644 --- a/src/core/cpu_manager.h +++ b/src/core/cpu_manager.h | |||
| @@ -16,10 +16,6 @@ class Event; | |||
| 16 | class Fiber; | 16 | class Fiber; |
| 17 | } // namespace Common | 17 | } // namespace Common |
| 18 | 18 | ||
| 19 | namespace Core::Frontend { | ||
| 20 | class EmuWindow; | ||
| 21 | } // namespace Core::Frontend | ||
| 22 | |||
| 23 | namespace Core { | 19 | namespace Core { |
| 24 | 20 | ||
| 25 | class System; | 21 | class System; |
| @@ -61,8 +57,6 @@ public: | |||
| 61 | return current_core.load(); | 57 | return current_core.load(); |
| 62 | } | 58 | } |
| 63 | 59 | ||
| 64 | void SetRenderWindow(Core::Frontend::EmuWindow& render_window); | ||
| 65 | |||
| 66 | private: | 60 | private: |
| 67 | static void GuestThreadFunction(void* cpu_manager); | 61 | static void GuestThreadFunction(void* cpu_manager); |
| 68 | static void GuestRewindFunction(void* cpu_manager); | 62 | static void GuestRewindFunction(void* cpu_manager); |
| @@ -106,7 +100,6 @@ private: | |||
| 106 | std::size_t preemption_count{}; | 100 | std::size_t preemption_count{}; |
| 107 | std::size_t idle_count{}; | 101 | std::size_t idle_count{}; |
| 108 | static constexpr std::size_t max_cycle_runs = 5; | 102 | static constexpr std::size_t max_cycle_runs = 5; |
| 109 | Core::Frontend::EmuWindow* render_window; | ||
| 110 | 103 | ||
| 111 | System& system; | 104 | System& system; |
| 112 | }; | 105 | }; |
diff --git a/src/video_core/gpu.h b/src/video_core/gpu.h index a1b4c305c..2c42483bd 100644 --- a/src/video_core/gpu.h +++ b/src/video_core/gpu.h | |||
| @@ -284,6 +284,12 @@ public: | |||
| 284 | /// core timing events. | 284 | /// core timing events. |
| 285 | virtual void Start() = 0; | 285 | virtual void Start() = 0; |
| 286 | 286 | ||
| 287 | /// Obtain the CPU Context | ||
| 288 | virtual void ObtainContext() = 0; | ||
| 289 | |||
| 290 | /// Release the CPU Context | ||
| 291 | virtual void ReleaseContext() = 0; | ||
| 292 | |||
| 287 | /// Push GPU command entries to be processed | 293 | /// Push GPU command entries to be processed |
| 288 | virtual void PushGPUEntries(Tegra::CommandList&& entries) = 0; | 294 | virtual void PushGPUEntries(Tegra::CommandList&& entries) = 0; |
| 289 | 295 | ||
diff --git a/src/video_core/gpu_asynch.cpp b/src/video_core/gpu_asynch.cpp index 53305ab43..7b855f63e 100644 --- a/src/video_core/gpu_asynch.cpp +++ b/src/video_core/gpu_asynch.cpp | |||
| @@ -19,10 +19,17 @@ GPUAsynch::GPUAsynch(Core::System& system, std::unique_ptr<VideoCore::RendererBa | |||
| 19 | GPUAsynch::~GPUAsynch() = default; | 19 | GPUAsynch::~GPUAsynch() = default; |
| 20 | 20 | ||
| 21 | void GPUAsynch::Start() { | 21 | void GPUAsynch::Start() { |
| 22 | cpu_context->MakeCurrent(); | ||
| 23 | gpu_thread.StartThread(*renderer, *gpu_context, *dma_pusher); | 22 | gpu_thread.StartThread(*renderer, *gpu_context, *dma_pusher); |
| 24 | } | 23 | } |
| 25 | 24 | ||
| 25 | void GPUAsynch::ObtainContext() { | ||
| 26 | cpu_context->MakeCurrent(); | ||
| 27 | } | ||
| 28 | |||
| 29 | void GPUAsynch::ReleaseContext() { | ||
| 30 | cpu_context->DoneCurrent(); | ||
| 31 | } | ||
| 32 | |||
| 26 | void GPUAsynch::PushGPUEntries(Tegra::CommandList&& entries) { | 33 | void GPUAsynch::PushGPUEntries(Tegra::CommandList&& entries) { |
| 27 | gpu_thread.SubmitList(std::move(entries)); | 34 | gpu_thread.SubmitList(std::move(entries)); |
| 28 | } | 35 | } |
diff --git a/src/video_core/gpu_asynch.h b/src/video_core/gpu_asynch.h index 517658612..15e9f1d38 100644 --- a/src/video_core/gpu_asynch.h +++ b/src/video_core/gpu_asynch.h | |||
| @@ -25,6 +25,8 @@ public: | |||
| 25 | ~GPUAsynch() override; | 25 | ~GPUAsynch() override; |
| 26 | 26 | ||
| 27 | void Start() override; | 27 | void Start() override; |
| 28 | void ObtainContext() override; | ||
| 29 | void ReleaseContext() override; | ||
| 28 | void PushGPUEntries(Tegra::CommandList&& entries) override; | 30 | void PushGPUEntries(Tegra::CommandList&& entries) override; |
| 29 | void SwapBuffers(const Tegra::FramebufferConfig* framebuffer) override; | 31 | void SwapBuffers(const Tegra::FramebufferConfig* framebuffer) override; |
| 30 | void FlushRegion(VAddr addr, u64 size) override; | 32 | void FlushRegion(VAddr addr, u64 size) override; |
diff --git a/src/video_core/gpu_synch.cpp b/src/video_core/gpu_synch.cpp index 6f38a672a..aaeb9811d 100644 --- a/src/video_core/gpu_synch.cpp +++ b/src/video_core/gpu_synch.cpp | |||
| @@ -13,10 +13,16 @@ GPUSynch::GPUSynch(Core::System& system, std::unique_ptr<VideoCore::RendererBase | |||
| 13 | 13 | ||
| 14 | GPUSynch::~GPUSynch() = default; | 14 | GPUSynch::~GPUSynch() = default; |
| 15 | 15 | ||
| 16 | void GPUSynch::Start() { | 16 | void GPUSynch::Start() {} |
| 17 | |||
| 18 | void GPUSynch::ObtainContext() { | ||
| 17 | context->MakeCurrent(); | 19 | context->MakeCurrent(); |
| 18 | } | 20 | } |
| 19 | 21 | ||
| 22 | void GPUSynch::ReleaseContext() { | ||
| 23 | context->DoneCurrent(); | ||
| 24 | } | ||
| 25 | |||
| 20 | void GPUSynch::PushGPUEntries(Tegra::CommandList&& entries) { | 26 | void GPUSynch::PushGPUEntries(Tegra::CommandList&& entries) { |
| 21 | dma_pusher->Push(std::move(entries)); | 27 | dma_pusher->Push(std::move(entries)); |
| 22 | dma_pusher->DispatchCalls(); | 28 | dma_pusher->DispatchCalls(); |
diff --git a/src/video_core/gpu_synch.h b/src/video_core/gpu_synch.h index 4a6e9a01d..762c20aa5 100644 --- a/src/video_core/gpu_synch.h +++ b/src/video_core/gpu_synch.h | |||
| @@ -24,6 +24,8 @@ public: | |||
| 24 | ~GPUSynch() override; | 24 | ~GPUSynch() override; |
| 25 | 25 | ||
| 26 | void Start() override; | 26 | void Start() override; |
| 27 | void ObtainContext() override; | ||
| 28 | void ReleaseContext() override; | ||
| 27 | void PushGPUEntries(Tegra::CommandList&& entries) override; | 29 | void PushGPUEntries(Tegra::CommandList&& entries) override; |
| 28 | void SwapBuffers(const Tegra::FramebufferConfig* framebuffer) override; | 30 | void SwapBuffers(const Tegra::FramebufferConfig* framebuffer) override; |
| 29 | void FlushRegion(VAddr addr, u64 size) override; | 31 | void FlushRegion(VAddr addr, u64 size) override; |
diff --git a/src/yuzu/bootmanager.cpp b/src/yuzu/bootmanager.cpp index 6aa161e99..5f93bd432 100644 --- a/src/yuzu/bootmanager.cpp +++ b/src/yuzu/bootmanager.cpp | |||
| @@ -48,24 +48,29 @@ void EmuThread::run() { | |||
| 48 | MicroProfileOnThreadCreate(name.c_str()); | 48 | MicroProfileOnThreadCreate(name.c_str()); |
| 49 | Common::SetCurrentThreadName(name.c_str()); | 49 | Common::SetCurrentThreadName(name.c_str()); |
| 50 | 50 | ||
| 51 | auto& system = Core::System::GetInstance(); | ||
| 52 | |||
| 53 | system.RegisterHostThread(); | ||
| 54 | |||
| 55 | auto& gpu = system.GPU(); | ||
| 56 | |||
| 51 | // Main process has been loaded. Make the context current to this thread and begin GPU and CPU | 57 | // Main process has been loaded. Make the context current to this thread and begin GPU and CPU |
| 52 | // execution. | 58 | // execution. |
| 53 | Core::System::GetInstance().GPU().Start(); | 59 | gpu.Start(); |
| 54 | 60 | ||
| 55 | emit LoadProgress(VideoCore::LoadCallbackStage::Prepare, 0, 0); | 61 | gpu.ObtainContext(); |
| 56 | 62 | ||
| 57 | Core::System::GetInstance().RegisterHostThread(); | 63 | emit LoadProgress(VideoCore::LoadCallbackStage::Prepare, 0, 0); |
| 58 | |||
| 59 | context.MakeCurrent(); | ||
| 60 | 64 | ||
| 61 | Core::System::GetInstance().Renderer().Rasterizer().LoadDiskResources( | 65 | system.Renderer().Rasterizer().LoadDiskResources( |
| 62 | stop_run, [this](VideoCore::LoadCallbackStage stage, std::size_t value, std::size_t total) { | 66 | stop_run, [this](VideoCore::LoadCallbackStage stage, std::size_t value, std::size_t total) { |
| 63 | emit LoadProgress(stage, value, total); | 67 | emit LoadProgress(stage, value, total); |
| 64 | }); | 68 | }); |
| 65 | 69 | ||
| 66 | emit LoadProgress(VideoCore::LoadCallbackStage::Complete, 0, 0); | 70 | emit LoadProgress(VideoCore::LoadCallbackStage::Complete, 0, 0); |
| 67 | 71 | ||
| 68 | context.DoneCurrent(); | 72 | gpu.ReleaseContext(); |
| 73 | |||
| 69 | 74 | ||
| 70 | // Holds whether the cpu was running during the last iteration, | 75 | // Holds whether the cpu was running during the last iteration, |
| 71 | // so that the DebugModeLeft signal can be emitted before the | 76 | // so that the DebugModeLeft signal can be emitted before the |
| @@ -78,18 +83,18 @@ void EmuThread::run() { | |||
| 78 | } | 83 | } |
| 79 | 84 | ||
| 80 | running_guard = true; | 85 | running_guard = true; |
| 81 | Core::System::ResultStatus result = Core::System::GetInstance().Run(); | 86 | Core::System::ResultStatus result = system.Run(); |
| 82 | if (result != Core::System::ResultStatus::Success) { | 87 | if (result != Core::System::ResultStatus::Success) { |
| 83 | running_guard = false; | 88 | running_guard = false; |
| 84 | this->SetRunning(false); | 89 | this->SetRunning(false); |
| 85 | emit ErrorThrown(result, Core::System::GetInstance().GetStatusDetails()); | 90 | emit ErrorThrown(result, system.GetStatusDetails()); |
| 86 | } | 91 | } |
| 87 | running_wait.Wait(); | 92 | running_wait.Wait(); |
| 88 | result = Core::System::GetInstance().Pause(); | 93 | result = system.Pause(); |
| 89 | if (result != Core::System::ResultStatus::Success) { | 94 | if (result != Core::System::ResultStatus::Success) { |
| 90 | running_guard = false; | 95 | running_guard = false; |
| 91 | this->SetRunning(false); | 96 | this->SetRunning(false); |
| 92 | emit ErrorThrown(result, Core::System::GetInstance().GetStatusDetails()); | 97 | emit ErrorThrown(result, system.GetStatusDetails()); |
| 93 | } | 98 | } |
| 94 | running_guard = false; | 99 | running_guard = false; |
| 95 | 100 | ||
| @@ -106,7 +111,7 @@ void EmuThread::run() { | |||
| 106 | } | 111 | } |
| 107 | 112 | ||
| 108 | // Shutdown the core emulation | 113 | // Shutdown the core emulation |
| 109 | Core::System::GetInstance().Shutdown(); | 114 | system.Shutdown(); |
| 110 | 115 | ||
| 111 | #if MICROPROFILE_ENABLED | 116 | #if MICROPROFILE_ENABLED |
| 112 | MicroProfileOnThreadExit(); | 117 | MicroProfileOnThreadExit(); |