diff options
author | bunnei <bunneidev@gmail.com> | 2018-10-30 04:36:03 +0100 |
---|---|---|
committer | bunnei <bunneidev@gmail.com> | 2018-11-01 04:29:21 +0100 |
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 yuzu-de0ab806df4575df93068e128d911dabbf396d2c.tar.gz yuzu-de0ab806df4575df93068e128d911dabbf396d2c.tar.bz2 yuzu-de0ab806df4575df93068e128d911dabbf396d2c.tar.lz yuzu-de0ab806df4575df93068e128d911dabbf396d2c.tar.xz yuzu-de0ab806df4575df93068e128d911dabbf396d2c.tar.zst yuzu-de0ab806df4575df93068e128d911dabbf396d2c.zip |
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 { MacroInterpreter::MacroInterpreter(Engines::Maxwell3D& maxwell3d) : maxwell3d(maxwell3d) {} -void MacroInterpreter::Execute(const std::vector<u32>& code, std::vector<u32> parameters) { +void MacroInterpreter::Execute(u32 offset, std::vector<u32> parameters) { Reset(); registers[1] = parameters[0]; this->parameters = std::move(parameters); @@ -19,7 +19,7 @@ void MacroInterpreter::Execute(const std::vector<u32>& code, std::vector<u32> pa // Execute the code until we hit an exit condition. bool keep_executing = true; while (keep_executing) { - keep_executing = Step(code, false); + keep_executing = Step(offset, false); } // Assert the the macro used all the input parameters @@ -37,10 +37,10 @@ void MacroInterpreter::Reset() { next_parameter_index = 1; } -bool MacroInterpreter::Step(const std::vector<u32>& code, bool is_delay_slot) { +bool MacroInterpreter::Step(u32 offset, bool is_delay_slot) { u32 base_address = pc; - Opcode opcode = GetOpcode(code); + Opcode opcode = GetOpcode(offset); pc += 4; // Update the program counter if we were delayed @@ -108,7 +108,7 @@ bool MacroInterpreter::Step(const std::vector<u32>& code, bool is_delay_slot) { delayed_pc = base_address + opcode.GetBranchTarget(); // Execute one more instruction due to the delay slot. - return Step(code, true); + return Step(offset, true); } break; } @@ -121,17 +121,18 @@ bool MacroInterpreter::Step(const std::vector<u32>& code, bool is_delay_slot) { // Exit has a delay slot, execute the next instruction // Note: Executing an exit during a branch delay slot will cause the instruction at the // branch target to be executed before exiting. - Step(code, true); + Step(offset, true); return false; } return true; } -MacroInterpreter::Opcode MacroInterpreter::GetOpcode(const std::vector<u32>& code) const { +MacroInterpreter::Opcode MacroInterpreter::GetOpcode(u32 offset) const { + const auto& macro_memory{maxwell3d.GetMacroMemory()}; ASSERT((pc % sizeof(u32)) == 0); - ASSERT(pc < code.size() * sizeof(u32)); - return {code[pc / sizeof(u32)]}; + ASSERT((pc + offset) < macro_memory.size() * sizeof(u32)); + return {macro_memory[offset + pc / sizeof(u32)]}; } u32 MacroInterpreter::GetALUResult(ALUOperation operation, u32 src_a, u32 src_b) const { |