summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/video_core/engines/maxwell_3d.cpp7
-rw-r--r--src/video_core/engines/maxwell_3d.h3
-rw-r--r--src/video_core/macro_interpreter.cpp18
-rw-r--r--src/video_core/macro_interpreter.h8
4 files changed, 24 insertions, 12 deletions
diff --git a/src/video_core/engines/maxwell_3d.cpp b/src/video_core/engines/maxwell_3d.cpp
index f5158d219..c8c92757a 100644
--- a/src/video_core/engines/maxwell_3d.cpp
+++ b/src/video_core/engines/maxwell_3d.cpp
@@ -244,7 +244,7 @@ void Maxwell3D::InitDirtySettings() {
244 dirty_pointers[MAXWELL3D_REG_INDEX(polygon_offset_clamp)] = polygon_offset_dirty_reg; 244 dirty_pointers[MAXWELL3D_REG_INDEX(polygon_offset_clamp)] = polygon_offset_dirty_reg;
245} 245}
246 246
247void Maxwell3D::CallMacroMethod(u32 method, std::vector<u32> parameters) { 247void Maxwell3D::CallMacroMethod(u32 method, std::size_t num_parameters, const u32* parameters) {
248 // Reset the current macro. 248 // Reset the current macro.
249 executing_macro = 0; 249 executing_macro = 0;
250 250
@@ -252,7 +252,7 @@ void Maxwell3D::CallMacroMethod(u32 method, std::vector<u32> parameters) {
252 const u32 entry = ((method - MacroRegistersStart) >> 1) % macro_positions.size(); 252 const u32 entry = ((method - MacroRegistersStart) >> 1) % macro_positions.size();
253 253
254 // Execute the current macro. 254 // Execute the current macro.
255 macro_interpreter.Execute(macro_positions[entry], std::move(parameters)); 255 macro_interpreter.Execute(macro_positions[entry], num_parameters, parameters);
256} 256}
257 257
258void Maxwell3D::CallMethod(const GPU::MethodCall& method_call) { 258void Maxwell3D::CallMethod(const GPU::MethodCall& method_call) {
@@ -289,7 +289,8 @@ void Maxwell3D::CallMethod(const GPU::MethodCall& method_call) {
289 289
290 // Call the macro when there are no more parameters in the command buffer 290 // Call the macro when there are no more parameters in the command buffer
291 if (method_call.IsLastCall()) { 291 if (method_call.IsLastCall()) {
292 CallMacroMethod(executing_macro, std::move(macro_params)); 292 CallMacroMethod(executing_macro, macro_params.size(), macro_params.data());
293 macro_params.clear();
293 } 294 }
294 return; 295 return;
295 } 296 }
diff --git a/src/video_core/engines/maxwell_3d.h b/src/video_core/engines/maxwell_3d.h
index 3b3c82f41..f67a5389f 100644
--- a/src/video_core/engines/maxwell_3d.h
+++ b/src/video_core/engines/maxwell_3d.h
@@ -1308,9 +1308,10 @@ private:
1308 /** 1308 /**
1309 * Call a macro on this engine. 1309 * Call a macro on this engine.
1310 * @param method Method to call 1310 * @param method Method to call
1311 * @param num_parameters Number of arguments
1311 * @param parameters Arguments to the method call 1312 * @param parameters Arguments to the method call
1312 */ 1313 */
1313 void CallMacroMethod(u32 method, std::vector<u32> parameters); 1314 void CallMacroMethod(u32 method, std::size_t num_parameters, const u32* parameters);
1314 1315
1315 /// Handles writes to the macro uploading register. 1316 /// Handles writes to the macro uploading register.
1316 void ProcessMacroUpload(u32 data); 1317 void ProcessMacroUpload(u32 data);
diff --git a/src/video_core/macro_interpreter.cpp b/src/video_core/macro_interpreter.cpp
index 9f59a2dc1..4e1cb98db 100644
--- a/src/video_core/macro_interpreter.cpp
+++ b/src/video_core/macro_interpreter.cpp
@@ -14,11 +14,18 @@ namespace Tegra {
14 14
15MacroInterpreter::MacroInterpreter(Engines::Maxwell3D& maxwell3d) : maxwell3d(maxwell3d) {} 15MacroInterpreter::MacroInterpreter(Engines::Maxwell3D& maxwell3d) : maxwell3d(maxwell3d) {}
16 16
17void MacroInterpreter::Execute(u32 offset, std::vector<u32> parameters) { 17void MacroInterpreter::Execute(u32 offset, std::size_t num_parameters, const u32* parameters) {
18 MICROPROFILE_SCOPE(MacroInterp); 18 MICROPROFILE_SCOPE(MacroInterp);
19 Reset(); 19 Reset();
20
20 registers[1] = parameters[0]; 21 registers[1] = parameters[0];
21 this->parameters = std::move(parameters); 22
23 if (num_parameters > parameters_capacity) {
24 parameters_capacity = num_parameters;
25 this->parameters = std::make_unique<u32[]>(num_parameters);
26 }
27 std::memcpy(this->parameters.get(), parameters, num_parameters * sizeof(u32));
28 this->num_parameters = num_parameters;
22 29
23 // Execute the code until we hit an exit condition. 30 // Execute the code until we hit an exit condition.
24 bool keep_executing = true; 31 bool keep_executing = true;
@@ -27,7 +34,7 @@ void MacroInterpreter::Execute(u32 offset, std::vector<u32> parameters) {
27 } 34 }
28 35
29 // Assert the the macro used all the input parameters 36 // Assert the the macro used all the input parameters
30 ASSERT(next_parameter_index == this->parameters.size()); 37 ASSERT(next_parameter_index == num_parameters);
31} 38}
32 39
33void MacroInterpreter::Reset() { 40void MacroInterpreter::Reset() {
@@ -35,7 +42,7 @@ void MacroInterpreter::Reset() {
35 pc = 0; 42 pc = 0;
36 delayed_pc = {}; 43 delayed_pc = {};
37 method_address.raw = 0; 44 method_address.raw = 0;
38 parameters.clear(); 45 num_parameters = 0;
39 // The next parameter index starts at 1, because $r1 already has the value of the first 46 // The next parameter index starts at 1, because $r1 already has the value of the first
40 // parameter. 47 // parameter.
41 next_parameter_index = 1; 48 next_parameter_index = 1;
@@ -229,7 +236,8 @@ void MacroInterpreter::ProcessResult(ResultOperation operation, u32 reg, u32 res
229} 236}
230 237
231u32 MacroInterpreter::FetchParameter() { 238u32 MacroInterpreter::FetchParameter() {
232 return parameters.at(next_parameter_index++); 239 ASSERT(next_parameter_index < num_parameters);
240 return parameters[next_parameter_index++];
233} 241}
234 242
235u32 MacroInterpreter::GetRegister(u32 register_id) const { 243u32 MacroInterpreter::GetRegister(u32 register_id) const {
diff --git a/src/video_core/macro_interpreter.h b/src/video_core/macro_interpreter.h
index cde360288..76b6a895b 100644
--- a/src/video_core/macro_interpreter.h
+++ b/src/video_core/macro_interpreter.h
@@ -25,7 +25,7 @@ public:
25 * @param offset Offset to start execution at. 25 * @param offset Offset to start execution at.
26 * @param parameters The parameters of the macro. 26 * @param parameters The parameters of the macro.
27 */ 27 */
28 void Execute(u32 offset, std::vector<u32> parameters); 28 void Execute(u32 offset, std::size_t num_parameters, const u32* parameters);
29 29
30private: 30private:
31 enum class Operation : u32 { 31 enum class Operation : u32 {
@@ -162,10 +162,12 @@ private:
162 MethodAddress method_address = {}; 162 MethodAddress method_address = {};
163 163
164 /// Input parameters of the current macro. 164 /// Input parameters of the current macro.
165 std::vector<u32> parameters; 165 std::unique_ptr<u32[]> parameters;
166 std::size_t num_parameters = 0;
167 std::size_t parameters_capacity = 0;
166 /// Index of the next parameter that will be fetched by the 'parm' instruction. 168 /// Index of the next parameter that will be fetched by the 'parm' instruction.
167 u32 next_parameter_index = 0; 169 u32 next_parameter_index = 0;
168 170
169 bool carry_flag{}; 171 bool carry_flag = false;
170}; 172};
171} // namespace Tegra 173} // namespace Tegra