diff --git a/rpcs3/Emu/Cell/PPUModule.cpp b/rpcs3/Emu/Cell/PPUModule.cpp index cce0c015fc..ace6c03e30 100644 --- a/rpcs3/Emu/Cell/PPUModule.cpp +++ b/rpcs3/Emu/Cell/PPUModule.cpp @@ -1803,6 +1803,8 @@ bool ppu_load_exec(const ppu_exec_object& elf, bool virtual_load, const std::str error_handler.errored = false; } + const auto old_process_info = g_ps3_process_info; + // Allocate memory at fixed positions for (const auto& prog : elf.progs) { @@ -2199,30 +2201,33 @@ bool ppu_load_exec(const ppu_exec_object& elf, bool virtual_load, const std::str _main.seg0_code_end = end; _main.applied_pathes = applied; - // Set SDK version - g_ps3_process_info.sdk_ver = sdk_version; - - // Set ppc fixed allocations segment permission - g_ps3_process_info.ppc_seg = ppc_seg; - - if (Emu.init_mem_containers) - { - // Refer to sys_process_exit2 for explanation - Emu.init_mem_containers(mem_size); - } - else if (!ar) - { - g_fxo->init>(); - g_fxo->init(mem_size); - } - if (!virtual_load) { + // Set SDK version + g_ps3_process_info.sdk_ver = sdk_version; + + // Set ppc fixed allocations segment permission + g_ps3_process_info.ppc_seg = ppc_seg; + + if (Emu.init_mem_containers) + { + // Refer to sys_process_exit2 for explanation + // Make init_mem_containers empty before call + const auto callback = std::move(Emu.init_mem_containers); + callback(mem_size); + } + else if (!ar) + { + g_fxo->init>(); + g_fxo->init(mem_size); + } + void init_fxo_for_exec(utils::serial* ar, bool full); init_fxo_for_exec(ar, false); } else { + g_ps3_process_info = old_process_info; Emu.ConfigurePPUCache(); } diff --git a/rpcs3/Emu/Cell/PPUThread.cpp b/rpcs3/Emu/Cell/PPUThread.cpp index 36973a5c66..512a214d2b 100644 --- a/rpcs3/Emu/Cell/PPUThread.cpp +++ b/rpcs3/Emu/Cell/PPUThread.cpp @@ -3084,7 +3084,7 @@ extern void ppu_precompile(std::vector& dir_queue, std::vector& dir_queue, std::vectorget(); + _main = {}; + if (!ppu_load_exec(obj, true, path)) { // Abort @@ -3309,8 +3312,6 @@ extern void ppu_precompile(std::vector& dir_queue, std::vectorget(); - if (!_main.analyse(0, _main.elf_entry, _main.seg0_code_end, _main.applied_pathes, [](){ return Emu.IsStopped(); })) { break; @@ -3457,7 +3458,7 @@ extern void ppu_initialize() } // Avoid compilation if main's cache exists or it is a standalone SELF with no PARAM.SFO - if (compile_main && g_cfg.core.ppu_llvm_precompilation && !Emu.GetTitleID().empty()) + if (compile_main && g_cfg.core.ppu_llvm_precompilation && !Emu.GetTitleID().empty() && !Emu.IsChildProcess()) { // Try to add all related directories const std::set dirs = Emu.GetGameDirs(); diff --git a/rpcs3/Emu/Cell/lv2/sys_process.cpp b/rpcs3/Emu/Cell/lv2/sys_process.cpp index 3a0a3323ed..496e3406c0 100644 --- a/rpcs3/Emu/Cell/lv2/sys_process.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_process.cpp @@ -439,7 +439,7 @@ void lv2_exitspawn(ppu_thread& ppu, std::vector& argv, std::vector< } // Save LV2 memory containers - g_fxo->init>()->vec = std::move(vec); + ensure(g_fxo->init>())->vec = std::move(vec); // Empty the containers, accumulate their total size u32 total_size = 0; @@ -453,7 +453,7 @@ void lv2_exitspawn(ppu_thread& ppu, std::vector& argv, std::vector< // 1. If newer SDK version suggests higher memory capacity - it is ignored // 2. If newer SDK version suggests lower memory capacity - it is lowered // And if 2. happens while user memory containers exist, the left space can be spent on user memory containers - g_fxo->init(std::min(old_size - total_size, sdk_suggested_mem) + total_size); + ensure(g_fxo->init(std::min(old_size - total_size, sdk_suggested_mem) + total_size)); }; Emu.after_kill_callback = [func = std::move(func), argv = std::move(argv), envp = std::move(envp), data = std::move(data), diff --git a/rpcs3/Emu/System.cpp b/rpcs3/Emu/System.cpp index 2ce0d364f2..d42aa50478 100644 --- a/rpcs3/Emu/System.cpp +++ b/rpcs3/Emu/System.cpp @@ -2893,8 +2893,9 @@ void Emulator::Kill(bool allow_autoexit, bool savestate) if (after_kill_callback) { - after_kill_callback(); - after_kill_callback = nullptr; + // Make after_kill_callback empty before call + const auto callback = std::move(after_kill_callback); + callback(); } }); })); diff --git a/rpcs3/Emu/System.h b/rpcs3/Emu/System.h index 00ccaf717f..1874f2d315 100644 --- a/rpcs3/Emu/System.h +++ b/rpcs3/Emu/System.h @@ -312,6 +312,11 @@ public: return m_config_path; } + bool IsChildProcess() const + { + return m_config_mode == cfg_mode::continuous; + } + game_boot_result BootGame(const std::string& path, const std::string& title_id = "", bool direct = false, cfg_mode config_mode = cfg_mode::custom, const std::string& config_path = ""); bool BootRsxCapture(const std::string& path);