diff options
| author | 2019-02-20 21:24:56 -0500 | |
|---|---|---|
| committer | 2019-02-20 21:24:56 -0500 | |
| commit | ae437320c84e8c5fff69e8cec413e63b11f952b6 (patch) | |
| tree | d7f7f74d87fdaa6dd9ec829086e8c3814ae0506b | |
| parent | Fixes Unicode Key File Directories (#2120) (diff) | |
| parent | video_core: Remove usages of System::GetInstance() within the engines (diff) | |
| download | yuzu-ae437320c84e8c5fff69e8cec413e63b11f952b6.tar.gz yuzu-ae437320c84e8c5fff69e8cec413e63b11f952b6.tar.xz yuzu-ae437320c84e8c5fff69e8cec413e63b11f952b6.zip | |
Merge pull request #2130 from lioncash/system_engine
video_core: Remove usages of System::GetInstance() within the engines
| -rw-r--r-- | src/core/core.cpp | 2 | ||||
| -rw-r--r-- | src/video_core/engines/kepler_memory.cpp | 7 | ||||
| -rw-r--r-- | src/video_core/engines/kepler_memory.h | 9 | ||||
| -rw-r--r-- | src/video_core/engines/maxwell_3d.cpp | 12 | ||||
| -rw-r--r-- | src/video_core/engines/maxwell_3d.h | 9 | ||||
| -rw-r--r-- | src/video_core/engines/maxwell_dma.cpp | 8 | ||||
| -rw-r--r-- | src/video_core/engines/maxwell_dma.h | 10 | ||||
| -rw-r--r-- | src/video_core/gpu.cpp | 8 | ||||
| -rw-r--r-- | src/video_core/gpu.h | 7 |
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 | ||
| 12 | namespace Tegra::Engines { | 13 | namespace Tegra::Engines { |
| 13 | 14 | ||
| 14 | KeplerMemory::KeplerMemory(VideoCore::RasterizerInterface& rasterizer, | 15 | KeplerMemory::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 | ||
| 18 | KeplerMemory::~KeplerMemory() = default; | 19 | KeplerMemory::~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 | ||
| 14 | namespace Core { | ||
| 15 | class System; | ||
| 16 | } | ||
| 17 | |||
| 15 | namespace VideoCore { | 18 | namespace VideoCore { |
| 16 | class RasterizerInterface; | 19 | class RasterizerInterface; |
| 17 | } | 20 | } |
| @@ -23,7 +26,8 @@ namespace Tegra::Engines { | |||
| 23 | 26 | ||
| 24 | class KeplerMemory final { | 27 | class KeplerMemory final { |
| 25 | public: | 28 | public: |
| 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 | ||
| 78 | private: | 82 | private: |
| 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. |
| 20 | constexpr u32 MacroRegistersStart = 0xE00; | 20 | constexpr u32 MacroRegistersStart = 0xE00; |
| 21 | 21 | ||
| 22 | Maxwell3D::Maxwell3D(VideoCore::RasterizerInterface& rasterizer, MemoryManager& memory_manager) | 22 | Maxwell3D::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 | ||
| 105 | void Maxwell3D::CallMethod(const GPU::MethodCall& method_call) { | 107 | void 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 | ||
| 20 | namespace Core { | ||
| 21 | class System; | ||
| 22 | } | ||
| 23 | |||
| 20 | namespace VideoCore { | 24 | namespace VideoCore { |
| 21 | class RasterizerInterface; | 25 | class RasterizerInterface; |
| 22 | } | 26 | } |
| @@ -28,7 +32,8 @@ namespace Tegra::Engines { | |||
| 28 | 32 | ||
| 29 | class Maxwell3D final { | 33 | class Maxwell3D final { |
| 30 | public: | 34 | public: |
| 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: | |||
| 1131 | private: | 1136 | private: |
| 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 | ||
| 12 | namespace Tegra::Engines { | 13 | namespace Tegra::Engines { |
| 13 | 14 | ||
| 14 | MaxwellDMA::MaxwellDMA(VideoCore::RasterizerInterface& rasterizer, MemoryManager& memory_manager) | 15 | MaxwellDMA::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 | ||
| 17 | void MaxwellDMA::CallMethod(const GPU::MethodCall& method_call) { | 19 | void 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 | ||
| 14 | namespace Core { | ||
| 15 | class System; | ||
| 16 | } | ||
| 17 | |||
| 15 | namespace VideoCore { | 18 | namespace VideoCore { |
| 16 | class RasterizerInterface; | 19 | class RasterizerInterface; |
| 17 | } | 20 | } |
| @@ -20,7 +23,8 @@ namespace Tegra::Engines { | |||
| 20 | 23 | ||
| 21 | class MaxwellDMA final { | 24 | class MaxwellDMA final { |
| 22 | public: | 25 | public: |
| 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 | ||
| 139 | private: | 143 | private: |
| 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 | ||
| 31 | GPU::GPU(VideoCore::RasterizerInterface& rasterizer) { | 31 | GPU::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 | ||
| 41 | GPU::~GPU() = default; | 41 | GPU::~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 | ||
| 14 | namespace Core { | ||
| 15 | class System; | ||
| 16 | } | ||
| 17 | |||
| 15 | namespace VideoCore { | 18 | namespace VideoCore { |
| 16 | class RasterizerInterface; | 19 | class RasterizerInterface; |
| 17 | } | 20 | } |
| @@ -118,7 +121,7 @@ enum class EngineID { | |||
| 118 | 121 | ||
| 119 | class GPU final { | 122 | class GPU final { |
| 120 | public: | 123 | public: |
| 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 { |