Skip to content

Commit

Permalink
Fix Create PPU Cache
Browse files Browse the repository at this point in the history
  • Loading branch information
elad335 committed Jun 16, 2023
1 parent d5654d6 commit d2f4a47
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 17 deletions.
4 changes: 2 additions & 2 deletions rpcs3/Emu/Cell/PPUAnalyser.h
Expand Up @@ -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<u32> applied_pathes;
};

Expand Down
2 changes: 0 additions & 2 deletions rpcs3/Emu/Cell/PPUModule.cpp
Expand Up @@ -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<ppu_linkage_info>(), ar);
}
Expand Down
25 changes: 15 additions & 10 deletions rpcs3/Emu/System.cpp
Expand Up @@ -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<std::string> dir_queue;
dir_queue.emplace_back(m_path + '/');
Expand Down Expand Up @@ -1394,36 +1392,43 @@ 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_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
{
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_precompile(dir_queue, nullptr);

// Exit "process"
// Exit "process" // Exit "process"
CallFromMainThread([this]
{
Emu.Kill(false);
m_path = m_path_old; // Reset m_path to fix boot from gui
});
});

Run(false);

return game_boot_result::no_errors;
}

Expand Down
6 changes: 3 additions & 3 deletions rpcs3/Emu/cache_utils.cpp
Expand Up @@ -12,15 +12,15 @@ namespace rpcs3::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.");
return {};
}

return _main.cache;
return _main->cache;
}

void limit_cache_size()
Expand Down

0 comments on commit d2f4a47

Please sign in to comment.