Skip to content

Commit

Permalink
Merge branch 'master' into synchronization2-3
Browse files Browse the repository at this point in the history
  • Loading branch information
kd-11 committed Jun 29, 2023
2 parents b1a9205 + 593f850 commit 25a25bc
Show file tree
Hide file tree
Showing 17 changed files with 83 additions and 55 deletions.
37 changes: 21 additions & 16 deletions rpcs3/Emu/Cell/PPUModule.cpp
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;
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;
// 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<id_manager::id_map<lv2_memory_container>>();
g_fxo->init<lv2_memory_container>(mem_size);
}
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<id_manager::id_map<lv2_memory_container>>();
g_fxo->init<lv2_memory_container>(mem_size);
}

if (!virtual_load)
{
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();
}

Expand Down
22 changes: 5 additions & 17 deletions rpcs3/Emu/Cell/PPUThread.cpp
Expand Up @@ -2996,10 +2996,6 @@ extern void ppu_precompile(std::vector<std::string>& dir_queue, std::vector<ppu_

const std::string firmware_sprx_path = vfs::get("/dev_flash/sys/external/");

// Map fixed address executables area, fake overlay support
const bool had_ovl = !vm::map(0x3000'0000, 0x1000'0000, 0x202).operator bool();
const u32 ppc_seg = std::exchange(g_ps3_process_info.ppc_seg, 0x3);

std::vector<std::pair<std::string, u64>> file_queue;
file_queue.reserve(2000);

Expand Down Expand Up @@ -3084,7 +3080,7 @@ extern void ppu_precompile(std::vector<std::string>& dir_queue, std::vector<ppu_
}

// Check .self filename
if (upper.ends_with(".SELF"))
if (upper.ends_with(".SELF") && Emu.GetBoot() != dir_queue[i] + entry.name)
{
// Get full path
file_queue.emplace_back(dir_queue[i] + entry.name, 0);
Expand Down Expand Up @@ -3302,15 +3298,16 @@ extern void ppu_precompile(std::vector<std::string>& dir_queue, std::vector<ppu_
{
while (exec_err == elf_error::ok)
{
main_ppu_module& _main = g_fxo->get<main_ppu_module>();
_main = {};

if (!ppu_load_exec(obj, true, path))
{
// Abort
exec_err = elf_error::header_type;
break;
}

main_ppu_module& _main = g_fxo->get<main_ppu_module>();

if (!_main.analyse(0, _main.elf_entry, _main.seg0_code_end, _main.applied_pathes, [](){ return Emu.IsStopped(); }))
{
break;
Expand Down Expand Up @@ -3338,15 +3335,6 @@ extern void ppu_precompile(std::vector<std::string>& dir_queue, std::vector<ppu_
});

exec_worker();

// Revert changes

if (!had_ovl)
{
ensure(vm::unmap(0x3000'0000).second);
}

g_ps3_process_info.ppc_seg = ppc_seg;
}

extern void ppu_initialize()
Expand Down Expand Up @@ -3457,7 +3445,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<std::string> dirs = Emu.GetGameDirs();
Expand Down
4 changes: 2 additions & 2 deletions rpcs3/Emu/Cell/lv2/sys_process.cpp
Expand Up @@ -439,7 +439,7 @@ void lv2_exitspawn(ppu_thread& ppu, std::vector<std::string>& argv, std::vector<
}

// Save LV2 memory containers
g_fxo->init<id_map<lv2_memory_container>>()->vec = std::move(vec);
ensure(g_fxo->init<id_map<lv2_memory_container>>())->vec = std::move(vec);

// Empty the containers, accumulate their total size
u32 total_size = 0;
Expand All @@ -453,7 +453,7 @@ void lv2_exitspawn(ppu_thread& ppu, std::vector<std::string>& 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<lv2_memory_container>(std::min(old_size - total_size, sdk_suggested_mem) + total_size);
ensure(g_fxo->init<lv2_memory_container>(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),
Expand Down
22 changes: 12 additions & 10 deletions rpcs3/Emu/System.cpp
Expand Up @@ -2606,13 +2606,20 @@ void Emulator::Kill(bool allow_autoexit, bool savestate)
{
const auto closed_sucessfully = std::make_shared<atomic_t<bool>>(false);

bool is_being_held_longer = false;

for (int i = 0; thread_ctrl::state() != thread_state::aborting;)
{
if (g_watchdog_hold_ctr)
{
is_being_held_longer = true;
}

// We don't need accurate timekeeping, using clocks may interfere with debugging
if (i >= 2000)
if (i >= (is_being_held_longer ? 5000 : 2000))
{
// Total amount of waiting: about 10s
GetCallbacks().on_emulation_stop_no_response(closed_sucessfully, 10);
GetCallbacks().on_emulation_stop_no_response(closed_sucessfully, is_being_held_longer ? 25 : 10);

while (thread_ctrl::state() != thread_state::aborting)
{
Expand All @@ -2623,12 +2630,6 @@ void Emulator::Kill(bool allow_autoexit, bool savestate)
}

thread_ctrl::wait_for(5'000);

if (!g_watchdog_hold_ctr)
{
// Don't count if there are still uninterruptable threads like PPU LLVM workers
i++;
}
}

*closed_sucessfully = true;
Expand Down Expand Up @@ -2893,8 +2894,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();
}
});
}));
Expand Down
5 changes: 5 additions & 0 deletions rpcs3/Emu/System.h
Expand Up @@ -312,6 +312,11 @@ class Emulator final
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);

Expand Down
3 changes: 3 additions & 0 deletions rpcs3/rpcs3qt/debugger_frame.cpp
Expand Up @@ -230,6 +230,9 @@ bool debugger_frame::eventFilter(QObject* object, QEvent* event)

void debugger_frame::closeEvent(QCloseEvent* event)
{
SaveSettings();
m_gui_settings->sync();

QDockWidget::closeEvent(event);
Q_EMIT DebugFrameClosed();
}
Expand Down
5 changes: 3 additions & 2 deletions rpcs3/rpcs3qt/game_list_frame.cpp
Expand Up @@ -222,8 +222,6 @@ game_list_frame::~game_list_frame()
WaitAndAbortRepaintThreads();
gui::utils::stop_future_watcher(m_parsing_watcher, true);
gui::utils::stop_future_watcher(m_refresh_watcher, true);

SaveSettings();
}

void game_list_frame::OnColClicked(int col)
Expand Down Expand Up @@ -2226,6 +2224,9 @@ void game_list_frame::FocusAndSelectFirstEntryIfNoneIs()

void game_list_frame::closeEvent(QCloseEvent *event)
{
SaveSettings();
m_gui_settings->sync();

QDockWidget::closeEvent(event);
Q_EMIT GameListFrameClosed();
}
Expand Down
4 changes: 3 additions & 1 deletion rpcs3/rpcs3qt/main_window.cpp
Expand Up @@ -109,7 +109,6 @@ main_window::main_window(std::shared_ptr<gui_settings> gui_settings, std::shared

main_window::~main_window()
{
SaveWindowState();
}

/* An init method is used so that RPCS3App can create the necessary connects before calling init (specifically the stylesheet connect).
Expand Down Expand Up @@ -1667,6 +1666,8 @@ void main_window::SaveWindowState() const
m_game_list_frame->SaveSettings();
// Save splitter state
m_debugger_frame->SaveSettings();

m_gui_settings->sync();
}

void main_window::RepaintThumbnailIcons()
Expand Down Expand Up @@ -3204,6 +3205,7 @@ void main_window::closeEvent(QCloseEvent* closeEvent)
Emu.GracefulShutdown(false);
}

SaveWindowState();
Emu.Quit(true);
}

Expand Down
14 changes: 9 additions & 5 deletions rpcs3/rpcs3qt/pad_settings_dialog.cpp
Expand Up @@ -220,18 +220,22 @@ pad_settings_dialog::pad_settings_dialog(std::shared_ptr<gui_settings> gui_setti
ChangeProfile(ui->chooseProfile->currentText());
}

void pad_settings_dialog::closeEvent(QCloseEvent* event)
{
m_gui_settings->SetValue(gui::pads_geometry, saveGeometry());
m_gui_settings->sync();

QDialog::closeEvent(event);
}

pad_settings_dialog::~pad_settings_dialog()
{
if (m_input_thread)
{
m_input_thread_state = input_thread_state::pausing;
auto& thread = *m_input_thread;
thread = thread_state::aborting;
thread();
*m_input_thread = thread_state::finished;
}

m_gui_settings->SetValue(gui::pads_geometry, saveGeometry());

if (!Emu.IsStopped())
{
pad::reset(Emu.GetTitleID());
Expand Down
1 change: 1 addition & 0 deletions rpcs3/rpcs3qt/pad_settings_dialog.h
Expand Up @@ -236,4 +236,5 @@ private Q_SLOTS:
void mouseMoveEvent(QMouseEvent *event) override;
void wheelEvent(QWheelEvent *event) override;
bool eventFilter(QObject* object, QEvent* event) override;
void closeEvent(QCloseEvent* event) override;
};
9 changes: 8 additions & 1 deletion rpcs3/rpcs3qt/patch_manager_dialog.cpp
Expand Up @@ -151,11 +151,18 @@ patch_manager_dialog::patch_manager_dialog(std::shared_ptr<gui_settings> gui_set
download_update(true, false);
}

patch_manager_dialog::~patch_manager_dialog()
void patch_manager_dialog::closeEvent(QCloseEvent* event)
{
// Save gui settings
m_gui_settings->SetValue(gui::pm_geometry, saveGeometry());
m_gui_settings->SetValue(gui::pm_splitter_state, ui->splitter->saveState());
m_gui_settings->sync();

QDialog::closeEvent(event);
}

patch_manager_dialog::~patch_manager_dialog()
{
}

int patch_manager_dialog::exec()
Expand Down
1 change: 1 addition & 0 deletions rpcs3/rpcs3qt/patch_manager_dialog.h
Expand Up @@ -83,4 +83,5 @@ private Q_SLOTS:
void dragEnterEvent(QDragEnterEvent* event) override;
void dragMoveEvent(QDragMoveEvent* event) override;
void dragLeaveEvent(QDragLeaveEvent* event) override;
void closeEvent(QCloseEvent* event) override;
};
1 change: 1 addition & 0 deletions rpcs3/rpcs3qt/rsx_debugger.cpp
Expand Up @@ -267,6 +267,7 @@ void rsx_debugger::closeEvent(QCloseEvent* event)

m_gui_settings->SetValue(gui::rsx_states, states);
m_gui_settings->SetValue(gui::rsx_geometry, saveGeometry());
m_gui_settings->sync();

QDialog::closeEvent(event);
}
Expand Down
1 change: 1 addition & 0 deletions rpcs3/rpcs3qt/save_manager_dialog.cpp
Expand Up @@ -589,6 +589,7 @@ void save_manager_dialog::SetIconSize(int size)
void save_manager_dialog::closeEvent(QCloseEvent *event)
{
m_gui_settings->SetValue(gui::sd_geometry, saveGeometry());
m_gui_settings->sync();

QDialog::closeEvent(event);
}
Expand Down
7 changes: 6 additions & 1 deletion rpcs3/rpcs3qt/settings_dialog.cpp
Expand Up @@ -2365,9 +2365,14 @@ settings_dialog::settings_dialog(std::shared_ptr<gui_settings> gui_settings, std
}
}

settings_dialog::~settings_dialog()
void settings_dialog::closeEvent(QCloseEvent* event)
{
m_gui_settings->SetValue(gui::cfg_geometry, saveGeometry());
m_gui_settings->sync();
}

settings_dialog::~settings_dialog()
{
}

void settings_dialog::EnhanceSlider(emu_settings_type settings_type, QSlider* slider, QLabel* label, const QString& label_text) const
Expand Down
1 change: 1 addition & 0 deletions rpcs3/rpcs3qt/settings_dialog.h
Expand Up @@ -64,4 +64,5 @@ class settings_dialog : public QDialog
void SubscribeDescription(QLabel* description);
void SubscribeTooltip(QObject* object, const QString& tooltip);
bool eventFilter(QObject* object, QEvent* event) override;
void closeEvent(QCloseEvent* event) override;
};
1 change: 1 addition & 0 deletions rpcs3/rpcs3qt/trophy_manager_dialog.cpp
Expand Up @@ -1224,6 +1224,7 @@ void trophy_manager_dialog::closeEvent(QCloseEvent *event)
m_gui_settings->SetValue(gui::tr_splitterState, m_splitter->saveState());
m_gui_settings->SetValue(gui::tr_games_state, m_game_table->horizontalHeader()->saveState());
m_gui_settings->SetValue(gui::tr_trophy_state, m_trophy_table->horizontalHeader()->saveState());
m_gui_settings->sync();

QWidget::closeEvent(event);
}
Expand Down

0 comments on commit 25a25bc

Please sign in to comment.