summaryrefslogtreecommitdiffstats
path: root/src/video_core/macro/macro.cpp
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2020-06-04 17:40:52 +0200
committerGitHub <noreply@github.com>2020-06-04 17:40:52 +0200
commit34d4abc4f9c264fb4dfc32b9b44aaeecaa4695a0 (patch)
tree95b864039ba58c858b0bb89c2eb6b56a25475d22 /src/video_core/macro/macro.cpp
parentMerge pull request #4039 from FearlessTobi/port-5376 (diff)
parentDefault init labels and use initializer list for macro engine (diff)
downloadyuzu-34d4abc4f9c264fb4dfc32b9b44aaeecaa4695a0.tar
yuzu-34d4abc4f9c264fb4dfc32b9b44aaeecaa4695a0.tar.gz
yuzu-34d4abc4f9c264fb4dfc32b9b44aaeecaa4695a0.tar.bz2
yuzu-34d4abc4f9c264fb4dfc32b9b44aaeecaa4695a0.tar.lz
yuzu-34d4abc4f9c264fb4dfc32b9b44aaeecaa4695a0.tar.xz
yuzu-34d4abc4f9c264fb4dfc32b9b44aaeecaa4695a0.tar.zst
yuzu-34d4abc4f9c264fb4dfc32b9b44aaeecaa4695a0.zip
Diffstat (limited to 'src/video_core/macro/macro.cpp')
-rw-r--r--src/video_core/macro/macro.cpp45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/video_core/macro/macro.cpp b/src/video_core/macro/macro.cpp
new file mode 100644
index 000000000..89077a2d8
--- /dev/null
+++ b/src/video_core/macro/macro.cpp
@@ -0,0 +1,45 @@
+// Copyright 2020 yuzu Emulator Project
+// Licensed under GPLv2 or any later version
+// Refer to the license.txt file included.
+
+#include "common/assert.h"
+#include "common/logging/log.h"
+#include "core/settings.h"
+#include "video_core/macro/macro.h"
+#include "video_core/macro/macro_interpreter.h"
+#include "video_core/macro/macro_jit_x64.h"
+
+namespace Tegra {
+
+void MacroEngine::AddCode(u32 method, u32 data) {
+ uploaded_macro_code[method].push_back(data);
+}
+
+void MacroEngine::Execute(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);
+ } else {
+ // Macro not compiled, check if it's uploaded and if so, compile it
+ auto macro_code = uploaded_macro_code.find(method);
+ if (macro_code == uploaded_macro_code.end()) {
+ UNREACHABLE_MSG("Macro 0x{0:x} was not uploaded", method);
+ return;
+ }
+ macro_cache[method] = Compile(macro_code->second);
+ macro_cache[method]->Execute(parameters, method);
+ }
+}
+
+std::unique_ptr<MacroEngine> GetMacroEngine(Engines::Maxwell3D& maxwell3d) {
+ if (Settings::values.disable_macro_jit) {
+ return std::make_unique<MacroInterpreter>(maxwell3d);
+ }
+#ifdef ARCHITECTURE_x86_64
+ return std::make_unique<MacroJITx64>(maxwell3d);
+#else
+ return std::make_unique<MacroInterpreter>(maxwell3d);
+#endif
+}
+
+} // namespace Tegra