summaryrefslogtreecommitdiff
path: root/src/video_core/engines
diff options
context:
space:
mode:
authorGravatar ReinUsesLisp2020-06-11 00:58:57 -0300
committerGravatar ReinUsesLisp2020-08-22 01:51:45 -0300
commitda53bcee60fced902479b72b40ed26b099fa9938 (patch)
treeb83232ad60b7725090b31bd3e347c9df774ced40 /src/video_core/engines
parentMerge pull request #4536 from lioncash/semi3 (diff)
downloadyuzu-da53bcee60fced902479b72b40ed26b099fa9938.tar.gz
yuzu-da53bcee60fced902479b72b40ed26b099fa9938.tar.xz
yuzu-da53bcee60fced902479b72b40ed26b099fa9938.zip
video_core: Initialize renderer with a GPU
Add an extra step in GPU initialization to be able to initialize render backends with a valid GPU instance.
Diffstat (limited to 'src/video_core/engines')
-rw-r--r--src/video_core/engines/fermi_2d.cpp10
-rw-r--r--src/video_core/engines/fermi_2d.h9
-rw-r--r--src/video_core/engines/kepler_compute.cpp17
-rw-r--r--src/video_core/engines/kepler_compute.h16
-rw-r--r--src/video_core/engines/maxwell_3d.cpp35
-rw-r--r--src/video_core/engines/maxwell_3d.h21
6 files changed, 63 insertions, 45 deletions
diff --git a/src/video_core/engines/fermi_2d.cpp b/src/video_core/engines/fermi_2d.cpp
index ff10ff40d..6e50661a3 100644
--- a/src/video_core/engines/fermi_2d.cpp
+++ b/src/video_core/engines/fermi_2d.cpp
@@ -10,7 +10,13 @@
10 10
11namespace Tegra::Engines { 11namespace Tegra::Engines {
12 12
13Fermi2D::Fermi2D(VideoCore::RasterizerInterface& rasterizer) : rasterizer{rasterizer} {} 13Fermi2D::Fermi2D() = default;
14
15Fermi2D::~Fermi2D() = default;
16
17void Fermi2D::BindRasterizer(VideoCore::RasterizerInterface& rasterizer_) {
18 rasterizer = &rasterizer_;
19}
14 20
15void Fermi2D::CallMethod(u32 method, u32 method_argument, bool is_last_call) { 21void Fermi2D::CallMethod(u32 method, u32 method_argument, bool is_last_call) {
16 ASSERT_MSG(method < Regs::NUM_REGS, 22 ASSERT_MSG(method < Regs::NUM_REGS,
@@ -87,7 +93,7 @@ void Fermi2D::HandleSurfaceCopy() {
87 copy_config.src_rect = src_rect; 93 copy_config.src_rect = src_rect;
88 copy_config.dst_rect = dst_rect; 94 copy_config.dst_rect = dst_rect;
89 95
90 if (!rasterizer.AccelerateSurfaceCopy(regs.src, regs.dst, copy_config)) { 96 if (!rasterizer->AccelerateSurfaceCopy(regs.src, regs.dst, copy_config)) {
91 UNIMPLEMENTED(); 97 UNIMPLEMENTED();
92 } 98 }
93} 99}
diff --git a/src/video_core/engines/fermi_2d.h b/src/video_core/engines/fermi_2d.h
index 8f37d053f..213abfaae 100644
--- a/src/video_core/engines/fermi_2d.h
+++ b/src/video_core/engines/fermi_2d.h
@@ -34,8 +34,11 @@ namespace Tegra::Engines {
34 34
35class Fermi2D final : public EngineInterface { 35class Fermi2D final : public EngineInterface {
36public: 36public:
37 explicit Fermi2D(VideoCore::RasterizerInterface& rasterizer); 37 explicit Fermi2D();
38 ~Fermi2D() = default; 38 ~Fermi2D();
39
40 /// Binds a rasterizer to this engine.
41 void BindRasterizer(VideoCore::RasterizerInterface& rasterizer);
39 42
40 /// Write the value to the register identified by method. 43 /// Write the value to the register identified by method.
41 void CallMethod(u32 method, u32 method_argument, bool is_last_call) override; 44 void CallMethod(u32 method, u32 method_argument, bool is_last_call) override;
@@ -149,7 +152,7 @@ public:
149 }; 152 };
150 153
151private: 154private:
152 VideoCore::RasterizerInterface& rasterizer; 155 VideoCore::RasterizerInterface* rasterizer;
153 156
154 /// Performs the copy from the source surface to the destination surface as configured in the 157 /// Performs the copy from the source surface to the destination surface as configured in the
155 /// registers. 158 /// registers.
diff --git a/src/video_core/engines/kepler_compute.cpp b/src/video_core/engines/kepler_compute.cpp
index a82b06a38..898370739 100644
--- a/src/video_core/engines/kepler_compute.cpp
+++ b/src/video_core/engines/kepler_compute.cpp
@@ -16,14 +16,15 @@
16 16
17namespace Tegra::Engines { 17namespace Tegra::Engines {
18 18
19KeplerCompute::KeplerCompute(Core::System& system, VideoCore::RasterizerInterface& rasterizer, 19KeplerCompute::KeplerCompute(Core::System& system_, MemoryManager& memory_manager_)
20 MemoryManager& memory_manager) 20 : system{system_}, memory_manager{memory_manager_}, upload_state{memory_manager, regs.upload} {}
21 : system{system}, rasterizer{rasterizer}, memory_manager{memory_manager}, upload_state{
22 memory_manager,
23 regs.upload} {}
24 21
25KeplerCompute::~KeplerCompute() = default; 22KeplerCompute::~KeplerCompute() = default;
26 23
24void KeplerCompute::BindRasterizer(VideoCore::RasterizerInterface& rasterizer_) {
25 rasterizer = &rasterizer_;
26}
27
27void KeplerCompute::CallMethod(u32 method, u32 method_argument, bool is_last_call) { 28void KeplerCompute::CallMethod(u32 method, u32 method_argument, bool is_last_call) {
28 ASSERT_MSG(method < Regs::NUM_REGS, 29 ASSERT_MSG(method < Regs::NUM_REGS,
29 "Invalid KeplerCompute register, increase the size of the Regs structure"); 30 "Invalid KeplerCompute register, increase the size of the Regs structure");
@@ -104,11 +105,11 @@ SamplerDescriptor KeplerCompute::AccessSampler(u32 handle) const {
104} 105}
105 106
106VideoCore::GuestDriverProfile& KeplerCompute::AccessGuestDriverProfile() { 107VideoCore::GuestDriverProfile& KeplerCompute::AccessGuestDriverProfile() {
107 return rasterizer.AccessGuestDriverProfile(); 108 return rasterizer->AccessGuestDriverProfile();
108} 109}
109 110
110const VideoCore::GuestDriverProfile& KeplerCompute::AccessGuestDriverProfile() const { 111const VideoCore::GuestDriverProfile& KeplerCompute::AccessGuestDriverProfile() const {
111 return rasterizer.AccessGuestDriverProfile(); 112 return rasterizer->AccessGuestDriverProfile();
112} 113}
113 114
114void KeplerCompute::ProcessLaunch() { 115void KeplerCompute::ProcessLaunch() {
@@ -119,7 +120,7 @@ void KeplerCompute::ProcessLaunch() {
119 const GPUVAddr code_addr = regs.code_loc.Address() + launch_description.program_start; 120 const GPUVAddr code_addr = regs.code_loc.Address() + launch_description.program_start;
120 LOG_TRACE(HW_GPU, "Compute invocation launched at address 0x{:016x}", code_addr); 121 LOG_TRACE(HW_GPU, "Compute invocation launched at address 0x{:016x}", code_addr);
121 122
122 rasterizer.DispatchCompute(code_addr); 123 rasterizer->DispatchCompute(code_addr);
123} 124}
124 125
125Texture::TICEntry KeplerCompute::GetTICEntry(u32 tic_index) const { 126Texture::TICEntry KeplerCompute::GetTICEntry(u32 tic_index) const {
diff --git a/src/video_core/engines/kepler_compute.h b/src/video_core/engines/kepler_compute.h
index b7f668d88..7f2500aab 100644
--- a/src/video_core/engines/kepler_compute.h
+++ b/src/video_core/engines/kepler_compute.h
@@ -42,10 +42,12 @@ namespace Tegra::Engines {
42 42
43class KeplerCompute final : public ConstBufferEngineInterface, public EngineInterface { 43class KeplerCompute final : public ConstBufferEngineInterface, public EngineInterface {
44public: 44public:
45 explicit KeplerCompute(Core::System& system, VideoCore::RasterizerInterface& rasterizer, 45 explicit KeplerCompute(Core::System& system, MemoryManager& memory_manager);
46 MemoryManager& memory_manager);
47 ~KeplerCompute(); 46 ~KeplerCompute();
48 47
48 /// Binds a rasterizer to this engine.
49 void BindRasterizer(VideoCore::RasterizerInterface& rasterizer);
50
49 static constexpr std::size_t NumConstBuffers = 8; 51 static constexpr std::size_t NumConstBuffers = 8;
50 52
51 struct Regs { 53 struct Regs {
@@ -230,11 +232,6 @@ public:
230 const VideoCore::GuestDriverProfile& AccessGuestDriverProfile() const override; 232 const VideoCore::GuestDriverProfile& AccessGuestDriverProfile() const override;
231 233
232private: 234private:
233 Core::System& system;
234 VideoCore::RasterizerInterface& rasterizer;
235 MemoryManager& memory_manager;
236 Upload::State upload_state;
237
238 void ProcessLaunch(); 235 void ProcessLaunch();
239 236
240 /// Retrieves information about a specific TIC entry from the TIC buffer. 237 /// Retrieves information about a specific TIC entry from the TIC buffer.
@@ -242,6 +239,11 @@ private:
242 239
243 /// Retrieves information about a specific TSC entry from the TSC buffer. 240 /// Retrieves information about a specific TSC entry from the TSC buffer.
244 Texture::TSCEntry GetTSCEntry(u32 tsc_index) const; 241 Texture::TSCEntry GetTSCEntry(u32 tsc_index) const;
242
243 Core::System& system;
244 MemoryManager& memory_manager;
245 VideoCore::RasterizerInterface* rasterizer = nullptr;
246 Upload::State upload_state;
245}; 247};
246 248
247#define ASSERT_REG_POSITION(field_name, position) \ 249#define ASSERT_REG_POSITION(field_name, position) \
diff --git a/src/video_core/engines/maxwell_3d.cpp b/src/video_core/engines/maxwell_3d.cpp
index c01436295..33854445f 100644
--- a/src/video_core/engines/maxwell_3d.cpp
+++ b/src/video_core/engines/maxwell_3d.cpp
@@ -22,14 +22,19 @@ using VideoCore::QueryType;
22/// First register id that is actually a Macro call. 22/// First register id that is actually a Macro call.
23constexpr u32 MacroRegistersStart = 0xE00; 23constexpr u32 MacroRegistersStart = 0xE00;
24 24
25Maxwell3D::Maxwell3D(Core::System& system, VideoCore::RasterizerInterface& rasterizer, 25Maxwell3D::Maxwell3D(Core::System& system_, MemoryManager& memory_manager_)
26 MemoryManager& memory_manager) 26 : system{system_}, memory_manager{memory_manager_}, macro_engine{GetMacroEngine(*this)},
27 : system{system}, rasterizer{rasterizer}, memory_manager{memory_manager}, 27 upload_state{memory_manager, regs.upload} {
28 macro_engine{GetMacroEngine(*this)}, upload_state{memory_manager, regs.upload} {
29 dirty.flags.flip(); 28 dirty.flags.flip();
30 InitializeRegisterDefaults(); 29 InitializeRegisterDefaults();
31} 30}
32 31
32Maxwell3D::~Maxwell3D() = default;
33
34void Maxwell3D::BindRasterizer(VideoCore::RasterizerInterface& rasterizer_) {
35 rasterizer = &rasterizer_;
36}
37
33void Maxwell3D::InitializeRegisterDefaults() { 38void Maxwell3D::InitializeRegisterDefaults() {
34 // Initializes registers to their default values - what games expect them to be at boot. This is 39 // Initializes registers to their default values - what games expect them to be at boot. This is
35 // for certain registers that may not be explicitly set by games. 40 // for certain registers that may not be explicitly set by games.
@@ -192,7 +197,7 @@ void Maxwell3D::CallMethod(u32 method, u32 method_argument, bool is_last_call) {
192 197
193 switch (method) { 198 switch (method) {
194 case MAXWELL3D_REG_INDEX(wait_for_idle): { 199 case MAXWELL3D_REG_INDEX(wait_for_idle): {
195 rasterizer.WaitForIdle(); 200 rasterizer->WaitForIdle();
196 break; 201 break;
197 } 202 }
198 case MAXWELL3D_REG_INDEX(shadow_ram_control): { 203 case MAXWELL3D_REG_INDEX(shadow_ram_control): {
@@ -402,7 +407,7 @@ void Maxwell3D::FlushMMEInlineDraw() {
402 407
403 const bool is_indexed = mme_draw.current_mode == MMEDrawMode::Indexed; 408 const bool is_indexed = mme_draw.current_mode == MMEDrawMode::Indexed;
404 if (ShouldExecute()) { 409 if (ShouldExecute()) {
405 rasterizer.Draw(is_indexed, true); 410 rasterizer->Draw(is_indexed, true);
406 } 411 }
407 412
408 // TODO(bunnei): Below, we reset vertex count so that we can use these registers to determine if 413 // TODO(bunnei): Below, we reset vertex count so that we can use these registers to determine if
@@ -465,7 +470,7 @@ void Maxwell3D::ProcessQueryGet() {
465 switch (regs.query.query_get.operation) { 470 switch (regs.query.query_get.operation) {
466 case Regs::QueryOperation::Release: 471 case Regs::QueryOperation::Release:
467 if (regs.query.query_get.fence == 1) { 472 if (regs.query.query_get.fence == 1) {
468 rasterizer.SignalSemaphore(regs.query.QueryAddress(), regs.query.query_sequence); 473 rasterizer->SignalSemaphore(regs.query.QueryAddress(), regs.query.query_sequence);
469 } else { 474 } else {
470 StampQueryResult(regs.query.query_sequence, regs.query.query_get.short_query == 0); 475 StampQueryResult(regs.query.query_sequence, regs.query.query_get.short_query == 0);
471 } 476 }
@@ -533,7 +538,7 @@ void Maxwell3D::ProcessQueryCondition() {
533void Maxwell3D::ProcessCounterReset() { 538void Maxwell3D::ProcessCounterReset() {
534 switch (regs.counter_reset) { 539 switch (regs.counter_reset) {
535 case Regs::CounterReset::SampleCnt: 540 case Regs::CounterReset::SampleCnt:
536 rasterizer.ResetCounter(QueryType::SamplesPassed); 541 rasterizer->ResetCounter(QueryType::SamplesPassed);
537 break; 542 break;
538 default: 543 default:
539 LOG_DEBUG(Render_OpenGL, "Unimplemented counter reset={}", 544 LOG_DEBUG(Render_OpenGL, "Unimplemented counter reset={}",
@@ -547,7 +552,7 @@ void Maxwell3D::ProcessSyncPoint() {
547 const u32 increment = regs.sync_info.increment.Value(); 552 const u32 increment = regs.sync_info.increment.Value();
548 [[maybe_unused]] const u32 cache_flush = regs.sync_info.unknown.Value(); 553 [[maybe_unused]] const u32 cache_flush = regs.sync_info.unknown.Value();
549 if (increment) { 554 if (increment) {
550 rasterizer.SignalSyncPoint(sync_point); 555 rasterizer->SignalSyncPoint(sync_point);
551 } 556 }
552} 557}
553 558
@@ -570,7 +575,7 @@ void Maxwell3D::DrawArrays() {
570 575
571 const bool is_indexed{regs.index_array.count && !regs.vertex_buffer.count}; 576 const bool is_indexed{regs.index_array.count && !regs.vertex_buffer.count};
572 if (ShouldExecute()) { 577 if (ShouldExecute()) {
573 rasterizer.Draw(is_indexed, false); 578 rasterizer->Draw(is_indexed, false);
574 } 579 }
575 580
576 // TODO(bunnei): Below, we reset vertex count so that we can use these registers to determine if 581 // TODO(bunnei): Below, we reset vertex count so that we can use these registers to determine if
@@ -590,8 +595,8 @@ std::optional<u64> Maxwell3D::GetQueryResult() {
590 return 0; 595 return 0;
591 case Regs::QuerySelect::SamplesPassed: 596 case Regs::QuerySelect::SamplesPassed:
592 // Deferred. 597 // Deferred.
593 rasterizer.Query(regs.query.QueryAddress(), VideoCore::QueryType::SamplesPassed, 598 rasterizer->Query(regs.query.QueryAddress(), VideoCore::QueryType::SamplesPassed,
594 system.GPU().GetTicks()); 599 system.GPU().GetTicks());
595 return {}; 600 return {};
596 default: 601 default:
597 LOG_DEBUG(HW_GPU, "Unimplemented query select type {}", 602 LOG_DEBUG(HW_GPU, "Unimplemented query select type {}",
@@ -718,7 +723,7 @@ void Maxwell3D::ProcessClearBuffers() {
718 regs.clear_buffers.R == regs.clear_buffers.B && 723 regs.clear_buffers.R == regs.clear_buffers.B &&
719 regs.clear_buffers.R == regs.clear_buffers.A); 724 regs.clear_buffers.R == regs.clear_buffers.A);
720 725
721 rasterizer.Clear(); 726 rasterizer->Clear();
722} 727}
723 728
724u32 Maxwell3D::AccessConstBuffer32(ShaderType stage, u64 const_buffer, u64 offset) const { 729u32 Maxwell3D::AccessConstBuffer32(ShaderType stage, u64 const_buffer, u64 offset) const {
@@ -752,11 +757,11 @@ SamplerDescriptor Maxwell3D::AccessSampler(u32 handle) const {
752} 757}
753 758
754VideoCore::GuestDriverProfile& Maxwell3D::AccessGuestDriverProfile() { 759VideoCore::GuestDriverProfile& Maxwell3D::AccessGuestDriverProfile() {
755 return rasterizer.AccessGuestDriverProfile(); 760 return rasterizer->AccessGuestDriverProfile();
756} 761}
757 762
758const VideoCore::GuestDriverProfile& Maxwell3D::AccessGuestDriverProfile() const { 763const VideoCore::GuestDriverProfile& Maxwell3D::AccessGuestDriverProfile() const {
759 return rasterizer.AccessGuestDriverProfile(); 764 return rasterizer->AccessGuestDriverProfile();
760} 765}
761 766
762} // namespace Tegra::Engines 767} // namespace Tegra::Engines
diff --git a/src/video_core/engines/maxwell_3d.h b/src/video_core/engines/maxwell_3d.h
index c97eeb792..bc289c55d 100644
--- a/src/video_core/engines/maxwell_3d.h
+++ b/src/video_core/engines/maxwell_3d.h
@@ -51,9 +51,11 @@ namespace Tegra::Engines {
51 51
52class Maxwell3D final : public ConstBufferEngineInterface, public EngineInterface { 52class Maxwell3D final : public ConstBufferEngineInterface, public EngineInterface {
53public: 53public:
54 explicit Maxwell3D(Core::System& system, VideoCore::RasterizerInterface& rasterizer, 54 explicit Maxwell3D(Core::System& system, MemoryManager& memory_manager);
55 MemoryManager& memory_manager); 55 ~Maxwell3D();
56 ~Maxwell3D() = default; 56
57 /// Binds a rasterizer to this engine.
58 void BindRasterizer(VideoCore::RasterizerInterface& rasterizer);
57 59
58 /// Register structure of the Maxwell3D engine. 60 /// Register structure of the Maxwell3D engine.
59 /// TODO(Subv): This structure will need to be made bigger as more registers are discovered. 61 /// TODO(Subv): This structure will need to be made bigger as more registers are discovered.
@@ -1418,12 +1420,12 @@ public:
1418 return execute_on; 1420 return execute_on;
1419 } 1421 }
1420 1422
1421 VideoCore::RasterizerInterface& GetRasterizer() { 1423 VideoCore::RasterizerInterface& Rasterizer() {
1422 return rasterizer; 1424 return *rasterizer;
1423 } 1425 }
1424 1426
1425 const VideoCore::RasterizerInterface& GetRasterizer() const { 1427 const VideoCore::RasterizerInterface& Rasterizer() const {
1426 return rasterizer; 1428 return *rasterizer;
1427 } 1429 }
1428 1430
1429 /// Notify a memory write has happened. 1431 /// Notify a memory write has happened.
@@ -1460,11 +1462,10 @@ private:
1460 void InitializeRegisterDefaults(); 1462 void InitializeRegisterDefaults();
1461 1463
1462 Core::System& system; 1464 Core::System& system;
1463
1464 VideoCore::RasterizerInterface& rasterizer;
1465
1466 MemoryManager& memory_manager; 1465 MemoryManager& memory_manager;
1467 1466
1467 VideoCore::RasterizerInterface* rasterizer = nullptr;
1468
1468 /// Start offsets of each macro in macro_memory 1469 /// Start offsets of each macro in macro_memory
1469 std::array<u32, 0x80> macro_positions = {}; 1470 std::array<u32, 0x80> macro_positions = {};
1470 1471