summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Fernando Sahmkow2020-02-25 11:12:46 -0400
committerGravatar Fernando Sahmkow2020-06-27 11:35:09 -0400
commitdc580582034fb5937aa53176fdaa4bd0fc4acce8 (patch)
tree6d351a6c3a76fee0a9bc1ab546d07c0583a9d9cd /src
parentCPU_Manager: remove debugging code. (diff)
downloadyuzu-dc580582034fb5937aa53176fdaa4bd0fc4acce8.tar.gz
yuzu-dc580582034fb5937aa53176fdaa4bd0fc4acce8.tar.xz
yuzu-dc580582034fb5937aa53176fdaa4bd0fc4acce8.zip
General: Setup yuzu threads' microprofile, naming and registry.
Diffstat (limited to 'src')
-rw-r--r--src/core/core_timing.cpp5
-rw-r--r--src/core/cpu_manager.cpp5
-rw-r--r--src/video_core/gpu_thread.cpp6
-rw-r--r--src/yuzu/bootmanager.cpp4
-rw-r--r--src/yuzu/main.cpp2
-rw-r--r--src/yuzu_cmd/yuzu.cpp6
-rw-r--r--src/yuzu_tester/yuzu.cpp6
7 files changed, 25 insertions, 9 deletions
diff --git a/src/core/core_timing.cpp b/src/core/core_timing.cpp
index a3ce69790..cc32a853b 100644
--- a/src/core/core_timing.cpp
+++ b/src/core/core_timing.cpp
@@ -2,14 +2,14 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "core/core_timing.h"
6
7#include <algorithm> 5#include <algorithm>
8#include <mutex> 6#include <mutex>
9#include <string> 7#include <string>
10#include <tuple> 8#include <tuple>
11 9
12#include "common/assert.h" 10#include "common/assert.h"
11#include "common/microprofile.h"
12#include "core/core_timing.h"
13#include "core/core_timing_util.h" 13#include "core/core_timing_util.h"
14 14
15namespace Core::Timing { 15namespace Core::Timing {
@@ -44,6 +44,7 @@ CoreTiming::~CoreTiming() = default;
44 44
45void CoreTiming::ThreadEntry(CoreTiming& instance) { 45void CoreTiming::ThreadEntry(CoreTiming& instance) {
46 std::string name = "yuzu:HostTiming"; 46 std::string name = "yuzu:HostTiming";
47 MicroProfileOnThreadCreate(name.c_str());
47 Common::SetCurrentThreadName(name.c_str()); 48 Common::SetCurrentThreadName(name.c_str());
48 instance.on_thread_init(); 49 instance.on_thread_init();
49 instance.ThreadLoop(); 50 instance.ThreadLoop();
diff --git a/src/core/cpu_manager.cpp b/src/core/cpu_manager.cpp
index ff2fe8ead..9b9337131 100644
--- a/src/core/cpu_manager.cpp
+++ b/src/core/cpu_manager.cpp
@@ -3,6 +3,7 @@
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "common/fiber.h" 5#include "common/fiber.h"
6#include "common/microprofile.h"
6#include "common/thread.h" 7#include "common/thread.h"
7#include "core/arm/exclusive_monitor.h" 8#include "core/arm/exclusive_monitor.h"
8#include "core/core.h" 9#include "core/core.h"
@@ -36,6 +37,7 @@ void CpuManager::Shutdown() {
36 Pause(false); 37 Pause(false);
37 for (std::size_t core = 0; core < Core::Hardware::NUM_CPU_CORES; core++) { 38 for (std::size_t core = 0; core < Core::Hardware::NUM_CPU_CORES; core++) {
38 core_data[core].host_thread->join(); 39 core_data[core].host_thread->join();
40 core_data[core].host_thread.reset();
39 } 41 }
40} 42}
41 43
@@ -80,7 +82,7 @@ void CpuManager::RunGuestThread() {
80 auto& physical_core = kernel.CurrentPhysicalCore(); 82 auto& physical_core = kernel.CurrentPhysicalCore();
81 if (!physical_core.IsInterrupted()) { 83 if (!physical_core.IsInterrupted()) {
82 physical_core.Idle(); 84 physical_core.Idle();
83 //physical_core.Run(); 85 // physical_core.Run();
84 } 86 }
85 auto& scheduler = physical_core.Scheduler(); 87 auto& scheduler = physical_core.Scheduler();
86 scheduler.TryDoContextSwitch(); 88 scheduler.TryDoContextSwitch();
@@ -159,6 +161,7 @@ void CpuManager::RunThread(std::size_t core) {
159 /// Initialization 161 /// Initialization
160 system.RegisterCoreThread(core); 162 system.RegisterCoreThread(core);
161 std::string name = "yuzu:CoreHostThread_" + std::to_string(core); 163 std::string name = "yuzu:CoreHostThread_" + std::to_string(core);
164 MicroProfileOnThreadCreate(name.c_str());
162 Common::SetCurrentThreadName(name.c_str()); 165 Common::SetCurrentThreadName(name.c_str());
163 auto& data = core_data[core]; 166 auto& data = core_data[core];
164 data.enter_barrier = std::make_unique<Common::Event>(); 167 data.enter_barrier = std::make_unique<Common::Event>();
diff --git a/src/video_core/gpu_thread.cpp b/src/video_core/gpu_thread.cpp
index c3bb4fe06..323185bfc 100644
--- a/src/video_core/gpu_thread.cpp
+++ b/src/video_core/gpu_thread.cpp
@@ -4,6 +4,7 @@
4 4
5#include "common/assert.h" 5#include "common/assert.h"
6#include "common/microprofile.h" 6#include "common/microprofile.h"
7#include "common/thread.h"
7#include "core/core.h" 8#include "core/core.h"
8#include "core/frontend/emu_window.h" 9#include "core/frontend/emu_window.h"
9#include "core/settings.h" 10#include "core/settings.h"
@@ -18,7 +19,10 @@ namespace VideoCommon::GPUThread {
18static void RunThread(Core::System& system, VideoCore::RendererBase& renderer, 19static void RunThread(Core::System& system, VideoCore::RendererBase& renderer,
19 Core::Frontend::GraphicsContext& context, Tegra::DmaPusher& dma_pusher, 20 Core::Frontend::GraphicsContext& context, Tegra::DmaPusher& dma_pusher,
20 SynchState& state) { 21 SynchState& state) {
21 MicroProfileOnThreadCreate("GpuThread"); 22 std::string name = "yuzu:GPU";
23 MicroProfileOnThreadCreate(name.c_str());
24 Common::SetCurrentThreadName(name.c_str());
25 system.RegisterHostThread();
22 26
23 // Wait for first GPU command before acquiring the window context 27 // Wait for first GPU command before acquiring the window context
24 while (state.queue.Empty()) 28 while (state.queue.Empty())
diff --git a/src/yuzu/bootmanager.cpp b/src/yuzu/bootmanager.cpp
index 9ceb6c8d7..468dde782 100644
--- a/src/yuzu/bootmanager.cpp
+++ b/src/yuzu/bootmanager.cpp
@@ -44,7 +44,9 @@ EmuThread::EmuThread() = default;
44EmuThread::~EmuThread() = default; 44EmuThread::~EmuThread() = default;
45 45
46void EmuThread::run() { 46void EmuThread::run() {
47 MicroProfileOnThreadCreate("EmuThread"); 47 std::string name = "yuzu:EmuControlThread";
48 MicroProfileOnThreadCreate(name.c_str());
49 Common::SetCurrentThreadName(name.c_str());
48 50
49 // Main process has been loaded. Make the context current to this thread and begin GPU and CPU 51 // Main process has been loaded. Make the context current to this thread and begin GPU and CPU
50 // execution. 52 // execution.
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp
index ba69139e5..de0c7fe8c 100644
--- a/src/yuzu/main.cpp
+++ b/src/yuzu/main.cpp
@@ -925,6 +925,8 @@ bool GMainWindow::LoadROM(const QString& filename) {
925 nullptr, // E-Commerce 925 nullptr, // E-Commerce
926 }); 926 });
927 927
928 system.RegisterHostThread();
929
928 const Core::System::ResultStatus result{system.Load(*render_window, filename.toStdString())}; 930 const Core::System::ResultStatus result{system.Load(*render_window, filename.toStdString())};
929 931
930 const auto drd_callout = 932 const auto drd_callout =
diff --git a/src/yuzu_cmd/yuzu.cpp b/src/yuzu_cmd/yuzu.cpp
index 38ffdfbd3..e6c6a839d 100644
--- a/src/yuzu_cmd/yuzu.cpp
+++ b/src/yuzu_cmd/yuzu.cpp
@@ -2,6 +2,7 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include <chrono>
5#include <iostream> 6#include <iostream>
6#include <memory> 7#include <memory>
7#include <string> 8#include <string>
@@ -237,8 +238,9 @@ int main(int argc, char** argv) {
237 238
238 std::thread render_thread([&emu_window] { emu_window->Present(); }); 239 std::thread render_thread([&emu_window] { emu_window->Present(); });
239 system.Run(); 240 system.Run();
240 while (emu_window->IsOpen()) 241 while (emu_window->IsOpen()) {
241 ; 242 std::this_thread::sleep_for(std::chrono::milliseconds(1));
243 }
242 system.Pause(); 244 system.Pause();
243 render_thread.join(); 245 render_thread.join();
244 246
diff --git a/src/yuzu_tester/yuzu.cpp b/src/yuzu_tester/yuzu.cpp
index d62686dd2..083667baf 100644
--- a/src/yuzu_tester/yuzu.cpp
+++ b/src/yuzu_tester/yuzu.cpp
@@ -2,6 +2,7 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include <chrono>
5#include <iostream> 6#include <iostream>
6#include <memory> 7#include <memory>
7#include <string> 8#include <string>
@@ -256,8 +257,9 @@ int main(int argc, char** argv) {
256 system.Renderer().Rasterizer().LoadDiskResources(); 257 system.Renderer().Rasterizer().LoadDiskResources();
257 258
258 system.Run(); 259 system.Run();
259 while (!finished) 260 while (!finished) {
260 ; 261 std::this_thread::sleep_for(std::chrono::milliseconds(1));
262 }
261 system.Pause(); 263 system.Pause();
262 264
263 detached_tasks.WaitForAllTasks(); 265 detached_tasks.WaitForAllTasks();