diff options
author | David Marcec <dmarcecguzman@gmail.com> | 2020-06-04 17:42:19 +0200 |
---|---|---|
committer | David Marcec <dmarcecguzman@gmail.com> | 2020-06-24 04:09:01 +0200 |
commit | 6ce5f3120be6a65a798d3abc6fda0fe6171d0296 (patch) | |
tree | c63966fe5761248a4f48f4ccb4567b6213773fa4 /src/video_core/macro/macro.cpp | |
parent | Merge pull request #4138 from Morph1984/GyroscopeZeroDriftMode (diff) | |
download | yuzu-6ce5f3120be6a65a798d3abc6fda0fe6171d0296.tar yuzu-6ce5f3120be6a65a798d3abc6fda0fe6171d0296.tar.gz yuzu-6ce5f3120be6a65a798d3abc6fda0fe6171d0296.tar.bz2 yuzu-6ce5f3120be6a65a798d3abc6fda0fe6171d0296.tar.lz yuzu-6ce5f3120be6a65a798d3abc6fda0fe6171d0296.tar.xz yuzu-6ce5f3120be6a65a798d3abc6fda0fe6171d0296.tar.zst yuzu-6ce5f3120be6a65a798d3abc6fda0fe6171d0296.zip |
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 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include <boost/container_hash/hash.hpp> #include "common/assert.h" #include "common/logging/log.h" #include "core/settings.h" +#include "video_core/engines/maxwell_3d.h" #include "video_core/macro/macro.h" +#include "video_core/macro/macro_hle.h" #include "video_core/macro/macro_interpreter.h" #include "video_core/macro/macro_jit_x64.h" namespace Tegra { +MacroEngine::MacroEngine(Engines::Maxwell3D& maxwell3d) + : hle_macros{std::make_unique<Tegra::HLEMacro>(maxwell3d)} {} + +MacroEngine::~MacroEngine() {} + void MacroEngine::AddCode(u32 method, u32 data) { uploaded_macro_code[method].push_back(data); } -void MacroEngine::Execute(u32 method, const std::vector<u32>& parameters) { +void MacroEngine::Execute(Engines::Maxwell3D& maxwell3d, u32 method, + const std::vector<u32>& parameters) { auto compiled_macro = macro_cache.find(method); if (compiled_macro != macro_cache.end()) { - compiled_macro->second->Execute(parameters, method); + const auto& cache_info = compiled_macro->second; + if (cache_info.has_hle_program) { + cache_info.hle_program->Execute(parameters, method); + } else { + cache_info.lle_program->Execute(parameters, method); + } } else { // Macro not compiled, check if it's uploaded and if so, compile it auto macro_code = uploaded_macro_code.find(method); @@ -26,8 +40,21 @@ void MacroEngine::Execute(u32 method, const std::vector<u32>& parameters) { UNREACHABLE_MSG("Macro 0x{0:x} was not uploaded", method); return; } - macro_cache[method] = Compile(macro_code->second); - macro_cache[method]->Execute(parameters, method); + auto& cache_info = macro_cache[method]; + cache_info.hash = boost::hash_value(macro_code->second); + cache_info.lle_program = Compile(macro_code->second); + + auto hle_program = hle_macros->GetHLEProgram(cache_info.hash); + if (hle_program.has_value()) { + cache_info.has_hle_program = true; + cache_info.hle_program = std::move(hle_program.value()); + } + + if (cache_info.has_hle_program) { + cache_info.hle_program->Execute(parameters, method); + } else { + cache_info.lle_program->Execute(parameters, method); + } } } |