diff options
| author | 2018-08-03 12:55:58 -0400 | |
|---|---|---|
| committer | 2018-08-04 02:36:57 -0400 | |
| commit | 6030c5ce412e44ddcfe0a31c6747a017166bf33d (patch) | |
| tree | 2b79fa019f07e601b5170e92e93b69788ffde949 /src/core/core.h | |
| parent | Merge pull request #911 from lioncash/prototype (diff) | |
| download | yuzu-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.h')
| -rw-r--r-- | src/core/core.h | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/core/core.h b/src/core/core.h index ed475ac4e..059db4262 100644 --- a/src/core/core.h +++ b/src/core/core.h | |||
| @@ -27,6 +27,10 @@ namespace Service::SM { | |||
| 27 | class ServiceManager; | 27 | class ServiceManager; |
| 28 | } | 28 | } |
| 29 | 29 | ||
| 30 | namespace VideoCore { | ||
| 31 | class RendererBase; | ||
| 32 | } | ||
| 33 | |||
| 30 | namespace Core { | 34 | namespace Core { |
| 31 | 35 | ||
| 32 | class System { | 36 | class System { |
| @@ -127,11 +131,26 @@ public: | |||
| 127 | /// Gets a CPU interface to the CPU core with the specified index | 131 | /// Gets a CPU interface to the CPU core with the specified index |
| 128 | Cpu& CpuCore(size_t core_index); | 132 | Cpu& CpuCore(size_t core_index); |
| 129 | 133 | ||
| 130 | /// Gets the GPU interface | 134 | /// Gets a mutable reference to the GPU interface |
| 131 | Tegra::GPU& GPU() { | 135 | Tegra::GPU& GPU() { |
| 132 | return *gpu_core; | 136 | return *gpu_core; |
| 133 | } | 137 | } |
| 134 | 138 | ||
| 139 | /// Gets an immutable reference to the GPU interface. | ||
| 140 | const Tegra::GPU& GPU() const { | ||
| 141 | return *gpu_core; | ||
| 142 | } | ||
| 143 | |||
| 144 | /// Gets a mutable reference to the renderer. | ||
| 145 | VideoCore::RendererBase& Renderer() { | ||
| 146 | return *renderer; | ||
| 147 | } | ||
| 148 | |||
| 149 | /// Gets an immutable reference to the renderer. | ||
| 150 | const VideoCore::RendererBase& Renderer() const { | ||
| 151 | return *renderer; | ||
| 152 | } | ||
| 153 | |||
| 135 | /// Gets the scheduler for the CPU core that is currently running | 154 | /// Gets the scheduler for the CPU core that is currently running |
| 136 | Kernel::Scheduler& CurrentScheduler() { | 155 | Kernel::Scheduler& CurrentScheduler() { |
| 137 | return *CurrentCpuCore().Scheduler(); | 156 | return *CurrentCpuCore().Scheduler(); |
| @@ -195,6 +214,7 @@ private: | |||
| 195 | 214 | ||
| 196 | /// AppLoader used to load the current executing application | 215 | /// AppLoader used to load the current executing application |
| 197 | std::unique_ptr<Loader::AppLoader> app_loader; | 216 | std::unique_ptr<Loader::AppLoader> app_loader; |
| 217 | std::unique_ptr<VideoCore::RendererBase> renderer; | ||
| 198 | std::unique_ptr<Tegra::GPU> gpu_core; | 218 | std::unique_ptr<Tegra::GPU> gpu_core; |
| 199 | std::shared_ptr<Tegra::DebugContext> debug_context; | 219 | std::shared_ptr<Tegra::DebugContext> debug_context; |
| 200 | Kernel::SharedPtr<Kernel::Process> current_process; | 220 | Kernel::SharedPtr<Kernel::Process> current_process; |