diff options
| author | 2020-06-05 01:42:19 +1000 | |
|---|---|---|
| committer | 2020-06-24 12:09:01 +1000 | |
| commit | 6ce5f3120be6a65a798d3abc6fda0fe6171d0296 (patch) | |
| tree | c63966fe5761248a4f48f4ccb4567b6213773fa4 /src/video_core/macro/macro.cpp | |
| parent | Merge pull request #4138 from Morph1984/GyroscopeZeroDriftMode (diff) | |
| download | yuzu-6ce5f3120be6a65a798d3abc6fda0fe6171d0296.tar.gz yuzu-6ce5f3120be6a65a798d3abc6fda0fe6171d0296.tar.xz yuzu-6ce5f3120be6a65a798d3abc6fda0fe6171d0296.zip | |
Macro HLE support
Diffstat (limited to 'src/video_core/macro/macro.cpp')
| -rw-r--r-- | src/video_core/macro/macro.cpp | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/src/video_core/macro/macro.cpp b/src/video_core/macro/macro.cpp index 89077a2d8..c8aa2534a 100644 --- a/src/video_core/macro/macro.cpp +++ b/src/video_core/macro/macro.cpp | |||
| @@ -2,23 +2,37 @@ | |||
| 2 | // Licensed under GPLv2 or any later version | 2 | // Licensed under GPLv2 or any later version |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include <boost/container_hash/hash.hpp> | ||
| 5 | #include "common/assert.h" | 6 | #include "common/assert.h" |
| 6 | #include "common/logging/log.h" | 7 | #include "common/logging/log.h" |
| 7 | #include "core/settings.h" | 8 | #include "core/settings.h" |
| 9 | #include "video_core/engines/maxwell_3d.h" | ||
| 8 | #include "video_core/macro/macro.h" | 10 | #include "video_core/macro/macro.h" |
| 11 | #include "video_core/macro/macro_hle.h" | ||
| 9 | #include "video_core/macro/macro_interpreter.h" | 12 | #include "video_core/macro/macro_interpreter.h" |
| 10 | #include "video_core/macro/macro_jit_x64.h" | 13 | #include "video_core/macro/macro_jit_x64.h" |
| 11 | 14 | ||
| 12 | namespace Tegra { | 15 | namespace Tegra { |
| 13 | 16 | ||
| 17 | MacroEngine::MacroEngine(Engines::Maxwell3D& maxwell3d) | ||
| 18 | : hle_macros{std::make_unique<Tegra::HLEMacro>(maxwell3d)} {} | ||
| 19 | |||
| 20 | MacroEngine::~MacroEngine() {} | ||
| 21 | |||
| 14 | void MacroEngine::AddCode(u32 method, u32 data) { | 22 | void MacroEngine::AddCode(u32 method, u32 data) { |
| 15 | uploaded_macro_code[method].push_back(data); | 23 | uploaded_macro_code[method].push_back(data); |
| 16 | } | 24 | } |
| 17 | 25 | ||
| 18 | void MacroEngine::Execute(u32 method, const std::vector<u32>& parameters) { | 26 | void MacroEngine::Execute(Engines::Maxwell3D& maxwell3d, u32 method, |
| 27 | const std::vector<u32>& parameters) { | ||
| 19 | auto compiled_macro = macro_cache.find(method); | 28 | auto compiled_macro = macro_cache.find(method); |
| 20 | if (compiled_macro != macro_cache.end()) { | 29 | if (compiled_macro != macro_cache.end()) { |
| 21 | compiled_macro->second->Execute(parameters, method); | 30 | const auto& cache_info = compiled_macro->second; |
| 31 | if (cache_info.has_hle_program) { | ||
| 32 | cache_info.hle_program->Execute(parameters, method); | ||
| 33 | } else { | ||
| 34 | cache_info.lle_program->Execute(parameters, method); | ||
| 35 | } | ||
| 22 | } else { | 36 | } else { |
| 23 | // Macro not compiled, check if it's uploaded and if so, compile it | 37 | // Macro not compiled, check if it's uploaded and if so, compile it |
| 24 | auto macro_code = uploaded_macro_code.find(method); | 38 | auto macro_code = uploaded_macro_code.find(method); |
| @@ -26,8 +40,21 @@ void MacroEngine::Execute(u32 method, const std::vector<u32>& parameters) { | |||
| 26 | UNREACHABLE_MSG("Macro 0x{0:x} was not uploaded", method); | 40 | UNREACHABLE_MSG("Macro 0x{0:x} was not uploaded", method); |
| 27 | return; | 41 | return; |
| 28 | } | 42 | } |
| 29 | macro_cache[method] = Compile(macro_code->second); | 43 | auto& cache_info = macro_cache[method]; |
| 30 | macro_cache[method]->Execute(parameters, method); | 44 | cache_info.hash = boost::hash_value(macro_code->second); |
| 45 | cache_info.lle_program = Compile(macro_code->second); | ||
| 46 | |||
| 47 | auto hle_program = hle_macros->GetHLEProgram(cache_info.hash); | ||
| 48 | if (hle_program.has_value()) { | ||
| 49 | cache_info.has_hle_program = true; | ||
| 50 | cache_info.hle_program = std::move(hle_program.value()); | ||
| 51 | } | ||
| 52 | |||
| 53 | if (cache_info.has_hle_program) { | ||
| 54 | cache_info.hle_program->Execute(parameters, method); | ||
| 55 | } else { | ||
| 56 | cache_info.lle_program->Execute(parameters, method); | ||
| 57 | } | ||
| 31 | } | 58 | } |
| 32 | } | 59 | } |
| 33 | 60 | ||