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/core/loader/loader.cpp | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'src/core/loader/loader.cpp') diff --git a/src/core/loader/loader.cpp b/src/core/loader/loader.cpp index 69bfa2e879..90e23ccc11 100644 --- a/src/core/loader/loader.cpp +++ b/src/core/loader/loader.cpp @@ -17,6 +17,8 @@ #include "core/core.h" #include "core/file_sys/card_image.h" #include "core/file_sys/common_funcs.h" +#include "core/file_sys/content_archive.h" +#include "core/file_sys/registered_cache.h" #include "core/file_sys/submission_package.h" #include "core/hle/kernel/k_process.h" #include "core/loader/deconstructed_rom_directory.h" @@ -41,6 +43,38 @@ std::optional IdentifyFileLoader(FileSys::VirtualFile file) { return std::nullopt; } +struct IndexedProgram { + FileSys::VirtualFile file; + u64 program_id; + bool update_only; +}; + +std::optional ResolveIndexedProgram(Core::System& system, u64 program_id, + std::size_t program_index) { + if (program_index == 0 || program_id == 0) { + return std::nullopt; + } + + const auto target_id = FileSys::GetBaseTitleIDWithProgramIndex(program_id, program_index); + const auto& provider = system.GetContentProvider(); + + if (auto base = provider.GetEntryRaw(target_id, FileSys::ContentRecordType::Program)) { + LOG_INFO(Loader, "Program index {} resolved to {:016X}", program_index, target_id); + return IndexedProgram{std::move(base), target_id, false}; + } + + const auto update_id = FileSys::GetUpdateTitleID(target_id); + if (auto update = provider.GetEntryRaw(update_id, FileSys::ContentRecordType::Program)) { + LOG_INFO(Loader, "Program index {} has no base program, loading it from update {:016X}", + program_index, update_id); + return IndexedProgram{std::move(update), target_id, true}; + } + + LOG_WARNING(Loader, "No program NCA for {:016X} (index {}), falling back to the container", + target_id, program_index); + return std::nullopt; +} + std::shared_ptr OpenContainerAsNsp(FileSys::VirtualFile file, FileType type, u64 program_id = 0, std::size_t program_index = 0) { @@ -321,6 +355,11 @@ std::unique_ptr GetLoader(Core::System& system, FileSys::VirtualFile return nullptr; } + if (const auto indexed = ResolveIndexedProgram(system, program_id, program_index)) { + return std::make_unique( + indexed->file, indexed->update_only ? indexed->program_id : 0); + } + FileType type = IdentifyFile(file); const FileType filename_type = GuessFromFilename(file->GetName()); -- cgit v1.2.3