summaryrefslogtreecommitdiff
path: root/src/core/core.cpp
diff options
context:
space:
mode:
authorGravatar Lioncash2018-08-03 12:55:58 -0400
committerGravatar Lioncash2018-08-04 02:36:57 -0400
commit6030c5ce412e44ddcfe0a31c6747a017166bf33d (patch)
tree2b79fa019f07e601b5170e92e93b69788ffde949 /src/core/core.cpp
parentMerge pull request #911 from lioncash/prototype (diff)
downloadyuzu-6030c5ce412e44ddcfe0a31c6747a017166bf33d.tar.gz
yuzu-6030c5ce412e44ddcfe0a31c6747a017166bf33d.tar.xz
yuzu-6030c5ce412e44ddcfe0a31c6747a017166bf33d.zip
video_core: Eliminate the g_renderer global variable
We move the initialization of the renderer to the core class, while keeping the creation of it and any other specifics in video_core. This way we can ensure that the renderer is initialized and doesn't give unfettered access to the renderer. This also makes dependencies on types more explicit. For example, the GPU class doesn't need to depend on the existence of a renderer, it only needs to care about whether or not it has a rasterizer, but since it was accessing the global variable, it was also making the renderer a part of its dependency chain. By adjusting the interface, we can get rid of this dependency.
Diffstat (limited to 'src/core/core.cpp')
-rw-r--r--src/core/core.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/core/core.cpp b/src/core/core.cpp
index 9824769cf..29222baba 100644
--- a/src/core/core.cpp
+++ b/src/core/core.cpp
@@ -18,6 +18,7 @@
18#include "core/loader/loader.h" 18#include "core/loader/loader.h"
19#include "core/settings.h" 19#include "core/settings.h"
20#include "file_sys/vfs_real.h" 20#include "file_sys/vfs_real.h"
21#include "video_core/renderer_base.h"
21#include "video_core/video_core.h" 22#include "video_core/video_core.h"
22 23
23namespace Core { 24namespace Core {
@@ -174,7 +175,6 @@ System::ResultStatus System::Init(EmuWindow& emu_window) {
174 cpu_cores[index] = std::make_shared<Cpu>(cpu_exclusive_monitor, cpu_barrier, index); 175 cpu_cores[index] = std::make_shared<Cpu>(cpu_exclusive_monitor, cpu_barrier, index);
175 } 176 }
176 177
177 gpu_core = std::make_unique<Tegra::GPU>();
178 telemetry_session = std::make_unique<Core::TelemetrySession>(); 178 telemetry_session = std::make_unique<Core::TelemetrySession>();
179 service_manager = std::make_shared<Service::SM::ServiceManager>(); 179 service_manager = std::make_shared<Service::SM::ServiceManager>();
180 180
@@ -182,10 +182,13 @@ System::ResultStatus System::Init(EmuWindow& emu_window) {
182 Service::Init(service_manager); 182 Service::Init(service_manager);
183 GDBStub::Init(); 183 GDBStub::Init();
184 184
185 if (!VideoCore::Init(emu_window)) { 185 renderer = VideoCore::CreateRenderer(emu_window);
186 if (!renderer->Init()) {
186 return ResultStatus::ErrorVideoCore; 187 return ResultStatus::ErrorVideoCore;
187 } 188 }
188 189
190 gpu_core = std::make_unique<Tegra::GPU>(*renderer->Rasterizer());
191
189 // Create threads for CPU cores 1-3, and build thread_to_cpu map 192 // Create threads for CPU cores 1-3, and build thread_to_cpu map
190 // CPU core 0 is run on the main thread 193 // CPU core 0 is run on the main thread
191 thread_to_cpu[std::this_thread::get_id()] = cpu_cores[0]; 194 thread_to_cpu[std::this_thread::get_id()] = cpu_cores[0];
@@ -217,7 +220,7 @@ void System::Shutdown() {
217 perf_results.frametime * 1000.0); 220 perf_results.frametime * 1000.0);
218 221
219 // Shutdown emulation session 222 // Shutdown emulation session
220 VideoCore::Shutdown(); 223 renderer.reset();
221 GDBStub::Shutdown(); 224 GDBStub::Shutdown();
222 Service::Shutdown(); 225 Service::Shutdown();
223 Kernel::Shutdown(); 226 Kernel::Shutdown();