summaryrefslogtreecommitdiff
path: root/src/video_core/macro/macro.cpp
diff options
context:
space:
mode:
authorGravatar Kelebek12023-08-19 01:19:49 +0100
committerGravatar Liam2023-08-25 21:47:47 -0400
commitd7a0b8c373526c07c1edddbcdc6e20cc4c9e759c (patch)
tree06c7c5701475c5cff367c39081f6386a842f401c /src/video_core/macro/macro.cpp
parentMerge pull request #11278 from Kelebek1/dma_sync (diff)
downloadyuzu-d7a0b8c373526c07c1edddbcdc6e20cc4c9e759c.tar.gz
yuzu-d7a0b8c373526c07c1edddbcdc6e20cc4c9e759c.tar.xz
yuzu-d7a0b8c373526c07c1edddbcdc6e20cc4c9e759c.zip
Mark decompiled macros as decompiled on dump, dump shaders after translation
Diffstat (limited to 'src/video_core/macro/macro.cpp')
-rw-r--r--src/video_core/macro/macro.cpp24
1 files changed, 16 insertions, 8 deletions
diff --git a/src/video_core/macro/macro.cpp b/src/video_core/macro/macro.cpp
index 905505ca1..5d0bb9cc4 100644
--- a/src/video_core/macro/macro.cpp
+++ b/src/video_core/macro/macro.cpp
@@ -27,14 +27,24 @@ MICROPROFILE_DEFINE(MacroHLE, "GPU", "Execute macro HLE", MP_RGB(128, 192, 192))
27 27
28namespace Tegra { 28namespace Tegra {
29 29
30static void Dump(u64 hash, std::span<const u32> code) { 30static void Dump(u64 hash, std::span<const u32> code, bool decompiled = false) {
31 const auto base_dir{Common::FS::GetYuzuPath(Common::FS::YuzuPath::DumpDir)}; 31 const auto base_dir{Common::FS::GetYuzuPath(Common::FS::YuzuPath::DumpDir)};
32 const auto macro_dir{base_dir / "macros"}; 32 const auto macro_dir{base_dir / "macros"};
33 if (!Common::FS::CreateDir(base_dir) || !Common::FS::CreateDir(macro_dir)) { 33 if (!Common::FS::CreateDir(base_dir) || !Common::FS::CreateDir(macro_dir)) {
34 LOG_ERROR(Common_Filesystem, "Failed to create macro dump directories"); 34 LOG_ERROR(Common_Filesystem, "Failed to create macro dump directories");
35 return; 35 return;
36 } 36 }
37 const auto name{macro_dir / fmt::format("{:016x}.macro", hash)}; 37 auto name{macro_dir / fmt::format("{:016x}.macro", hash)};
38
39 if (decompiled) {
40 auto new_name{macro_dir / fmt::format("decompiled_{:016x}.macro", hash)};
41 if (Common::FS::Exists(name)) {
42 (void)Common::FS::RenameFile(name, new_name);
43 return;
44 }
45 name = new_name;
46 }
47
38 std::fstream macro_file(name, std::ios::out | std::ios::binary); 48 std::fstream macro_file(name, std::ios::out | std::ios::binary);
39 if (!macro_file) { 49 if (!macro_file) {
40 LOG_ERROR(Common_Filesystem, "Unable to open or create file at {}", 50 LOG_ERROR(Common_Filesystem, "Unable to open or create file at {}",
@@ -90,9 +100,6 @@ void MacroEngine::Execute(u32 method, const std::vector<u32>& parameters) {
90 if (!mid_method.has_value()) { 100 if (!mid_method.has_value()) {
91 cache_info.lle_program = Compile(macro_code->second); 101 cache_info.lle_program = Compile(macro_code->second);
92 cache_info.hash = Common::HashValue(macro_code->second); 102 cache_info.hash = Common::HashValue(macro_code->second);
93 if (Settings::values.dump_macros) {
94 Dump(cache_info.hash, macro_code->second);
95 }
96 } else { 103 } else {
97 const auto& macro_cached = uploaded_macro_code[mid_method.value()]; 104 const auto& macro_cached = uploaded_macro_code[mid_method.value()];
98 const auto rebased_method = method - mid_method.value(); 105 const auto rebased_method = method - mid_method.value();
@@ -102,9 +109,6 @@ void MacroEngine::Execute(u32 method, const std::vector<u32>& parameters) {
102 code.size() * sizeof(u32)); 109 code.size() * sizeof(u32));
103 cache_info.hash = Common::HashValue(code); 110 cache_info.hash = Common::HashValue(code);
104 cache_info.lle_program = Compile(code); 111 cache_info.lle_program = Compile(code);
105 if (Settings::values.dump_macros) {
106 Dump(cache_info.hash, code);
107 }
108 } 112 }
109 113
110 auto hle_program = hle_macros->GetHLEProgram(cache_info.hash); 114 auto hle_program = hle_macros->GetHLEProgram(cache_info.hash);
@@ -117,6 +121,10 @@ void MacroEngine::Execute(u32 method, const std::vector<u32>& parameters) {
117 MICROPROFILE_SCOPE(MacroHLE); 121 MICROPROFILE_SCOPE(MacroHLE);
118 cache_info.hle_program->Execute(parameters, method); 122 cache_info.hle_program->Execute(parameters, method);
119 } 123 }
124
125 if (Settings::values.dump_macros) {
126 Dump(cache_info.hash, macro_code->second, cache_info.has_hle_program);
127 }
120 } 128 }
121} 129}
122 130