diff options
| author | 2018-10-29 23:36:03 -0400 | |
|---|---|---|
| committer | 2018-10-31 23:29:21 -0400 | |
| commit | de0ab806df4575df93068e128d911dabbf396d2c (patch) | |
| tree | ae9ce164967cd5bcfa824a1b7f0330957c792824 /src/video_core/macro_interpreter.cpp | |
| parent | Merge pull request #1604 from FearlessTobi/port-4369 (diff) | |
| download | yuzu-de0ab806df4575df93068e128d911dabbf396d2c.tar.gz yuzu-de0ab806df4575df93068e128d911dabbf396d2c.tar.xz yuzu-de0ab806df4575df93068e128d911dabbf396d2c.zip | |
maxwell_3d: Restructure macro upload to use a single macro code memory.
- Fixes an issue where macros could be skipped.
- Fixes rendering of distant objects in Super Mario Odyssey.
Diffstat (limited to 'src/video_core/macro_interpreter.cpp')
| -rw-r--r-- | src/video_core/macro_interpreter.cpp | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/video_core/macro_interpreter.cpp b/src/video_core/macro_interpreter.cpp index f6af132fb..335a8d407 100644 --- a/src/video_core/macro_interpreter.cpp +++ b/src/video_core/macro_interpreter.cpp | |||
| @@ -11,7 +11,7 @@ namespace Tegra { | |||
| 11 | 11 | ||
| 12 | MacroInterpreter::MacroInterpreter(Engines::Maxwell3D& maxwell3d) : maxwell3d(maxwell3d) {} | 12 | MacroInterpreter::MacroInterpreter(Engines::Maxwell3D& maxwell3d) : maxwell3d(maxwell3d) {} |
| 13 | 13 | ||
| 14 | void MacroInterpreter::Execute(const std::vector<u32>& code, std::vector<u32> parameters) { | 14 | void MacroInterpreter::Execute(u32 offset, std::vector<u32> parameters) { |
| 15 | Reset(); | 15 | Reset(); |
| 16 | registers[1] = parameters[0]; | 16 | registers[1] = parameters[0]; |
| 17 | this->parameters = std::move(parameters); | 17 | this->parameters = std::move(parameters); |
| @@ -19,7 +19,7 @@ void MacroInterpreter::Execute(const std::vector<u32>& code, std::vector<u32> pa | |||
| 19 | // Execute the code until we hit an exit condition. | 19 | // Execute the code until we hit an exit condition. |
| 20 | bool keep_executing = true; | 20 | bool keep_executing = true; |
| 21 | while (keep_executing) { | 21 | while (keep_executing) { |
| 22 | keep_executing = Step(code, false); | 22 | keep_executing = Step(offset, false); |
| 23 | } | 23 | } |
| 24 | 24 | ||
| 25 | // Assert the the macro used all the input parameters | 25 | // Assert the the macro used all the input parameters |
| @@ -37,10 +37,10 @@ void MacroInterpreter::Reset() { | |||
| 37 | next_parameter_index = 1; | 37 | next_parameter_index = 1; |
| 38 | } | 38 | } |
| 39 | 39 | ||
| 40 | bool MacroInterpreter::Step(const std::vector<u32>& code, bool is_delay_slot) { | 40 | bool MacroInterpreter::Step(u32 offset, bool is_delay_slot) { |
| 41 | u32 base_address = pc; | 41 | u32 base_address = pc; |
| 42 | 42 | ||
| 43 | Opcode opcode = GetOpcode(code); | 43 | Opcode opcode = GetOpcode(offset); |
| 44 | pc += 4; | 44 | pc += 4; |
| 45 | 45 | ||
| 46 | // Update the program counter if we were delayed | 46 | // Update the program counter if we were delayed |
| @@ -108,7 +108,7 @@ bool MacroInterpreter::Step(const std::vector<u32>& code, bool is_delay_slot) { | |||
| 108 | 108 | ||
| 109 | delayed_pc = base_address + opcode.GetBranchTarget(); | 109 | delayed_pc = base_address + opcode.GetBranchTarget(); |
| 110 | // Execute one more instruction due to the delay slot. | 110 | // Execute one more instruction due to the delay slot. |
| 111 | return Step(code, true); | 111 | return Step(offset, true); |
| 112 | } | 112 | } |
| 113 | break; | 113 | break; |
| 114 | } | 114 | } |
| @@ -121,17 +121,18 @@ bool MacroInterpreter::Step(const std::vector<u32>& code, bool is_delay_slot) { | |||
| 121 | // Exit has a delay slot, execute the next instruction | 121 | // Exit has a delay slot, execute the next instruction |
| 122 | // Note: Executing an exit during a branch delay slot will cause the instruction at the | 122 | // Note: Executing an exit during a branch delay slot will cause the instruction at the |
| 123 | // branch target to be executed before exiting. | 123 | // branch target to be executed before exiting. |
| 124 | Step(code, true); | 124 | Step(offset, true); |
| 125 | return false; | 125 | return false; |
| 126 | } | 126 | } |
| 127 | 127 | ||
| 128 | return true; | 128 | return true; |
| 129 | } | 129 | } |
| 130 | 130 | ||
| 131 | MacroInterpreter::Opcode MacroInterpreter::GetOpcode(const std::vector<u32>& code) const { | 131 | MacroInterpreter::Opcode MacroInterpreter::GetOpcode(u32 offset) const { |
| 132 | const auto& macro_memory{maxwell3d.GetMacroMemory()}; | ||
| 132 | ASSERT((pc % sizeof(u32)) == 0); | 133 | ASSERT((pc % sizeof(u32)) == 0); |
| 133 | ASSERT(pc < code.size() * sizeof(u32)); | 134 | ASSERT((pc + offset) < macro_memory.size() * sizeof(u32)); |
| 134 | return {code[pc / sizeof(u32)]}; | 135 | return {macro_memory[offset + pc / sizeof(u32)]}; |
| 135 | } | 136 | } |
| 136 | 137 | ||
| 137 | u32 MacroInterpreter::GetALUResult(ALUOperation operation, u32 src_a, u32 src_b) const { | 138 | u32 MacroInterpreter::GetALUResult(ALUOperation operation, u32 src_a, u32 src_b) const { |