From 598f58d03ddb0e94f36ded79f154dc474af1c7e7 Mon Sep 17 00:00:00 2001 From: pineappleEA Date: Mon, 9 May 2022 06:18:26 +0200 Subject: [PATCH] early-access version 2723 --- README.md | 2 +- src/common/settings.h | 1 + src/video_core/macro/macro.cpp | 27 ++++++++++++++++++++++ src/yuzu/configuration/configure_debug.cpp | 3 +++ src/yuzu/configuration/configure_debug.ui | 13 +++++++++++ 5 files changed, 45 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 21b7afaf3..acb7f26d8 100755 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ yuzu emulator early access ============= -This is the source code for early-access 2722. +This is the source code for early-access 2723. ## Legal Notice diff --git a/src/common/settings.h b/src/common/settings.h index 5b34169a8..e61d9cd7f 100755 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -606,6 +606,7 @@ struct Values { BasicSetting dump_exefs{false, "dump_exefs"}; BasicSetting dump_nso{false, "dump_nso"}; BasicSetting dump_shaders{false, "dump_shaders"}; + BasicSetting dump_macros{false, "dump_macros"}; BasicSetting enable_fs_access_log{false, "enable_fs_access_log"}; BasicSetting reporting_services{false, "reporting_services"}; BasicSetting quest_flag{false, "quest_flag"}; diff --git a/src/video_core/macro/macro.cpp b/src/video_core/macro/macro.cpp index a033d03be..86393c49c 100755 --- a/src/video_core/macro/macro.cpp +++ b/src/video_core/macro/macro.cpp @@ -2,11 +2,15 @@ // SPDX-License-Identifier: GPL-2.0-or-later #include +#include #include +#include #include #include "common/assert.h" +#include "common/fs/fs.h" +#include "common/fs/path_util.h" #include "common/settings.h" #include "video_core/macro/macro.h" #include "video_core/macro/macro_hle.h" @@ -15,6 +19,23 @@ namespace Tegra { +static void Dump(u64 hash, std::span code) { + const auto base_dir{Common::FS::GetYuzuPath(Common::FS::YuzuPath::DumpDir)}; + const auto macro_dir{base_dir / "macros"}; + if (!Common::FS::CreateDir(base_dir) || !Common::FS::CreateDir(macro_dir)) { + LOG_ERROR(Common_Filesystem, "Failed to create macro dump directories"); + return; + } + const auto name{macro_dir / fmt::format("{:016x}.macro", hash)}; + std::fstream macro_file(name, std::ios::out | std::ios::binary); + if (!macro_file) { + LOG_ERROR(Common_Filesystem, "Unable to open or create file at {}", + Common::FS::PathToUTF8String(name)); + return; + } + macro_file.write(reinterpret_cast(code.data()), code.size_bytes()); +} + MacroEngine::MacroEngine(Engines::Maxwell3D& maxwell3d) : hle_macros{std::make_unique(maxwell3d)} {} @@ -54,6 +75,9 @@ void MacroEngine::Execute(u32 method, const std::vector& parameters) { if (!mid_method.has_value()) { cache_info.lle_program = Compile(macro_code->second); cache_info.hash = boost::hash_value(macro_code->second); + if (Settings::values.dump_macros) { + Dump(cache_info.hash, macro_code->second); + } } else { const auto& macro_cached = uploaded_macro_code[mid_method.value()]; const auto rebased_method = method - mid_method.value(); @@ -63,6 +87,9 @@ void MacroEngine::Execute(u32 method, const std::vector& parameters) { code.size() * sizeof(u32)); cache_info.hash = boost::hash_value(code); cache_info.lle_program = Compile(code); + if (Settings::values.dump_macros) { + Dump(cache_info.hash, code); + } } if (auto hle_program = hle_macros->GetHLEProgram(cache_info.hash)) { diff --git a/src/yuzu/configuration/configure_debug.cpp b/src/yuzu/configuration/configure_debug.cpp index bd50f7a68..d6e8b5ead 100755 --- a/src/yuzu/configuration/configure_debug.cpp +++ b/src/yuzu/configuration/configure_debug.cpp @@ -53,6 +53,8 @@ void ConfigureDebug::SetConfiguration() { ui->enable_nsight_aftermath->setChecked(Settings::values.enable_nsight_aftermath.GetValue()); ui->dump_shaders->setEnabled(runtime_lock); ui->dump_shaders->setChecked(Settings::values.dump_shaders.GetValue()); + ui->dump_macros->setEnabled(runtime_lock); + ui->dump_macros->setChecked(Settings::values.dump_macros.GetValue()); ui->disable_macro_jit->setEnabled(runtime_lock); ui->disable_macro_jit->setChecked(Settings::values.disable_macro_jit.GetValue()); ui->disable_loop_safety_checks->setEnabled(runtime_lock); @@ -83,6 +85,7 @@ void ConfigureDebug::ApplyConfiguration() { Settings::values.cpu_debug_mode = ui->enable_cpu_debugging->isChecked(); Settings::values.enable_nsight_aftermath = ui->enable_nsight_aftermath->isChecked(); Settings::values.dump_shaders = ui->dump_shaders->isChecked(); + Settings::values.dump_macros = ui->dump_macros->isChecked(); Settings::values.disable_shader_loop_safety_checks = ui->disable_loop_safety_checks->isChecked(); Settings::values.disable_macro_jit = ui->disable_macro_jit->isChecked(); diff --git a/src/yuzu/configuration/configure_debug.ui b/src/yuzu/configuration/configure_debug.ui index c1d90d588..863a3fd57 100755 --- a/src/yuzu/configuration/configure_debug.ui +++ b/src/yuzu/configuration/configure_debug.ui @@ -118,6 +118,19 @@ + + + + true + + + When checked, it will dump all the macro programs of the GPU + + + Dump Maxwell Macros + + +