Fix Create PPU Cache

This commit is contained in:
Eladash 2023-06-15 21:59:19 +03:00 committed by Ivan
parent 37bc73865d
commit 073b723c09
4 changed files with 24 additions and 16 deletions

View file

@ -107,8 +107,8 @@ struct ppu_module
struct main_ppu_module : public ppu_module struct main_ppu_module : public ppu_module
{ {
u32 elf_entry; u32 elf_entry{};
u32 seg0_code_end; u32 seg0_code_end{};
std::basic_string<u32> applied_pathes; std::basic_string<u32> applied_pathes;
}; };

View file

@ -1051,8 +1051,6 @@ void init_ppu_functions(utils::serial* ar, bool full = false)
if (full) if (full)
{ {
ensure(ar);
// Initialize HLE modules // Initialize HLE modules
ppu_initialize_modules(&g_fxo->get<ppu_linkage_info>(), ar); ppu_initialize_modules(&g_fxo->get<ppu_linkage_info>(), ar);
} }

View file

@ -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"; argv[0] = "/dev_bdvd/PS3_GAME/USRDIR/EBOOT.BIN";
m_dir = "/dev_bdvd/PS3_GAME"; m_dir = "/dev_bdvd/PS3_GAME";
Run(false);
std::string path; std::string path;
std::vector<std::string> dir_queue; std::vector<std::string> dir_queue;
dir_queue.emplace_back(m_path + '/'); 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 // Workaround for analyser glitches
ensure(vm::falloc(0x10000, 0xf0000, vm::main)); 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_ppu_module>(); _main.path.empty()) if (auto& _main = g_fxo->get<main_ppu_module>(); _main.path.empty())
{ {
init_fxo_for_exec(nullptr, false); init_fxo_for_exec(nullptr, true);
}
if (auto main_ppu = idm::get<named_thread<ppu_thread>>(ppu_thread::id_base))
{
// Created by ppu_load_exec, unwanted
main_ppu->state += cpu_flag::exit;
} }
g_fxo->init<named_thread>("SPRX Loader"sv, [this, dir_queue]() mutable g_fxo->init<named_thread>("SPRX Loader"sv, [this, dir_queue]() mutable
{ {
if (auto& _main = g_fxo->get<main_ppu_module>(); !_main.path.empty()) if (auto& _main = g_fxo->get<main_ppu_module>(); !_main.path.empty())
{ {
if (!_main.analyse(0, _main.elf_entry, _main.seg0_code_end, _main.applied_pathes, [](){ return Emu.IsStopped(); }))
{
return;
}
ppu_initialize(_main); ppu_initialize(_main);
} }
if (Emu.IsStopped())
{
return;
}
ppu_precompile(dir_queue, nullptr); ppu_precompile(dir_queue, nullptr);
// Exit "process" // 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; return game_boot_result::no_errors;
} }

View file

@ -12,15 +12,15 @@ namespace rpcs3::cache
{ {
std::string get_ppu_cache() std::string get_ppu_cache()
{ {
auto& _main = g_fxo->get<main_ppu_module>(); const auto _main = g_fxo->try_get<main_ppu_module>();
if (!g_fxo->is_init<main_ppu_module>() || _main.cache.empty()) if (!_main || _main->cache.empty())
{ {
ppu_log.error("PPU Cache location not initialized."); ppu_log.error("PPU Cache location not initialized.");
return {}; return {};
} }
return _main.cache; return _main->cache;
} }
void limit_cache_size() void limit_cache_size()