From b48cdc2260793563948b4515d4256a409a4c09da Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Thu, 26 Sep 2019 17:06:43 +0300 Subject: [PATCH] Use g_fxo for global ppu_module instance Also fix autonomous PRX/SPU loading sequence. --- rpcs3/Emu/Cell/PPUAnalyser.h | 2 +- rpcs3/Emu/Cell/PPUModule.cpp | 4 ++-- rpcs3/Emu/Cell/PPUThread.cpp | 7 +++++-- rpcs3/Emu/System.cpp | 8 +++++--- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/rpcs3/Emu/Cell/PPUAnalyser.h b/rpcs3/Emu/Cell/PPUAnalyser.h index e01466961b..467c391c17 100644 --- a/rpcs3/Emu/Cell/PPUAnalyser.h +++ b/rpcs3/Emu/Cell/PPUAnalyser.h @@ -68,7 +68,7 @@ struct ppu_segment // PPU Module Information struct ppu_module { - uchar sha1[20]; + uchar sha1[20]{}; std::string name; std::string path; std::string cache; diff --git a/rpcs3/Emu/Cell/PPUModule.cpp b/rpcs3/Emu/Cell/PPUModule.cpp index 7f13c4b553..ef92d93251 100644 --- a/rpcs3/Emu/Cell/PPUModule.cpp +++ b/rpcs3/Emu/Cell/PPUModule.cpp @@ -992,7 +992,7 @@ std::shared_ptr ppu_load_prx(const ppu_prx_object& elf, const std::stri LOG_NOTICE(LOADER, "PRX library hash: %s (<- %u)", hash, applied); - if (Emu.IsReady() && fxm::import([&] { return prx; })) + if (Emu.IsReady() && g_fxo->get()->segs.empty()) { // Special loading mode ppu_thread_params p{}; @@ -1043,7 +1043,7 @@ void ppu_unload_prx(const lv2_prx& prx) void ppu_load_exec(const ppu_exec_object& elf) { // Set for delayed initialization in ppu_initialize() - const auto _main = fxm::make(); + const auto _main = g_fxo->get(); // Access linkage information object const auto link = g_fxo->init(); diff --git a/rpcs3/Emu/Cell/PPUThread.cpp b/rpcs3/Emu/Cell/PPUThread.cpp index d08c8468da..e15aff7a12 100644 --- a/rpcs3/Emu/Cell/PPUThread.cpp +++ b/rpcs3/Emu/Cell/PPUThread.cpp @@ -1304,7 +1304,7 @@ extern bool ppu_stdcx(ppu_thread& ppu, u32 addr, u64 reg_value) extern void ppu_initialize() { - const auto _main = fxm::get(); + const auto _main = g_fxo->get(); if (!_main) { @@ -1317,7 +1317,10 @@ extern void ppu_initialize() } // Initialize main module - ppu_initialize(*_main); + if (!_main->segs.empty()) + { + ppu_initialize(*_main); + } std::vector prx_list; diff --git a/rpcs3/Emu/System.cpp b/rpcs3/Emu/System.cpp index e4dc48ce0b..12b118ccc1 100644 --- a/rpcs3/Emu/System.cpp +++ b/rpcs3/Emu/System.cpp @@ -605,7 +605,7 @@ const std::string Emulator::GetBackgroundPicturePath() const std::string Emulator::PPUCache() const { - const auto _main = fxm::check_unlocked(); + const auto _main = g_fxo->get(); if (!_main || _main->cache.empty()) { @@ -1557,9 +1557,9 @@ void Emulator::Load(const std::string& title_id, bool add_only, bool force_globa LOG_NOTICE(LOADER, "Elf path: %s", argv[0]); } - ppu_load_exec(ppu_exec); + const auto _main = g_fxo->init(); - const auto _main = fxm::get(); + ppu_load_exec(ppu_exec); _main->cache = fs::get_cache_dir() + "cache/"; @@ -1594,6 +1594,7 @@ void Emulator::Load(const std::string& title_id, bool add_only, bool force_globa m_state = system_state::ready; GetCallbacks().on_ready(); vm::init(); + g_fxo->init(); ppu_load_prx(ppu_prx, m_path); } else if (spu_exec.open(elf_file) == elf_error::ok) @@ -1602,6 +1603,7 @@ void Emulator::Load(const std::string& title_id, bool add_only, bool force_globa m_state = system_state::ready; GetCallbacks().on_ready(); vm::init(); + g_fxo->init(); spu_load_exec(spu_exec); } else