diff options
| author | 2024-01-31 10:25:28 -0600 | |
|---|---|---|
| committer | 2024-01-31 10:25:28 -0600 | |
| commit | 7cc7d027f74b5bffc0b3f8f3a6c3110999c7cc4c (patch) | |
| tree | 24b2ed412f2683c8460839778ea7761d052bc38f /src/core/core.cpp | |
| parent | Merge pull request #12858 from liamwhite/non-blocking (diff) | |
| parent | am: push storage from error applet with non-zero size (diff) | |
| download | yuzu-7cc7d027f74b5bffc0b3f8f3a6c3110999c7cc4c.tar.gz yuzu-7cc7d027f74b5bffc0b3f8f3a6c3110999c7cc4c.tar.xz yuzu-7cc7d027f74b5bffc0b3f8f3a6c3110999c7cc4c.zip | |
Merge pull request #12760 from liamwhite/mp-am
am: rewrite for multiprocess support
Diffstat (limited to 'src/core/core.cpp')
| -rw-r--r-- | src/core/core.cpp | 72 |
1 files changed, 42 insertions, 30 deletions
diff --git a/src/core/core.cpp b/src/core/core.cpp index 11bf8d2f6..435ef6793 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp | |||
| @@ -36,7 +36,8 @@ | |||
| 36 | #include "core/hle/kernel/kernel.h" | 36 | #include "core/hle/kernel/kernel.h" |
| 37 | #include "core/hle/kernel/physical_core.h" | 37 | #include "core/hle/kernel/physical_core.h" |
| 38 | #include "core/hle/service/acc/profile_manager.h" | 38 | #include "core/hle/service/acc/profile_manager.h" |
| 39 | #include "core/hle/service/am/applets/applets.h" | 39 | #include "core/hle/service/am/applet_manager.h" |
| 40 | #include "core/hle/service/am/frontend/applets.h" | ||
| 40 | #include "core/hle/service/apm/apm_controller.h" | 41 | #include "core/hle/service/apm/apm_controller.h" |
| 41 | #include "core/hle/service/filesystem/filesystem.h" | 42 | #include "core/hle/service/filesystem/filesystem.h" |
| 42 | #include "core/hle/service/glue/glue_manager.h" | 43 | #include "core/hle/service/glue/glue_manager.h" |
| @@ -135,8 +136,8 @@ FileSys::VirtualFile GetGameFileFromPath(const FileSys::VirtualFilesystem& vfs, | |||
| 135 | 136 | ||
| 136 | struct System::Impl { | 137 | struct System::Impl { |
| 137 | explicit Impl(System& system) | 138 | explicit Impl(System& system) |
| 138 | : kernel{system}, fs_controller{system}, hid_core{}, room_network{}, | 139 | : kernel{system}, fs_controller{system}, hid_core{}, room_network{}, cpu_manager{system}, |
| 139 | cpu_manager{system}, reporter{system}, applet_manager{system}, profile_manager{} {} | 140 | reporter{system}, applet_manager{system}, frontend_applets{system}, profile_manager{} {} |
| 140 | 141 | ||
| 141 | void Initialize(System& system) { | 142 | void Initialize(System& system) { |
| 142 | device_memory = std::make_unique<Core::DeviceMemory>(); | 143 | device_memory = std::make_unique<Core::DeviceMemory>(); |
| @@ -157,7 +158,7 @@ struct System::Impl { | |||
| 157 | } | 158 | } |
| 158 | 159 | ||
| 159 | // Create default implementations of applets if one is not provided. | 160 | // Create default implementations of applets if one is not provided. |
| 160 | applet_manager.SetDefaultAppletsIfMissing(); | 161 | frontend_applets.SetDefaultAppletsIfMissing(); |
| 161 | 162 | ||
| 162 | is_async_gpu = Settings::values.use_asynchronous_gpu_emulation.GetValue(); | 163 | is_async_gpu = Settings::values.use_asynchronous_gpu_emulation.GetValue(); |
| 163 | 164 | ||
| @@ -330,16 +331,27 @@ struct System::Impl { | |||
| 330 | } | 331 | } |
| 331 | 332 | ||
| 332 | SystemResultStatus Load(System& system, Frontend::EmuWindow& emu_window, | 333 | SystemResultStatus Load(System& system, Frontend::EmuWindow& emu_window, |
| 333 | const std::string& filepath, u64 program_id, | 334 | const std::string& filepath, |
| 334 | std::size_t program_index) { | 335 | Service::AM::FrontendAppletParameters& params) { |
| 335 | app_loader = Loader::GetLoader(system, GetGameFileFromPath(virtual_filesystem, filepath), | 336 | app_loader = Loader::GetLoader(system, GetGameFileFromPath(virtual_filesystem, filepath), |
| 336 | program_id, program_index); | 337 | params.program_id, params.program_index); |
| 337 | 338 | ||
| 338 | if (!app_loader) { | 339 | if (!app_loader) { |
| 339 | LOG_CRITICAL(Core, "Failed to obtain loader for {}!", filepath); | 340 | LOG_CRITICAL(Core, "Failed to obtain loader for {}!", filepath); |
| 340 | return SystemResultStatus::ErrorGetLoader; | 341 | return SystemResultStatus::ErrorGetLoader; |
| 341 | } | 342 | } |
| 342 | 343 | ||
| 344 | if (app_loader->ReadProgramId(params.program_id) != Loader::ResultStatus::Success) { | ||
| 345 | LOG_ERROR(Core, "Failed to find title id for ROM!"); | ||
| 346 | } | ||
| 347 | |||
| 348 | std::string name = "Unknown program"; | ||
| 349 | if (app_loader->ReadTitle(name) != Loader::ResultStatus::Success) { | ||
| 350 | LOG_ERROR(Core, "Failed to read title for ROM!"); | ||
| 351 | } | ||
| 352 | |||
| 353 | LOG_INFO(Core, "Loading {} ({})", name, params.program_id); | ||
| 354 | |||
| 343 | InitializeKernel(system); | 355 | InitializeKernel(system); |
| 344 | 356 | ||
| 345 | // Create the application process. | 357 | // Create the application process. |
| @@ -373,9 +385,14 @@ struct System::Impl { | |||
| 373 | cheat_engine->Initialize(); | 385 | cheat_engine->Initialize(); |
| 374 | } | 386 | } |
| 375 | 387 | ||
| 388 | // Register with applet manager. | ||
| 389 | applet_manager.CreateAndInsertByFrontendAppletParameters(main_process->GetProcessId(), | ||
| 390 | params); | ||
| 391 | |||
| 376 | // All threads are started, begin main process execution, now that we're in the clear. | 392 | // All threads are started, begin main process execution, now that we're in the clear. |
| 377 | main_process->Run(load_parameters->main_thread_priority, | 393 | main_process->Run(load_parameters->main_thread_priority, |
| 378 | load_parameters->main_thread_stack_size); | 394 | load_parameters->main_thread_stack_size); |
| 395 | main_process->Close(); | ||
| 379 | 396 | ||
| 380 | if (Settings::values.gamecard_inserted) { | 397 | if (Settings::values.gamecard_inserted) { |
| 381 | if (Settings::values.gamecard_current_game) { | 398 | if (Settings::values.gamecard_current_game) { |
| @@ -386,21 +403,13 @@ struct System::Impl { | |||
| 386 | } | 403 | } |
| 387 | } | 404 | } |
| 388 | 405 | ||
| 389 | if (app_loader->ReadProgramId(program_id) != Loader::ResultStatus::Success) { | 406 | perf_stats = std::make_unique<PerfStats>(params.program_id); |
| 390 | LOG_ERROR(Core, "Failed to find title id for ROM (Error {})", load_result); | ||
| 391 | } | ||
| 392 | perf_stats = std::make_unique<PerfStats>(program_id); | ||
| 393 | // Reset counters and set time origin to current frame | 407 | // Reset counters and set time origin to current frame |
| 394 | GetAndResetPerfStats(); | 408 | GetAndResetPerfStats(); |
| 395 | perf_stats->BeginSystemFrame(); | 409 | perf_stats->BeginSystemFrame(); |
| 396 | 410 | ||
| 397 | std::string name = "Unknown Game"; | ||
| 398 | if (app_loader->ReadTitle(name) != Loader::ResultStatus::Success) { | ||
| 399 | LOG_ERROR(Core, "Failed to read title for ROM (Error {})", load_result); | ||
| 400 | } | ||
| 401 | |||
| 402 | std::string title_version; | 411 | std::string title_version; |
| 403 | const FileSys::PatchManager pm(program_id, system.GetFileSystemController(), | 412 | const FileSys::PatchManager pm(params.program_id, system.GetFileSystemController(), |
| 404 | system.GetContentProvider()); | 413 | system.GetContentProvider()); |
| 405 | const auto metadata = pm.GetControlMetadata(); | 414 | const auto metadata = pm.GetControlMetadata(); |
| 406 | if (metadata.first != nullptr) { | 415 | if (metadata.first != nullptr) { |
| @@ -409,14 +418,15 @@ struct System::Impl { | |||
| 409 | if (auto room_member = room_network.GetRoomMember().lock()) { | 418 | if (auto room_member = room_network.GetRoomMember().lock()) { |
| 410 | Network::GameInfo game_info; | 419 | Network::GameInfo game_info; |
| 411 | game_info.name = name; | 420 | game_info.name = name; |
| 412 | game_info.id = program_id; | 421 | game_info.id = params.program_id; |
| 413 | game_info.version = title_version; | 422 | game_info.version = title_version; |
| 414 | room_member->SendGameInfo(game_info); | 423 | room_member->SendGameInfo(game_info); |
| 415 | } | 424 | } |
| 416 | 425 | ||
| 417 | // Workarounds: | 426 | // Workarounds: |
| 418 | // Activate this in Super Smash Brothers Ultimate, it only affects AMD cards using AMDVLK | 427 | // Activate this in Super Smash Brothers Ultimate, it only affects AMD cards using AMDVLK |
| 419 | Settings::values.renderer_amdvlk_depth_bias_workaround = program_id == 0x1006A800016E000ULL; | 428 | Settings::values.renderer_amdvlk_depth_bias_workaround = |
| 429 | params.program_id == 0x1006A800016E000ULL; | ||
| 420 | 430 | ||
| 421 | status = SystemResultStatus::Success; | 431 | status = SystemResultStatus::Success; |
| 422 | return status; | 432 | return status; |
| @@ -455,6 +465,7 @@ struct System::Impl { | |||
| 455 | } | 465 | } |
| 456 | kernel.CloseServices(); | 466 | kernel.CloseServices(); |
| 457 | kernel.ShutdownCores(); | 467 | kernel.ShutdownCores(); |
| 468 | applet_manager.Reset(); | ||
| 458 | services.reset(); | 469 | services.reset(); |
| 459 | service_manager.reset(); | 470 | service_manager.reset(); |
| 460 | fs_controller.Reset(); | 471 | fs_controller.Reset(); |
| @@ -566,8 +577,9 @@ struct System::Impl { | |||
| 566 | 577 | ||
| 567 | std::unique_ptr<Tools::RenderdocAPI> renderdoc_api; | 578 | std::unique_ptr<Tools::RenderdocAPI> renderdoc_api; |
| 568 | 579 | ||
| 569 | /// Frontend applets | 580 | /// Applets |
| 570 | Service::AM::Applets::AppletManager applet_manager; | 581 | Service::AM::AppletManager applet_manager; |
| 582 | Service::AM::Frontend::FrontendAppletHolder frontend_applets; | ||
| 571 | 583 | ||
| 572 | /// APM (Performance) services | 584 | /// APM (Performance) services |
| 573 | Service::APM::Controller apm_controller{core_timing}; | 585 | Service::APM::Controller apm_controller{core_timing}; |
| @@ -680,8 +692,8 @@ void System::InitializeDebugger() { | |||
| 680 | } | 692 | } |
| 681 | 693 | ||
| 682 | SystemResultStatus System::Load(Frontend::EmuWindow& emu_window, const std::string& filepath, | 694 | SystemResultStatus System::Load(Frontend::EmuWindow& emu_window, const std::string& filepath, |
| 683 | u64 program_id, std::size_t program_index) { | 695 | Service::AM::FrontendAppletParameters& params) { |
| 684 | return impl->Load(*this, emu_window, filepath, program_id, program_index); | 696 | return impl->Load(*this, emu_window, filepath, params); |
| 685 | } | 697 | } |
| 686 | 698 | ||
| 687 | bool System::IsPoweredOn() const { | 699 | bool System::IsPoweredOn() const { |
| @@ -871,19 +883,19 @@ void System::RegisterCheatList(const std::vector<Memory::CheatEntry>& list, | |||
| 871 | impl->cheat_engine->SetMainMemoryParameters(main_region_begin, main_region_size); | 883 | impl->cheat_engine->SetMainMemoryParameters(main_region_begin, main_region_size); |
| 872 | } | 884 | } |
| 873 | 885 | ||
| 874 | void System::SetAppletFrontendSet(Service::AM::Applets::AppletFrontendSet&& set) { | 886 | void System::SetFrontendAppletSet(Service::AM::Frontend::FrontendAppletSet&& set) { |
| 875 | impl->applet_manager.SetAppletFrontendSet(std::move(set)); | 887 | impl->frontend_applets.SetFrontendAppletSet(std::move(set)); |
| 876 | } | 888 | } |
| 877 | 889 | ||
| 878 | void System::SetDefaultAppletFrontendSet() { | 890 | Service::AM::Frontend::FrontendAppletHolder& System::GetFrontendAppletHolder() { |
| 879 | impl->applet_manager.SetDefaultAppletFrontendSet(); | 891 | return impl->frontend_applets; |
| 880 | } | 892 | } |
| 881 | 893 | ||
| 882 | Service::AM::Applets::AppletManager& System::GetAppletManager() { | 894 | const Service::AM::Frontend::FrontendAppletHolder& System::GetFrontendAppletHolder() const { |
| 883 | return impl->applet_manager; | 895 | return impl->frontend_applets; |
| 884 | } | 896 | } |
| 885 | 897 | ||
| 886 | const Service::AM::Applets::AppletManager& System::GetAppletManager() const { | 898 | Service::AM::AppletManager& System::GetAppletManager() { |
| 887 | return impl->applet_manager; | 899 | return impl->applet_manager; |
| 888 | } | 900 | } |
| 889 | 901 | ||