summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Lioncash2019-02-15 22:05:17 -0500
committerGravatar Lioncash2019-02-15 22:06:23 -0500
commita8fa5019b51c9ce765124121daac863cfc1365aa (patch)
treee23b97873c1e6b4fcb34066fccb393d2a1147bb8
parentMerge pull request #2123 from lioncash/coretiming-global (diff)
downloadyuzu-a8fa5019b51c9ce765124121daac863cfc1365aa.tar.gz
yuzu-a8fa5019b51c9ce765124121daac863cfc1365aa.tar.xz
yuzu-a8fa5019b51c9ce765124121daac863cfc1365aa.zip
video_core: Remove usages of System::GetInstance() within the engines
Avoids the use of the global accessor in favor of explicitly making the system a dependency within the interface.
-rw-r--r--src/core/core.cpp2
-rw-r--r--src/video_core/engines/kepler_memory.cpp7
-rw-r--r--src/video_core/engines/kepler_memory.h9
-rw-r--r--src/video_core/engines/maxwell_3d.cpp12
-rw-r--r--src/video_core/engines/maxwell_3d.h9
-rw-r--r--src/video_core/engines/maxwell_dma.cpp8
-rw-r--r--src/video_core/engines/maxwell_dma.h10
-rw-r--r--src/video_core/gpu.cpp8
-rw-r--r--src/video_core/gpu.h7
9 files changed, 49 insertions, 23 deletions
diff --git a/src/core/core.cpp b/src/core/core.cpp
index 8aa0932c5..ab7181a05 100644
--- a/src/core/core.cpp
+++ b/src/core/core.cpp
@@ -128,7 +128,7 @@ struct System::Impl {
128 return ResultStatus::ErrorVideoCore; 128 return ResultStatus::ErrorVideoCore;
129 } 129 }
130 130
131 gpu_core = std::make_unique<Tegra::GPU>(renderer->Rasterizer()); 131 gpu_core = std::make_unique<Tegra::GPU>(system, renderer->Rasterizer());
132 132
133 cpu_core_manager.Initialize(system); 133 cpu_core_manager.Initialize(system);
134 is_powered_on = true; 134 is_powered_on = true;
diff --git a/src/video_core/engines/kepler_memory.cpp b/src/video_core/engines/kepler_memory.cpp
index 5c1029ddf..4f6126116 100644
--- a/src/video_core/engines/kepler_memory.cpp
+++ b/src/video_core/engines/kepler_memory.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 "common/assert.h"
5#include "common/logging/log.h" 6#include "common/logging/log.h"
6#include "core/core.h" 7#include "core/core.h"
7#include "core/memory.h" 8#include "core/memory.h"
@@ -11,9 +12,9 @@
11 12
12namespace Tegra::Engines { 13namespace Tegra::Engines {
13 14
14KeplerMemory::KeplerMemory(VideoCore::RasterizerInterface& rasterizer, 15KeplerMemory::KeplerMemory(Core::System& system, VideoCore::RasterizerInterface& rasterizer,
15 MemoryManager& memory_manager) 16 MemoryManager& memory_manager)
16 : memory_manager(memory_manager), rasterizer{rasterizer} {} 17 : system{system}, memory_manager(memory_manager), rasterizer{rasterizer} {}
17 18
18KeplerMemory::~KeplerMemory() = default; 19KeplerMemory::~KeplerMemory() = default;
19 20
@@ -50,7 +51,7 @@ void KeplerMemory::ProcessData(u32 data) {
50 rasterizer.InvalidateRegion(*dest_address, sizeof(u32)); 51 rasterizer.InvalidateRegion(*dest_address, sizeof(u32));
51 52
52 Memory::Write32(*dest_address, data); 53 Memory::Write32(*dest_address, data);
53 Core::System::GetInstance().GPU().Maxwell3D().dirty_flags.OnMemoryWrite(); 54 system.GPU().Maxwell3D().dirty_flags.OnMemoryWrite();
54 55
55 state.write_offset++; 56 state.write_offset++;
56} 57}
diff --git a/src/video_core/engines/kepler_memory.h b/src/video_core/engines/kepler_memory.h
index fe9ebc5b9..f680c2ad9 100644
--- a/src/video_core/engines/kepler_memory.h
+++ b/src/video_core/engines/kepler_memory.h
@@ -5,13 +5,16 @@
5#pragma once 5#pragma once
6 6
7#include <array> 7#include <array>
8#include "common/assert.h"
9#include "common/bit_field.h" 8#include "common/bit_field.h"
10#include "common/common_funcs.h" 9#include "common/common_funcs.h"
11#include "common/common_types.h" 10#include "common/common_types.h"
12#include "video_core/gpu.h" 11#include "video_core/gpu.h"
13#include "video_core/memory_manager.h" 12#include "video_core/memory_manager.h"
14 13
14namespace Core {
15class System;
16}
17
15namespace VideoCore { 18namespace VideoCore {
16class RasterizerInterface; 19class RasterizerInterface;
17} 20}
@@ -23,7 +26,8 @@ namespace Tegra::Engines {
23 26
24class KeplerMemory final { 27class KeplerMemory final {
25public: 28public:
26 KeplerMemory(VideoCore::RasterizerInterface& rasterizer, MemoryManager& memory_manager); 29 KeplerMemory(Core::System& system, VideoCore::RasterizerInterface& rasterizer,
30 MemoryManager& memory_manager);
27 ~KeplerMemory(); 31 ~KeplerMemory();
28 32
29 /// Write the value to the register identified by method. 33 /// Write the value to the register identified by method.
@@ -76,6 +80,7 @@ public:
76 } state{}; 80 } state{};
77 81
78private: 82private:
83 Core::System& system;
79 MemoryManager& memory_manager; 84 MemoryManager& memory_manager;
80 VideoCore::RasterizerInterface& rasterizer; 85 VideoCore::RasterizerInterface& rasterizer;
81 86
diff --git a/src/video_core/engines/maxwell_3d.cpp b/src/video_core/engines/maxwell_3d.cpp
index 86ede5faa..2d2136067 100644
--- a/src/video_core/engines/maxwell_3d.cpp
+++ b/src/video_core/engines/maxwell_3d.cpp
@@ -19,8 +19,10 @@ namespace Tegra::Engines {
19/// First register id that is actually a Macro call. 19/// First register id that is actually a Macro call.
20constexpr u32 MacroRegistersStart = 0xE00; 20constexpr u32 MacroRegistersStart = 0xE00;
21 21
22Maxwell3D::Maxwell3D(VideoCore::RasterizerInterface& rasterizer, MemoryManager& memory_manager) 22Maxwell3D::Maxwell3D(Core::System& system, VideoCore::RasterizerInterface& rasterizer,
23 : memory_manager(memory_manager), rasterizer{rasterizer}, macro_interpreter(*this) { 23 MemoryManager& memory_manager)
24 : memory_manager(memory_manager), system{system}, rasterizer{rasterizer},
25 macro_interpreter(*this) {
24 InitializeRegisterDefaults(); 26 InitializeRegisterDefaults();
25} 27}
26 28
@@ -103,7 +105,7 @@ void Maxwell3D::CallMacroMethod(u32 method, std::vector<u32> parameters) {
103} 105}
104 106
105void Maxwell3D::CallMethod(const GPU::MethodCall& method_call) { 107void Maxwell3D::CallMethod(const GPU::MethodCall& method_call) {
106 auto debug_context = Core::System::GetInstance().GetGPUDebugContext(); 108 auto debug_context = system.GetGPUDebugContext();
107 109
108 // It is an error to write to a register other than the current macro's ARG register before it 110 // It is an error to write to a register other than the current macro's ARG register before it
109 // has finished execution. 111 // has finished execution.
@@ -317,7 +319,7 @@ void Maxwell3D::ProcessQueryGet() {
317 LongQueryResult query_result{}; 319 LongQueryResult query_result{};
318 query_result.value = result; 320 query_result.value = result;
319 // TODO(Subv): Generate a real GPU timestamp and write it here instead of CoreTiming 321 // TODO(Subv): Generate a real GPU timestamp and write it here instead of CoreTiming
320 query_result.timestamp = Core::System::GetInstance().CoreTiming().GetTicks(); 322 query_result.timestamp = system.CoreTiming().GetTicks();
321 Memory::WriteBlock(*address, &query_result, sizeof(query_result)); 323 Memory::WriteBlock(*address, &query_result, sizeof(query_result));
322 } 324 }
323 dirty_flags.OnMemoryWrite(); 325 dirty_flags.OnMemoryWrite();
@@ -334,7 +336,7 @@ void Maxwell3D::DrawArrays() {
334 regs.vertex_buffer.count); 336 regs.vertex_buffer.count);
335 ASSERT_MSG(!(regs.index_array.count && regs.vertex_buffer.count), "Both indexed and direct?"); 337 ASSERT_MSG(!(regs.index_array.count && regs.vertex_buffer.count), "Both indexed and direct?");
336 338
337 auto debug_context = Core::System::GetInstance().GetGPUDebugContext(); 339 auto debug_context = system.GetGPUDebugContext();
338 340
339 if (debug_context) { 341 if (debug_context) {
340 debug_context->OnEvent(Tegra::DebugContext::Event::IncomingPrimitiveBatch, nullptr); 342 debug_context->OnEvent(Tegra::DebugContext::Event::IncomingPrimitiveBatch, nullptr);
diff --git a/src/video_core/engines/maxwell_3d.h b/src/video_core/engines/maxwell_3d.h
index 1f76aa670..0e3873ffd 100644
--- a/src/video_core/engines/maxwell_3d.h
+++ b/src/video_core/engines/maxwell_3d.h
@@ -17,6 +17,10 @@
17#include "video_core/memory_manager.h" 17#include "video_core/memory_manager.h"
18#include "video_core/textures/texture.h" 18#include "video_core/textures/texture.h"
19 19
20namespace Core {
21class System;
22}
23
20namespace VideoCore { 24namespace VideoCore {
21class RasterizerInterface; 25class RasterizerInterface;
22} 26}
@@ -28,7 +32,8 @@ namespace Tegra::Engines {
28 32
29class Maxwell3D final { 33class Maxwell3D final {
30public: 34public:
31 explicit Maxwell3D(VideoCore::RasterizerInterface& rasterizer, MemoryManager& memory_manager); 35 explicit Maxwell3D(Core::System& system, VideoCore::RasterizerInterface& rasterizer,
36 MemoryManager& memory_manager);
32 ~Maxwell3D() = default; 37 ~Maxwell3D() = default;
33 38
34 /// Register structure of the Maxwell3D engine. 39 /// Register structure of the Maxwell3D engine.
@@ -1131,6 +1136,8 @@ public:
1131private: 1136private:
1132 void InitializeRegisterDefaults(); 1137 void InitializeRegisterDefaults();
1133 1138
1139 Core::System& system;
1140
1134 VideoCore::RasterizerInterface& rasterizer; 1141 VideoCore::RasterizerInterface& rasterizer;
1135 1142
1136 /// Start offsets of each macro in macro_memory 1143 /// Start offsets of each macro in macro_memory
diff --git a/src/video_core/engines/maxwell_dma.cpp b/src/video_core/engines/maxwell_dma.cpp
index d6c41a5ae..529a14ec7 100644
--- a/src/video_core/engines/maxwell_dma.cpp
+++ b/src/video_core/engines/maxwell_dma.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 "common/assert.h"
5#include "core/core.h" 6#include "core/core.h"
6#include "core/memory.h" 7#include "core/memory.h"
7#include "video_core/engines/maxwell_3d.h" 8#include "video_core/engines/maxwell_3d.h"
@@ -11,8 +12,9 @@
11 12
12namespace Tegra::Engines { 13namespace Tegra::Engines {
13 14
14MaxwellDMA::MaxwellDMA(VideoCore::RasterizerInterface& rasterizer, MemoryManager& memory_manager) 15MaxwellDMA::MaxwellDMA(Core::System& system, VideoCore::RasterizerInterface& rasterizer,
15 : memory_manager(memory_manager), rasterizer{rasterizer} {} 16 MemoryManager& memory_manager)
17 : memory_manager(memory_manager), system{system}, rasterizer{rasterizer} {}
16 18
17void MaxwellDMA::CallMethod(const GPU::MethodCall& method_call) { 19void MaxwellDMA::CallMethod(const GPU::MethodCall& method_call) {
18 ASSERT_MSG(method_call.method < Regs::NUM_REGS, 20 ASSERT_MSG(method_call.method < Regs::NUM_REGS,
@@ -59,7 +61,7 @@ void MaxwellDMA::HandleCopy() {
59 } 61 }
60 62
61 // All copies here update the main memory, so mark all rasterizer states as invalid. 63 // All copies here update the main memory, so mark all rasterizer states as invalid.
62 Core::System::GetInstance().GPU().Maxwell3D().dirty_flags.OnMemoryWrite(); 64 system.GPU().Maxwell3D().dirty_flags.OnMemoryWrite();
63 65
64 if (regs.exec.is_dst_linear && regs.exec.is_src_linear) { 66 if (regs.exec.is_dst_linear && regs.exec.is_src_linear) {
65 // When the enable_2d bit is disabled, the copy is performed as if we were copying a 1D 67 // When the enable_2d bit is disabled, the copy is performed as if we were copying a 1D
diff --git a/src/video_core/engines/maxwell_dma.h b/src/video_core/engines/maxwell_dma.h
index 1f8cd65d2..cf75aeb12 100644
--- a/src/video_core/engines/maxwell_dma.h
+++ b/src/video_core/engines/maxwell_dma.h
@@ -5,13 +5,16 @@
5#pragma once 5#pragma once
6 6
7#include <array> 7#include <array>
8#include "common/assert.h"
9#include "common/bit_field.h" 8#include "common/bit_field.h"
10#include "common/common_funcs.h" 9#include "common/common_funcs.h"
11#include "common/common_types.h" 10#include "common/common_types.h"
12#include "video_core/gpu.h" 11#include "video_core/gpu.h"
13#include "video_core/memory_manager.h" 12#include "video_core/memory_manager.h"
14 13
14namespace Core {
15class System;
16}
17
15namespace VideoCore { 18namespace VideoCore {
16class RasterizerInterface; 19class RasterizerInterface;
17} 20}
@@ -20,7 +23,8 @@ namespace Tegra::Engines {
20 23
21class MaxwellDMA final { 24class MaxwellDMA final {
22public: 25public:
23 explicit MaxwellDMA(VideoCore::RasterizerInterface& rasterizer, MemoryManager& memory_manager); 26 explicit MaxwellDMA(Core::System& system, VideoCore::RasterizerInterface& rasterizer,
27 MemoryManager& memory_manager);
24 ~MaxwellDMA() = default; 28 ~MaxwellDMA() = default;
25 29
26 /// Write the value to the register identified by method. 30 /// Write the value to the register identified by method.
@@ -137,6 +141,8 @@ public:
137 MemoryManager& memory_manager; 141 MemoryManager& memory_manager;
138 142
139private: 143private:
144 Core::System& system;
145
140 VideoCore::RasterizerInterface& rasterizer; 146 VideoCore::RasterizerInterface& rasterizer;
141 147
142 /// Performs the copy from the source buffer to the destination buffer as configured in the 148 /// Performs the copy from the source buffer to the destination buffer as configured in the
diff --git a/src/video_core/gpu.cpp b/src/video_core/gpu.cpp
index b86265dfe..ac30d1a89 100644
--- a/src/video_core/gpu.cpp
+++ b/src/video_core/gpu.cpp
@@ -28,14 +28,14 @@ u32 FramebufferConfig::BytesPerPixel(PixelFormat format) {
28 UNREACHABLE(); 28 UNREACHABLE();
29} 29}
30 30
31GPU::GPU(VideoCore::RasterizerInterface& rasterizer) { 31GPU::GPU(Core::System& system, VideoCore::RasterizerInterface& rasterizer) {
32 memory_manager = std::make_unique<Tegra::MemoryManager>(); 32 memory_manager = std::make_unique<Tegra::MemoryManager>();
33 dma_pusher = std::make_unique<Tegra::DmaPusher>(*this); 33 dma_pusher = std::make_unique<Tegra::DmaPusher>(*this);
34 maxwell_3d = std::make_unique<Engines::Maxwell3D>(rasterizer, *memory_manager); 34 maxwell_3d = std::make_unique<Engines::Maxwell3D>(system, rasterizer, *memory_manager);
35 fermi_2d = std::make_unique<Engines::Fermi2D>(rasterizer, *memory_manager); 35 fermi_2d = std::make_unique<Engines::Fermi2D>(rasterizer, *memory_manager);
36 kepler_compute = std::make_unique<Engines::KeplerCompute>(*memory_manager); 36 kepler_compute = std::make_unique<Engines::KeplerCompute>(*memory_manager);
37 maxwell_dma = std::make_unique<Engines::MaxwellDMA>(rasterizer, *memory_manager); 37 maxwell_dma = std::make_unique<Engines::MaxwellDMA>(system, rasterizer, *memory_manager);
38 kepler_memory = std::make_unique<Engines::KeplerMemory>(rasterizer, *memory_manager); 38 kepler_memory = std::make_unique<Engines::KeplerMemory>(system, rasterizer, *memory_manager);
39} 39}
40 40
41GPU::~GPU() = default; 41GPU::~GPU() = default;
diff --git a/src/video_core/gpu.h b/src/video_core/gpu.h
index a482196ea..0f5bfdcbf 100644
--- a/src/video_core/gpu.h
+++ b/src/video_core/gpu.h
@@ -6,12 +6,15 @@
6 6
7#include <array> 7#include <array>
8#include <memory> 8#include <memory>
9#include <vector>
10#include "common/common_types.h" 9#include "common/common_types.h"
11#include "core/hle/service/nvflinger/buffer_queue.h" 10#include "core/hle/service/nvflinger/buffer_queue.h"
12#include "video_core/dma_pusher.h" 11#include "video_core/dma_pusher.h"
13#include "video_core/memory_manager.h" 12#include "video_core/memory_manager.h"
14 13
14namespace Core {
15class System;
16}
17
15namespace VideoCore { 18namespace VideoCore {
16class RasterizerInterface; 19class RasterizerInterface;
17} 20}
@@ -118,7 +121,7 @@ enum class EngineID {
118 121
119class GPU final { 122class GPU final {
120public: 123public:
121 explicit GPU(VideoCore::RasterizerInterface& rasterizer); 124 explicit GPU(Core::System& system, VideoCore::RasterizerInterface& rasterizer);
122 ~GPU(); 125 ~GPU();
123 126
124 struct MethodCall { 127 struct MethodCall {