summaryrefslogtreecommitdiff
path: root/src/video_core/engines
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/video_core/engines
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/video_core/engines')
-rw-r--r--src/video_core/engines/maxwell_3d.cpp10
-rw-r--r--src/video_core/engines/maxwell_3d.h8
2 files changed, 12 insertions, 6 deletions
diff --git a/src/video_core/engines/maxwell_3d.cpp b/src/video_core/engines/maxwell_3d.cpp
index 0e205ed72..a235b543e 100644
--- a/src/video_core/engines/maxwell_3d.cpp
+++ b/src/video_core/engines/maxwell_3d.cpp
@@ -19,8 +19,8 @@ namespace 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(MemoryManager& memory_manager) 22Maxwell3D::Maxwell3D(VideoCore::RasterizerInterface& rasterizer, MemoryManager& memory_manager)
23 : memory_manager(memory_manager), macro_interpreter(*this) {} 23 : memory_manager(memory_manager), rasterizer{rasterizer}, macro_interpreter(*this) {}
24 24
25void Maxwell3D::CallMacroMethod(u32 method, std::vector<u32> parameters) { 25void Maxwell3D::CallMacroMethod(u32 method, std::vector<u32> parameters) {
26 auto macro_code = uploaded_macros.find(method); 26 auto macro_code = uploaded_macros.find(method);
@@ -130,7 +130,7 @@ void Maxwell3D::WriteReg(u32 method, u32 value, u32 remaining_params) {
130 break; 130 break;
131 } 131 }
132 132
133 VideoCore::g_renderer->Rasterizer()->NotifyMaxwellRegisterChanged(method); 133 rasterizer.NotifyMaxwellRegisterChanged(method);
134 134
135 if (debug_context) { 135 if (debug_context) {
136 debug_context->OnEvent(Tegra::DebugContext::Event::MaxwellCommandProcessed, nullptr); 136 debug_context->OnEvent(Tegra::DebugContext::Event::MaxwellCommandProcessed, nullptr);
@@ -218,7 +218,7 @@ void Maxwell3D::DrawArrays() {
218 } 218 }
219 219
220 const bool is_indexed{regs.index_array.count && !regs.vertex_buffer.count}; 220 const bool is_indexed{regs.index_array.count && !regs.vertex_buffer.count};
221 VideoCore::g_renderer->Rasterizer()->AccelerateDrawBatch(is_indexed); 221 rasterizer.AccelerateDrawBatch(is_indexed);
222 222
223 // TODO(bunnei): Below, we reset vertex count so that we can use these registers to determine if 223 // TODO(bunnei): Below, we reset vertex count so that we can use these registers to determine if
224 // the game is trying to draw indexed or direct mode. This needs to be verified on HW still - 224 // the game is trying to draw indexed or direct mode. This needs to be verified on HW still -
@@ -393,7 +393,7 @@ void Maxwell3D::ProcessClearBuffers() {
393 regs.clear_buffers.R == regs.clear_buffers.B && 393 regs.clear_buffers.R == regs.clear_buffers.B &&
394 regs.clear_buffers.R == regs.clear_buffers.A); 394 regs.clear_buffers.R == regs.clear_buffers.A);
395 395
396 VideoCore::g_renderer->Rasterizer()->Clear(); 396 rasterizer.Clear();
397} 397}
398 398
399} // namespace Engines 399} // namespace Engines
diff --git a/src/video_core/engines/maxwell_3d.h b/src/video_core/engines/maxwell_3d.h
index 3c32f1067..4d0ff96a5 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 VideoCore {
21class RasterizerInterface;
22}
23
20namespace Tegra::Engines { 24namespace Tegra::Engines {
21 25
22#define MAXWELL3D_REG_INDEX(field_name) \ 26#define MAXWELL3D_REG_INDEX(field_name) \
@@ -24,7 +28,7 @@ namespace Tegra::Engines {
24 28
25class Maxwell3D final { 29class Maxwell3D final {
26public: 30public:
27 explicit Maxwell3D(MemoryManager& memory_manager); 31 explicit Maxwell3D(VideoCore::RasterizerInterface& rasterizer, MemoryManager& memory_manager);
28 ~Maxwell3D() = default; 32 ~Maxwell3D() = default;
29 33
30 /// Register structure of the Maxwell3D engine. 34 /// Register structure of the Maxwell3D engine.
@@ -818,6 +822,8 @@ public:
818 Texture::FullTextureInfo GetStageTexture(Regs::ShaderStage stage, size_t offset) const; 822 Texture::FullTextureInfo GetStageTexture(Regs::ShaderStage stage, size_t offset) const;
819 823
820private: 824private:
825 VideoCore::RasterizerInterface& rasterizer;
826
821 std::unordered_map<u32, std::vector<u32>> uploaded_macros; 827 std::unordered_map<u32, std::vector<u32>> uploaded_macros;
822 828
823 /// Macro method that is currently being executed / being fed parameters. 829 /// Macro method that is currently being executed / being fed parameters.