summaryrefslogtreecommitdiff
path: root/src/video_core/macro/macro.cpp
diff options
context:
space:
mode:
authorGravatar bunnei2020-06-04 11:40:52 -0400
committerGravatar GitHub2020-06-04 11:40:52 -0400
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.gz
yuzu-34d4abc4f9c264fb4dfc32b9b44aaeecaa4695a0.tar.xz
yuzu-34d4abc4f9c264fb4dfc32b9b44aaeecaa4695a0.zip
Merge pull request #4009 from ogniK5377/macro-jit-prod
video_core: Implement Macro JIT
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 @@
1// Copyright 2020 yuzu Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#include "common/assert.h"
6#include "common/logging/log.h"
7#include "core/settings.h"
8#include "video_core/macro/macro.h"
9#include "video_core/macro/macro_interpreter.h"
10#include "video_core/macro/macro_jit_x64.h"
11
12namespace Tegra {
13
14void MacroEngine::AddCode(u32 method, u32 data) {
15 uploaded_macro_code[method].push_back(data);
16}
17
18void MacroEngine::Execute(u32 method, const std::vector<u32>& parameters) {
19 auto compiled_macro = macro_cache.find(method);
20 if (compiled_macro != macro_cache.end()) {
21 compiled_macro->second->Execute(parameters, method);
22 } else {
23 // Macro not compiled, check if it's uploaded and if so, compile it
24 auto macro_code = uploaded_macro_code.find(method);
25 if (macro_code == uploaded_macro_code.end()) {
26 UNREACHABLE_MSG("Macro 0x{0:x} was not uploaded", method);
27 return;
28 }
29 macro_cache[method] = Compile(macro_code->second);
30 macro_cache[method]->Execute(parameters, method);
31 }
32}
33
34std::unique_ptr<MacroEngine> GetMacroEngine(Engines::Maxwell3D& maxwell3d) {
35 if (Settings::values.disable_macro_jit) {
36 return std::make_unique<MacroInterpreter>(maxwell3d);
37 }
38#ifdef ARCHITECTURE_x86_64
39 return std::make_unique<MacroJITx64>(maxwell3d);
40#else
41 return std::make_unique<MacroInterpreter>(maxwell3d);
42#endif
43}
44
45} // namespace Tegra