From 073b723c09375caa538613df91f7716fcc7f5718 Mon Sep 17 00:00:00 2001 From: Eladash Date: Thu, 15 Jun 2023 21:59:19 +0300 Subject: [PATCH] Fix Create PPU Cache --- rpcs3/Emu/Cell/PPUAnalyser.h | 4 ++-- rpcs3/Emu/Cell/PPUModule.cpp | 2 -- rpcs3/Emu/System.cpp | 28 +++++++++++++++++++--------- rpcs3/Emu/cache_utils.cpp | 6 +++--- 4 files changed, 24 insertions(+), 16 deletions(-) diff --git a/rpcs3/Emu/Cell/PPUAnalyser.h b/rpcs3/Emu/Cell/PPUAnalyser.h index c82408856e..1f3cf84fda 100644 --- a/rpcs3/Emu/Cell/PPUAnalyser.h +++ b/rpcs3/Emu/Cell/PPUAnalyser.h @@ -107,8 +107,8 @@ struct ppu_module struct main_ppu_module : public ppu_module { - u32 elf_entry; - u32 seg0_code_end; + u32 elf_entry{}; + u32 seg0_code_end{}; std::basic_string applied_pathes; }; diff --git a/rpcs3/Emu/Cell/PPUModule.cpp b/rpcs3/Emu/Cell/PPUModule.cpp index f011062d8e..b739b7a0a6 100644 --- a/rpcs3/Emu/Cell/PPUModule.cpp +++ b/rpcs3/Emu/Cell/PPUModule.cpp @@ -1051,8 +1051,6 @@ void init_ppu_functions(utils::serial* ar, bool full = false) if (full) { - ensure(ar); - // Initialize HLE modules ppu_initialize_modules(&g_fxo->get(), ar); } diff --git a/rpcs3/Emu/System.cpp b/rpcs3/Emu/System.cpp index 6b534c75c2..a28ea0bdaf 100644 --- a/rpcs3/Emu/System.cpp +++ b/rpcs3/Emu/System.cpp @@ -1329,8 +1329,6 @@ game_boot_result Emulator::Load(const std::string& title_id, bool is_disc_patch, argv[0] = "/dev_bdvd/PS3_GAME/USRDIR/EBOOT.BIN"; m_dir = "/dev_bdvd/PS3_GAME"; - Run(false); - std::string path; std::vector dir_queue; dir_queue.emplace_back(m_path + '/'); @@ -1394,26 +1392,36 @@ game_boot_result Emulator::Load(const std::string& title_id, bool is_disc_patch, // Workaround for analyser glitches ensure(vm::falloc(0x10000, 0xf0000, vm::main)); } - - if (IsStopped()) - { - GetCallbacks().on_stop(); // Call on_stop to refresh gui - return game_boot_result::no_errors; - } } if (auto& _main = g_fxo->get(); _main.path.empty()) { - init_fxo_for_exec(nullptr, false); + init_fxo_for_exec(nullptr, true); + } + + if (auto main_ppu = idm::get>(ppu_thread::id_base)) + { + // Created by ppu_load_exec, unwanted + main_ppu->state += cpu_flag::exit; } g_fxo->init("SPRX Loader"sv, [this, dir_queue]() mutable { if (auto& _main = g_fxo->get(); !_main.path.empty()) { + if (!_main.analyse(0, _main.elf_entry, _main.seg0_code_end, _main.applied_pathes, [](){ return Emu.IsStopped(); })) + { + return; + } + ppu_initialize(_main); } + if (Emu.IsStopped()) + { + return; + } + ppu_precompile(dir_queue, nullptr); // Exit "process" @@ -1424,6 +1432,8 @@ game_boot_result Emulator::Load(const std::string& title_id, bool is_disc_patch, }); }); + Run(false); + return game_boot_result::no_errors; } diff --git a/rpcs3/Emu/cache_utils.cpp b/rpcs3/Emu/cache_utils.cpp index c41897c539..601998848b 100644 --- a/rpcs3/Emu/cache_utils.cpp +++ b/rpcs3/Emu/cache_utils.cpp @@ -12,15 +12,15 @@ namespace rpcs3::cache { std::string get_ppu_cache() { - auto& _main = g_fxo->get(); + const auto _main = g_fxo->try_get(); - if (!g_fxo->is_init() || _main.cache.empty()) + if (!_main || _main->cache.empty()) { ppu_log.error("PPU Cache location not initialized."); return {}; } - return _main.cache; + return _main->cache; } void limit_cache_size()