summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Fernando Sahmkow2020-04-20 02:16:56 -0400
committerGravatar Fernando Sahmkow2020-04-23 08:52:55 -0400
commit3fedcc2f6e001f0ed1fd791de4f9692570359eef (patch)
tree49109516beab33d825cc653d4e885107304da332
parentMerge pull request #3730 from lioncash/time (diff)
downloadyuzu-3fedcc2f6e001f0ed1fd791de4f9692570359eef.tar.gz
yuzu-3fedcc2f6e001f0ed1fd791de4f9692570359eef.tar.xz
yuzu-3fedcc2f6e001f0ed1fd791de4f9692570359eef.zip
DMAPusher: Propagate multimethod writes into the engines.
-rw-r--r--src/video_core/dma_pusher.cpp30
-rw-r--r--src/video_core/dma_pusher.h1
-rw-r--r--src/video_core/engines/fermi_2d.cpp6
-rw-r--r--src/video_core/engines/fermi_2d.h3
-rw-r--r--src/video_core/engines/kepler_compute.cpp6
-rw-r--r--src/video_core/engines/kepler_compute.h3
-rw-r--r--src/video_core/engines/kepler_memory.cpp6
-rw-r--r--src/video_core/engines/kepler_memory.h3
-rw-r--r--src/video_core/engines/maxwell_3d.cpp52
-rw-r--r--src/video_core/engines/maxwell_3d.h4
-rw-r--r--src/video_core/engines/maxwell_dma.cpp6
-rw-r--r--src/video_core/engines/maxwell_dma.h3
-rw-r--r--src/video_core/gpu.cpp47
-rw-r--r--src/video_core/gpu.h8
14 files changed, 164 insertions, 14 deletions
diff --git a/src/video_core/dma_pusher.cpp b/src/video_core/dma_pusher.cpp
index 324dafdcd..16311f05e 100644
--- a/src/video_core/dma_pusher.cpp
+++ b/src/video_core/dma_pusher.cpp
@@ -71,16 +71,22 @@ bool DmaPusher::Step() {
71 gpu.MemoryManager().ReadBlockUnsafe(dma_get, command_headers.data(), 71 gpu.MemoryManager().ReadBlockUnsafe(dma_get, command_headers.data(),
72 command_list_header.size * sizeof(u32)); 72 command_list_header.size * sizeof(u32));
73 73
74 for (const CommandHeader& command_header : command_headers) { 74 for (std::size_t index = 0; index < command_headers.size();) {
75 75 const CommandHeader& command_header = command_headers[index];
76 // now, see if we're in the middle of a command 76
77 if (dma_state.length_pending) { 77 if (dma_state.method_count) {
78 // Second word of long non-inc methods command - method count
79 dma_state.length_pending = 0;
80 dma_state.method_count = command_header.method_count_;
81 } else if (dma_state.method_count) {
82 // Data word of methods command 78 // Data word of methods command
83 CallMethod(command_header.argument); 79 if (dma_state.non_incrementing) {
80 const u32 max_write = static_cast<u32>(
81 std::min<std::size_t>(index + dma_state.method_count, command_headers.size()) -
82 index);
83 CallMultiMethod(&command_header.argument, max_write);
84 dma_state.method_count -= max_write;
85 index += max_write;
86 continue;
87 } else {
88 CallMethod(command_header.argument);
89 }
84 90
85 if (!dma_state.non_incrementing) { 91 if (!dma_state.non_incrementing) {
86 dma_state.method++; 92 dma_state.method++;
@@ -120,6 +126,7 @@ bool DmaPusher::Step() {
120 break; 126 break;
121 } 127 }
122 } 128 }
129 index++;
123 } 130 }
124 131
125 if (!non_main) { 132 if (!non_main) {
@@ -140,4 +147,9 @@ void DmaPusher::CallMethod(u32 argument) const {
140 gpu.CallMethod({dma_state.method, argument, dma_state.subchannel, dma_state.method_count}); 147 gpu.CallMethod({dma_state.method, argument, dma_state.subchannel, dma_state.method_count});
141} 148}
142 149
150void DmaPusher::CallMultiMethod(const u32* base_start, u32 num_methods) const {
151 gpu.CallMultiMethod(dma_state.method, dma_state.subchannel, base_start, num_methods,
152 dma_state.method_count);
153}
154
143} // namespace Tegra 155} // namespace Tegra
diff --git a/src/video_core/dma_pusher.h b/src/video_core/dma_pusher.h
index d6188614a..6cef71306 100644
--- a/src/video_core/dma_pusher.h
+++ b/src/video_core/dma_pusher.h
@@ -75,6 +75,7 @@ private:
75 void SetState(const CommandHeader& command_header); 75 void SetState(const CommandHeader& command_header);
76 76
77 void CallMethod(u32 argument) const; 77 void CallMethod(u32 argument) const;
78 void CallMultiMethod(const u32* base_start, u32 num_methods) const;
78 79
79 std::vector<CommandHeader> command_headers; ///< Buffer for list of commands fetched at once 80 std::vector<CommandHeader> command_headers; ///< Buffer for list of commands fetched at once
80 81
diff --git a/src/video_core/engines/fermi_2d.cpp b/src/video_core/engines/fermi_2d.cpp
index bace6affb..8a47614d2 100644
--- a/src/video_core/engines/fermi_2d.cpp
+++ b/src/video_core/engines/fermi_2d.cpp
@@ -28,6 +28,12 @@ void Fermi2D::CallMethod(const GPU::MethodCall& method_call) {
28 } 28 }
29} 29}
30 30
31void Fermi2D::CallMultiMethod(u32 method, const u32* base_start, u32 amount, u32 methods_pending) {
32 for (std::size_t i = 0; i < amount; i++) {
33 CallMethod({method, base_start[i], 0, methods_pending - static_cast<u32>(i)});
34 }
35}
36
31static std::pair<u32, u32> DelimitLine(u32 src_1, u32 src_2, u32 dst_1, u32 dst_2, u32 src_line) { 37static std::pair<u32, u32> DelimitLine(u32 src_1, u32 src_2, u32 dst_1, u32 dst_2, u32 src_line) {
32 const u32 line_a = src_2 - src_1; 38 const u32 line_a = src_2 - src_1;
33 const u32 line_b = dst_2 - dst_1; 39 const u32 line_b = dst_2 - dst_1;
diff --git a/src/video_core/engines/fermi_2d.h b/src/video_core/engines/fermi_2d.h
index dba342c70..939a5966d 100644
--- a/src/video_core/engines/fermi_2d.h
+++ b/src/video_core/engines/fermi_2d.h
@@ -39,6 +39,9 @@ public:
39 /// Write the value to the register identified by method. 39 /// Write the value to the register identified by method.
40 void CallMethod(const GPU::MethodCall& method_call); 40 void CallMethod(const GPU::MethodCall& method_call);
41 41
42 /// Write multiple values to the register identified by method.
43 void CallMultiMethod(u32 method, const u32* base_start, u32 amount, u32 methods_pending);
44
42 enum class Origin : u32 { 45 enum class Origin : u32 {
43 Center = 0, 46 Center = 0,
44 Corner = 1, 47 Corner = 1,
diff --git a/src/video_core/engines/kepler_compute.cpp b/src/video_core/engines/kepler_compute.cpp
index 368c75a66..894300f57 100644
--- a/src/video_core/engines/kepler_compute.cpp
+++ b/src/video_core/engines/kepler_compute.cpp
@@ -51,6 +51,12 @@ void KeplerCompute::CallMethod(const GPU::MethodCall& method_call) {
51 } 51 }
52} 52}
53 53
54void KeplerCompute::CallMultiMethod(u32 method, const u32* base_start, u32 amount, u32 methods_pending) {
55 for (std::size_t i = 0; i < amount; i++) {
56 CallMethod({method, base_start[i], 0, methods_pending - static_cast<u32>(i)});
57 }
58}
59
54Texture::FullTextureInfo KeplerCompute::GetTexture(std::size_t offset) const { 60Texture::FullTextureInfo KeplerCompute::GetTexture(std::size_t offset) const {
55 const std::bitset<8> cbuf_mask = launch_description.const_buffer_enable_mask.Value(); 61 const std::bitset<8> cbuf_mask = launch_description.const_buffer_enable_mask.Value();
56 ASSERT(cbuf_mask[regs.tex_cb_index]); 62 ASSERT(cbuf_mask[regs.tex_cb_index]);
diff --git a/src/video_core/engines/kepler_compute.h b/src/video_core/engines/kepler_compute.h
index eeb79c56f..fe55fdfd0 100644
--- a/src/video_core/engines/kepler_compute.h
+++ b/src/video_core/engines/kepler_compute.h
@@ -202,6 +202,9 @@ public:
202 /// Write the value to the register identified by method. 202 /// Write the value to the register identified by method.
203 void CallMethod(const GPU::MethodCall& method_call); 203 void CallMethod(const GPU::MethodCall& method_call);
204 204
205 /// Write multiple values to the register identified by method.
206 void CallMultiMethod(u32 method, const u32* base_start, u32 amount, u32 methods_pending);
207
205 Texture::FullTextureInfo GetTexture(std::size_t offset) const; 208 Texture::FullTextureInfo GetTexture(std::size_t offset) const;
206 209
207 /// Given a texture handle, returns the TSC and TIC entries. 210 /// Given a texture handle, returns the TSC and TIC entries.
diff --git a/src/video_core/engines/kepler_memory.cpp b/src/video_core/engines/kepler_memory.cpp
index 597872e43..e906a1124 100644
--- a/src/video_core/engines/kepler_memory.cpp
+++ b/src/video_core/engines/kepler_memory.cpp
@@ -41,4 +41,10 @@ void KeplerMemory::CallMethod(const GPU::MethodCall& method_call) {
41 } 41 }
42} 42}
43 43
44void KeplerMemory::CallMultiMethod(u32 method, const u32* base_start, u32 amount, u32 methods_pending) {
45 for (std::size_t i = 0; i < amount; i++) {
46 CallMethod({method, base_start[i], 0, methods_pending - static_cast<u32>(i)});
47 }
48}
49
44} // namespace Tegra::Engines 50} // namespace Tegra::Engines
diff --git a/src/video_core/engines/kepler_memory.h b/src/video_core/engines/kepler_memory.h
index 396fb6e86..bb26fb030 100644
--- a/src/video_core/engines/kepler_memory.h
+++ b/src/video_core/engines/kepler_memory.h
@@ -40,6 +40,9 @@ public:
40 /// Write the value to the register identified by method. 40 /// Write the value to the register identified by method.
41 void CallMethod(const GPU::MethodCall& method_call); 41 void CallMethod(const GPU::MethodCall& method_call);
42 42
43 /// Write multiple values to the register identified by method.
44 void CallMultiMethod(u32 method, const u32* base_start, u32 amount, u32 methods_pending);
45
43 struct Regs { 46 struct Regs {
44 static constexpr size_t NUM_REGS = 0x7F; 47 static constexpr size_t NUM_REGS = 0x7F;
45 48
diff --git a/src/video_core/engines/maxwell_3d.cpp b/src/video_core/engines/maxwell_3d.cpp
index 2824ed707..879ce542a 100644
--- a/src/video_core/engines/maxwell_3d.cpp
+++ b/src/video_core/engines/maxwell_3d.cpp
@@ -280,6 +280,36 @@ void Maxwell3D::CallMethod(const GPU::MethodCall& method_call) {
280 } 280 }
281} 281}
282 282
283void Maxwell3D::CallMultiMethod(u32 method, const u32* base_start, u32 amount, u32 methods_pending) {
284 switch (method) {
285 case MAXWELL3D_REG_INDEX(const_buffer.cb_data[0]):
286 case MAXWELL3D_REG_INDEX(const_buffer.cb_data[1]):
287 case MAXWELL3D_REG_INDEX(const_buffer.cb_data[2]):
288 case MAXWELL3D_REG_INDEX(const_buffer.cb_data[3]):
289 case MAXWELL3D_REG_INDEX(const_buffer.cb_data[4]):
290 case MAXWELL3D_REG_INDEX(const_buffer.cb_data[5]):
291 case MAXWELL3D_REG_INDEX(const_buffer.cb_data[6]):
292 case MAXWELL3D_REG_INDEX(const_buffer.cb_data[7]):
293 case MAXWELL3D_REG_INDEX(const_buffer.cb_data[8]):
294 case MAXWELL3D_REG_INDEX(const_buffer.cb_data[9]):
295 case MAXWELL3D_REG_INDEX(const_buffer.cb_data[10]):
296 case MAXWELL3D_REG_INDEX(const_buffer.cb_data[11]):
297 case MAXWELL3D_REG_INDEX(const_buffer.cb_data[12]):
298 case MAXWELL3D_REG_INDEX(const_buffer.cb_data[13]):
299 case MAXWELL3D_REG_INDEX(const_buffer.cb_data[14]):
300 case MAXWELL3D_REG_INDEX(const_buffer.cb_data[15]): {
301 ProcessCBMultiData(method, base_start, amount);
302 break;
303 }
304 default: {
305 for (std::size_t i = 0; i < amount; i++) {
306 CallMethod({method, base_start[i], 0, methods_pending - static_cast<u32>(i)});
307 }
308 }
309 }
310
311}
312
283void Maxwell3D::StepInstance(const MMEDrawMode expected_mode, const u32 count) { 313void Maxwell3D::StepInstance(const MMEDrawMode expected_mode, const u32 count) {
284 if (mme_draw.current_mode == MMEDrawMode::Undefined) { 314 if (mme_draw.current_mode == MMEDrawMode::Undefined) {
285 if (mme_draw.gl_begin_consume) { 315 if (mme_draw.gl_begin_consume) {
@@ -570,6 +600,28 @@ void Maxwell3D::StartCBData(u32 method) {
570 ProcessCBData(regs.const_buffer.cb_data[cb_data_state.id]); 600 ProcessCBData(regs.const_buffer.cb_data[cb_data_state.id]);
571} 601}
572 602
603void Maxwell3D::ProcessCBMultiData(u32 method, const u32* start_base, u32 amount) {
604 if (cb_data_state.current != method) {
605 if (cb_data_state.current != null_cb_data) {
606 FinishCBData();
607 }
608 constexpr u32 first_cb_data = MAXWELL3D_REG_INDEX(const_buffer.cb_data[0]);
609 cb_data_state.start_pos = regs.const_buffer.cb_pos;
610 cb_data_state.id = method - first_cb_data;
611 cb_data_state.current = method;
612 cb_data_state.counter = 0;
613 }
614 const std::size_t id = cb_data_state.id;
615 const std::size_t size = amount;
616 std::size_t i = 0;
617 for (; i < size; i++) {
618 cb_data_state.buffer[id][cb_data_state.counter] = start_base[i];
619 cb_data_state.counter++;
620 }
621 // Increment the current buffer position.
622 regs.const_buffer.cb_pos = regs.const_buffer.cb_pos + 4 * amount;
623}
624
573void Maxwell3D::FinishCBData() { 625void Maxwell3D::FinishCBData() {
574 // Write the input value to the current const buffer at the current position. 626 // Write the input value to the current const buffer at the current position.
575 const GPUVAddr buffer_address = regs.const_buffer.BufferAddress(); 627 const GPUVAddr buffer_address = regs.const_buffer.BufferAddress();
diff --git a/src/video_core/engines/maxwell_3d.h b/src/video_core/engines/maxwell_3d.h
index 59d5752d2..cfcda4f53 100644
--- a/src/video_core/engines/maxwell_3d.h
+++ b/src/video_core/engines/maxwell_3d.h
@@ -1358,6 +1358,9 @@ public:
1358 /// Write the value to the register identified by method. 1358 /// Write the value to the register identified by method.
1359 void CallMethod(const GPU::MethodCall& method_call); 1359 void CallMethod(const GPU::MethodCall& method_call);
1360 1360
1361 /// Write multiple values to the register identified by method.
1362 void CallMultiMethod(u32 method, const u32* base_start, u32 amount, u32 methods_pending);
1363
1361 /// Write the value to the register identified by method. 1364 /// Write the value to the register identified by method.
1362 void CallMethodFromMME(const GPU::MethodCall& method_call); 1365 void CallMethodFromMME(const GPU::MethodCall& method_call);
1363 1366
@@ -1511,6 +1514,7 @@ private:
1511 /// Handles a write to the CB_DATA[i] register. 1514 /// Handles a write to the CB_DATA[i] register.
1512 void StartCBData(u32 method); 1515 void StartCBData(u32 method);
1513 void ProcessCBData(u32 value); 1516 void ProcessCBData(u32 value);
1517 void ProcessCBMultiData(u32 method, const u32* start_base, u32 amount);
1514 void FinishCBData(); 1518 void FinishCBData();
1515 1519
1516 /// Handles a write to the CB_BIND register. 1520 /// Handles a write to the CB_BIND register.
diff --git a/src/video_core/engines/maxwell_dma.cpp b/src/video_core/engines/maxwell_dma.cpp
index 3bfed6ab8..51e606a10 100644
--- a/src/video_core/engines/maxwell_dma.cpp
+++ b/src/video_core/engines/maxwell_dma.cpp
@@ -36,6 +36,12 @@ void MaxwellDMA::CallMethod(const GPU::MethodCall& method_call) {
36#undef MAXWELLDMA_REG_INDEX 36#undef MAXWELLDMA_REG_INDEX
37} 37}
38 38
39void MaxwellDMA::CallMultiMethod(u32 method, const u32* base_start, u32 amount, u32 methods_pending) {
40 for (std::size_t i = 0; i < amount; i++) {
41 CallMethod({method, base_start[i], 0, methods_pending - static_cast<u32>(i)});
42 }
43}
44
39void MaxwellDMA::HandleCopy() { 45void MaxwellDMA::HandleCopy() {
40 LOG_TRACE(HW_GPU, "Requested a DMA copy"); 46 LOG_TRACE(HW_GPU, "Requested a DMA copy");
41 47
diff --git a/src/video_core/engines/maxwell_dma.h b/src/video_core/engines/maxwell_dma.h
index 4f40d1d1f..c43ed8194 100644
--- a/src/video_core/engines/maxwell_dma.h
+++ b/src/video_core/engines/maxwell_dma.h
@@ -35,6 +35,9 @@ public:
35 /// Write the value to the register identified by method. 35 /// Write the value to the register identified by method.
36 void CallMethod(const GPU::MethodCall& method_call); 36 void CallMethod(const GPU::MethodCall& method_call);
37 37
38 /// Write multiple values to the register identified by method.
39 void CallMultiMethod(u32 method, const u32* base_start, u32 amount, u32 methods_pending);
40
38 struct Regs { 41 struct Regs {
39 static constexpr std::size_t NUM_REGS = 0x1D6; 42 static constexpr std::size_t NUM_REGS = 0x1D6;
40 43
diff --git a/src/video_core/gpu.cpp b/src/video_core/gpu.cpp
index 3b7572d61..54e7876a6 100644
--- a/src/video_core/gpu.cpp
+++ b/src/video_core/gpu.cpp
@@ -209,16 +209,31 @@ void GPU::CallMethod(const MethodCall& method_call) {
209 209
210 ASSERT(method_call.subchannel < bound_engines.size()); 210 ASSERT(method_call.subchannel < bound_engines.size());
211 211
212 if (ExecuteMethodOnEngine(method_call)) { 212 if (ExecuteMethodOnEngine(method_call.method)) {
213 CallEngineMethod(method_call); 213 CallEngineMethod(method_call);
214 } else { 214 } else {
215 CallPullerMethod(method_call); 215 CallPullerMethod(method_call);
216 } 216 }
217} 217}
218 218
219bool GPU::ExecuteMethodOnEngine(const MethodCall& method_call) { 219void GPU::CallMultiMethod(u32 method, u32 subchannel, const u32* base_start, u32 amount, u32 methods_pending) {
220 const auto method = static_cast<BufferMethods>(method_call.method); 220 LOG_TRACE(HW_GPU, "Processing method {:08X} on subchannel {}", method,
221 return method >= BufferMethods::NonPullerMethods; 221 subchannel);
222
223 ASSERT(subchannel < bound_engines.size());
224
225 if (ExecuteMethodOnEngine(method)) {
226 CallEngineMultiMethod(method, subchannel, base_start, amount, methods_pending);
227 } else {
228 for (std::size_t i = 0; i < amount; i++) {
229 CallPullerMethod({method, base_start[i], subchannel, methods_pending - static_cast<u32>(i)});
230 }
231 }
232}
233
234bool GPU::ExecuteMethodOnEngine(u32 method) {
235 const auto buffer_method = static_cast<BufferMethods>(method);
236 return buffer_method >= BufferMethods::NonPullerMethods;
222} 237}
223 238
224void GPU::CallPullerMethod(const MethodCall& method_call) { 239void GPU::CallPullerMethod(const MethodCall& method_call) {
@@ -298,6 +313,30 @@ void GPU::CallEngineMethod(const MethodCall& method_call) {
298 } 313 }
299} 314}
300 315
316void GPU::CallEngineMultiMethod(u32 method, u32 subchannel, const u32* base_start, u32 amount, u32 methods_pending) {
317 const EngineID engine = bound_engines[subchannel];
318
319 switch (engine) {
320 case EngineID::FERMI_TWOD_A:
321 fermi_2d->CallMultiMethod(method, base_start, amount, methods_pending);
322 break;
323 case EngineID::MAXWELL_B:
324 maxwell_3d->CallMultiMethod(method, base_start, amount, methods_pending);
325 break;
326 case EngineID::KEPLER_COMPUTE_B:
327 kepler_compute->CallMultiMethod(method, base_start, amount, methods_pending);
328 break;
329 case EngineID::MAXWELL_DMA_COPY_A:
330 maxwell_dma->CallMultiMethod(method, base_start, amount, methods_pending);
331 break;
332 case EngineID::KEPLER_INLINE_TO_MEMORY_B:
333 kepler_memory->CallMultiMethod(method, base_start, amount, methods_pending);
334 break;
335 default:
336 UNIMPLEMENTED_MSG("Unimplemented engine");
337 }
338}
339
301void GPU::ProcessBindMethod(const MethodCall& method_call) { 340void GPU::ProcessBindMethod(const MethodCall& method_call) {
302 // Bind the current subchannel to the desired engine id. 341 // Bind the current subchannel to the desired engine id.
303 LOG_DEBUG(HW_GPU, "Binding subchannel {} to engine {}", method_call.subchannel, 342 LOG_DEBUG(HW_GPU, "Binding subchannel {} to engine {}", method_call.subchannel,
diff --git a/src/video_core/gpu.h b/src/video_core/gpu.h
index 5e3eb94e9..4d7e2651c 100644
--- a/src/video_core/gpu.h
+++ b/src/video_core/gpu.h
@@ -155,6 +155,9 @@ public:
155 /// Calls a GPU method. 155 /// Calls a GPU method.
156 void CallMethod(const MethodCall& method_call); 156 void CallMethod(const MethodCall& method_call);
157 157
158 /// Calls a GPU multivalue method.
159 void CallMultiMethod(u32 method, u32 subchannel, const u32* base_start, u32 amount, u32 methods_pending);
160
158 /// Flush all current written commands into the host GPU for execution. 161 /// Flush all current written commands into the host GPU for execution.
159 void FlushCommands(); 162 void FlushCommands();
160 /// Synchronizes CPU writes with Host GPU memory. 163 /// Synchronizes CPU writes with Host GPU memory.
@@ -309,8 +312,11 @@ private:
309 /// Calls a GPU engine method. 312 /// Calls a GPU engine method.
310 void CallEngineMethod(const MethodCall& method_call); 313 void CallEngineMethod(const MethodCall& method_call);
311 314
315 /// Calls a GPU engine multivalue method.
316 void CallEngineMultiMethod(u32 method, u32 subchannel, const u32* base_start, u32 amount, u32 methods_pending);
317
312 /// Determines where the method should be executed. 318 /// Determines where the method should be executed.
313 bool ExecuteMethodOnEngine(const MethodCall& method_call); 319 bool ExecuteMethodOnEngine(u32 method);
314 320
315protected: 321protected:
316 std::unique_ptr<Tegra::DmaPusher> dma_pusher; 322 std::unique_ptr<Tegra::DmaPusher> dma_pusher;