From 54cd5fb8ebf11b71c676b72a32811873caef20de Mon Sep 17 00:00:00 2001 From: Maufeat Date: Sat, 29 Aug 2026 01:04:02 +0200 Subject: [core, hle, video_core, memory] Improve multi-process, display layers, dynamic shader cache and rework overlay (#4238) - [x] I have read and followed the [Contribution Guidelines](https://git.eden-emu.dev/eden-emu/eden/src/branch/master/CONTRIBUTING.md#code-contributions). - [x] I have read and followed the [AI Policy](https://git.eden-emu.dev/eden-emu/eden/src/branch/master/docs/policies/AI.md) - [x] I have read and followed the [Coding Guidelines](https://git.eden-emu.dev/eden-emu/eden/src/branch/master/docs/policies/Coding.md) to the best of my ability. ------------------- - Dynamic shader cache reloading capability for qlaunch - Multi-process improvements (thanks to @frank1734), instead of just using the main application we now respect caller process (also did it for HID devices while I was at it) - Layer stack masks & shared buffer screenshot for video core, added different masks (screenshot, recording, etc.) this was discovered as an issue due to how in qlaunch the transition was not right between applications. May not be perfect but also fixes screenshots while using qlaunch - Reworked overlay display management (input and visibility) - instead of random numbers as I've previously did, I decided to add an AppletZIndex enum for better readability. Also split capability of input by touch and gamepad. - etc. Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/4238 Reviewed-by: Samuel Reviewed-by: CamilleLaVey Reviewed-by: MaranBr --- src/yuzu/main_window.cpp | 82 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 81 insertions(+), 1 deletion(-) (limited to 'src/yuzu/main_window.cpp') diff --git a/src/yuzu/main_window.cpp b/src/yuzu/main_window.cpp index f18a989255..934879ade5 100644 --- a/src/yuzu/main_window.cpp +++ b/src/yuzu/main_window.cpp @@ -139,6 +139,7 @@ static FileSys::VirtualFile VfsDirectoryCreateFileWrapper(const FileSys::Virtual #include "core/hle/service/am/frontend/applet_web_browser_types.h" #include "core/file_sys/card_image.h" +#include "core/file_sys/common_funcs.h" #include "core/file_sys/romfs.h" #include "core/file_sys/savedata_factory.h" @@ -1967,12 +1968,37 @@ void MainWindow::BootGame(const QString& filename, Service::AM::FrontendAppletPa render_window->Exit(); }); + QtCommon::system->RegisterApplicationChangedCallback([this](u64 changed_program_id) { + if (QtCommon::emu_thread) + QtCommon::emu_thread->RequestDiskShaderCacheReload(changed_program_id); + + QMetaObject::invokeMethod( + this, [this, changed_program_id] { this->OnApplicationChanged(changed_program_id); }, + Qt::QueuedConnection); + }); + connect(render_window, &GRenderWindow::Closed, this, &MainWindow::OnStopGame); connect(render_window, &GRenderWindow::MouseActivity, this, &MainWindow::OnMouseActivity); connect(QtCommon::emu_thread.get(), &EmuThread::LoadProgress, loading_screen, &LoadingScreen::OnLoadProgress, Qt::QueuedConnection); + connect( + QtCommon::emu_thread.get(), &EmuThread::ShaderCacheReloadStarted, this, + [this] { + loading_screen->Prepare(QtCommon::system->GetAppLoader()); + loading_screen->show(); + render_window->hide(); + }, + Qt::QueuedConnection); + + connect( + QtCommon::emu_thread.get(), &EmuThread::ShaderCacheReloadFinished, this, + [this] { + loading_screen->OnLoadComplete(); + }, + Qt::QueuedConnection); + // Update the GUI UpdateStatusButtons(); if (ui->action_Single_Window_Mode->isChecked()) { @@ -3061,12 +3087,31 @@ void MainWindow::OnLoadComplete() { } void MainWindow::OnExecuteProgram(std::size_t program_index) { + const u64 previous_program_id = QtCommon::system->GetApplicationProcessProgramID(); + + const auto current_path = + QString::fromStdString(QtCommon::system->GetCurrentApplicationFilePath()); + + LOG_INFO(Frontend, "ExecuteProgram requested, program_index={} previous_program_id={:016X}", + program_index, previous_program_id); + ShutdownGame(); auto params = ApplicationAppletParameters(); params.program_index = static_cast(program_index); params.launch_type = Service::AM::LaunchType::ApplicationInitiated; - BootGame(last_filename_booted, params); + + if (previous_program_id > static_cast(Service::AM::AppletProgramId::MaxProgramId)) { + params.previous_program_index = + static_cast(previous_program_id - FileSys::GetBaseTitleID(previous_program_id)); + params.program_id = previous_program_id; + } + + const auto filename = current_path.isEmpty() ? last_filename_booted : current_path; + + LOG_DEBUG(Frontend, "ExecuteProgram booting from path: {}", filename.toStdString()); + + BootGame(filename, params); } void MainWindow::OnExit() { @@ -3995,6 +4040,41 @@ void MainWindow::OnEmulatorUpdateAvailable() { } #endif +void MainWindow::OnApplicationChanged(u64 program_id) { + if (!emulation_running || program_id == 0) + return; + + std::string title_name; + std::string title_version; + + const FileSys::PatchManager pm(program_id, QtCommon::system->GetFileSystemController(), + QtCommon::system->GetContentProvider()); + if (const auto metadata = pm.GetControlMetadata(); metadata.first != nullptr) { + title_version = metadata.first->GetVersionString(); + title_name = metadata.first->GetApplicationName(); + } + if (title_name.empty()) { + title_name = fmt::format("{:016X}", program_id); + } + + if (const auto* process = QtCommon::system->Kernel().ApplicationProcess(); process != nullptr) { + const auto instruction_set_suffix = process->Is64Bit() ? tr("(64-bit)") : tr("(32-bit)"); + title_name = + tr("%1 %2", "%1 is the title name. %2 indicates if the title is 64-bit or 32-bit") + .arg(QString::fromStdString(title_name), instruction_set_suffix) + .toStdString(); + } + + LOG_INFO(Frontend, "Now running: {:016X} | {} | {}", program_id, title_name, title_version); + + UpdateWindowTitle(title_name, title_version, + QtCommon::system->GPU().Renderer().GetDeviceVendor()); + + // Switch to record playtime for the running program + if (play_time_manager) + play_time_manager->SetProgramId(program_id); +} + void MainWindow::UpdateWindowTitle(std::string_view title_name, std::string_view title_version, std::string_view gpu_vendor) { static const std::string build_id = std::string{Common::g_build_id}; -- cgit v1.2.3