summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Markus Wick2018-09-06 17:02:46 +0200
committerGravatar Markus Wick2018-09-10 22:06:16 +0200
commitc1b8cd90589141feb182da0d48c335bd624a4793 (patch)
tree224018fc0aed7e56980e2bf9e063f3770b99539e
parentvideo_core: Move command buffer loop. (diff)
downloadyuzu-c1b8cd90589141feb182da0d48c335bd624a4793.tar.gz
yuzu-c1b8cd90589141feb182da0d48c335bd624a4793.tar.xz
yuzu-c1b8cd90589141feb182da0d48c335bd624a4793.zip
video_core: Refactor command_processor.
Inline the WriteReg helper as it is called ~20k times per frame.
Diffstat (limited to '')
-rw-r--r--src/video_core/command_processor.cpp83
-rw-r--r--src/video_core/gpu.h3
2 files changed, 42 insertions, 44 deletions
diff --git a/src/video_core/command_processor.cpp b/src/video_core/command_processor.cpp
index e0c277105..2625ddfdc 100644
--- a/src/video_core/command_processor.cpp
+++ b/src/video_core/command_processor.cpp
@@ -28,51 +28,52 @@ enum class BufferMethods {
28 CountBufferMethods = 0x40, 28 CountBufferMethods = 0x40,
29}; 29};
30 30
31void GPU::WriteReg(u32 method, u32 subchannel, u32 value, u32 remaining_params) {
32 LOG_TRACE(HW_GPU,
33 "Processing method {:08X} on subchannel {} value "
34 "{:08X} remaining params {}",
35 method, subchannel, value, remaining_params);
36
37 ASSERT(subchannel < bound_engines.size());
38
39 if (method == static_cast<u32>(BufferMethods::BindObject)) {
40 // Bind the current subchannel to the desired engine id.
41 LOG_DEBUG(HW_GPU, "Binding subchannel {} to engine {}", subchannel, value);
42 bound_engines[subchannel] = static_cast<EngineID>(value);
43 return;
44 }
45
46 if (method < static_cast<u32>(BufferMethods::CountBufferMethods)) {
47 // TODO(Subv): Research and implement these methods.
48 LOG_ERROR(HW_GPU, "Special buffer methods other than Bind are not implemented");
49 return;
50 }
51
52 const EngineID engine = bound_engines[subchannel];
53
54 switch (engine) {
55 case EngineID::FERMI_TWOD_A:
56 fermi_2d->WriteReg(method, value);
57 break;
58 case EngineID::MAXWELL_B:
59 maxwell_3d->WriteReg(method, value, remaining_params);
60 break;
61 case EngineID::MAXWELL_COMPUTE_B:
62 maxwell_compute->WriteReg(method, value);
63 break;
64 case EngineID::MAXWELL_DMA_COPY_A:
65 maxwell_dma->WriteReg(method, value);
66 break;
67 default:
68 UNIMPLEMENTED_MSG("Unimplemented engine");
69 }
70}
71
72MICROPROFILE_DEFINE(ProcessCommandLists, "GPU", "Execute command buffer", MP_RGB(128, 128, 192)); 31MICROPROFILE_DEFINE(ProcessCommandLists, "GPU", "Execute command buffer", MP_RGB(128, 128, 192));
73 32
74void GPU::ProcessCommandLists(const std::vector<CommandListHeader>& commands) { 33void GPU::ProcessCommandLists(const std::vector<CommandListHeader>& commands) {
75 MICROPROFILE_SCOPE(ProcessCommandLists); 34 MICROPROFILE_SCOPE(ProcessCommandLists);
35
36 auto WriteReg = [this](u32 method, u32 subchannel, u32 value, u32 remaining_params) {
37 LOG_TRACE(HW_GPU,
38 "Processing method {:08X} on subchannel {} value "
39 "{:08X} remaining params {}",
40 method, subchannel, value, remaining_params);
41
42 ASSERT(subchannel < bound_engines.size());
43
44 if (method == static_cast<u32>(BufferMethods::BindObject)) {
45 // Bind the current subchannel to the desired engine id.
46 LOG_DEBUG(HW_GPU, "Binding subchannel {} to engine {}", subchannel, value);
47 bound_engines[subchannel] = static_cast<EngineID>(value);
48 return;
49 }
50
51 if (method < static_cast<u32>(BufferMethods::CountBufferMethods)) {
52 // TODO(Subv): Research and implement these methods.
53 LOG_ERROR(HW_GPU, "Special buffer methods other than Bind are not implemented");
54 return;
55 }
56
57 const EngineID engine = bound_engines[subchannel];
58
59 switch (engine) {
60 case EngineID::FERMI_TWOD_A:
61 fermi_2d->WriteReg(method, value);
62 break;
63 case EngineID::MAXWELL_B:
64 maxwell_3d->WriteReg(method, value, remaining_params);
65 break;
66 case EngineID::MAXWELL_COMPUTE_B:
67 maxwell_compute->WriteReg(method, value);
68 break;
69 case EngineID::MAXWELL_DMA_COPY_A:
70 maxwell_dma->WriteReg(method, value);
71 break;
72 default:
73 UNIMPLEMENTED_MSG("Unimplemented engine");
74 }
75 };
76
76 for (auto entry : commands) { 77 for (auto entry : commands) {
77 Tegra::GPUVAddr address = entry.Address(); 78 Tegra::GPUVAddr address = entry.Address();
78 u32 size = entry.sz; 79 u32 size = entry.sz;
diff --git a/src/video_core/gpu.h b/src/video_core/gpu.h
index 9163fbdc6..4f71f99d7 100644
--- a/src/video_core/gpu.h
+++ b/src/video_core/gpu.h
@@ -132,9 +132,6 @@ public:
132 const Tegra::MemoryManager& MemoryManager() const; 132 const Tegra::MemoryManager& MemoryManager() const;
133 133
134private: 134private:
135 /// Writes a single register in the engine bound to the specified subchannel
136 void WriteReg(u32 method, u32 subchannel, u32 value, u32 remaining_params);
137
138 std::unique_ptr<Tegra::MemoryManager> memory_manager; 135 std::unique_ptr<Tegra::MemoryManager> memory_manager;
139 136
140 /// Mapping of command subchannels to their bound engine ids. 137 /// Mapping of command subchannels to their bound engine ids.