refactor(subsystems&ime): RAII lifecycle

This commit is contained in:
nmzik
2026-08-11 14:53:16 +02:00
parent 34cf130e4d
commit 4980efa9b7
43 changed files with 816 additions and 1256 deletions
+6 -4
View File
@@ -1,6 +1,7 @@
#include "common/assert.h"
#include "common/emulatorConfig.h"
#include "common/logging/log.h"
#include "common/subsystems.h"
#include "common/threads.h"
#include "gpu_test_shaders/gpu_test_ms_depth_spv.h"
#include "graphics/guest_gpu/command_processor/commandProcessor.h"
@@ -706,13 +707,14 @@ void Require(const char* shader_name, const char* stage, bool value, const std::
void EnsureConfigInitialized() {
static bool config_initialized = false;
if (!config_initialized) {
Common::ThreadsSubsystem::Instance()->Init(nullptr);
Config::ConfigSubsystem::Instance()->Init(nullptr);
static Common::Subsystems subsystems;
Common::InitializeThreads();
subsystems.Initialize<Config::Lifecycle>();
Config::ConfigOptions options;
options.printf_direction = Config::OutputDirection::Silent;
Config::Load(options);
Log::LogSubsystem::Instance()->Init(nullptr);
Libs::LibKernel::Memory::MemorySubsystem::Instance()->Init(nullptr);
subsystems.Initialize<Log::Lifecycle>();
subsystems.Initialize<Libs::LibKernel::Memory::Lifecycle>();
config_initialized = true;
}
}
+6 -20
View File
@@ -1,4 +1,3 @@
#include "common/commonSubsystem.h"
#include "common/emulatorConfig.h"
#include "common/file.h"
#include "common/logging/log.h"
@@ -97,28 +96,16 @@ void InitSubsystems() {
return;
}
static char arg0[] = "virtual_memory_allocation_tests";
static char* argv[] = {arg0};
auto* slist = Common::SubsystemsList::Instance();
auto* core = Common::CommonSubsystem::Instance();
auto* config = Config::ConfigSubsystem::Instance();
auto* log = Log::LogSubsystem::Instance();
auto* memory = Libs::LibKernel::Memory::MemorySubsystem::Instance();
auto* thread = Common::ThreadsSubsystem::Instance();
slist->SetArgs(1, argv);
slist->Add(thread, {});
slist->Add(core, {});
slist->Add(config, {core});
Check("InitSubsystems", slist->InitAll(false), "failed to initialize base subsystems");
static Common::Subsystems subsystems;
Common::VirtualMemory::Init();
Common::InitializeThreads();
subsystems.Initialize<Config::Lifecycle>();
Config::ConfigOptions options;
options.printf_direction = Config::OutputDirection::Silent;
Config::Load(options);
slist->Add(log, {core, config});
Check("InitSubsystems", slist->InitAll(false), "failed to initialize logging subsystem");
subsystems.Initialize<Log::Lifecycle>();
const auto param_json = std::filesystem::temp_directory_path() /
("kyty_virtual_memory_" +
@@ -140,8 +127,7 @@ void InitSubsystems() {
"failed to read flexible memory size from param.json");
Libs::LibKernel::Memory::SetFlexibleMemorySize(flexible_memory_size);
slist->Add(memory, {core, log, thread});
Check("InitSubsystems", slist->InitAll(false), "failed to initialize memory subsystem");
subsystems.Initialize<Libs::LibKernel::Memory::Lifecycle>();
initialized = true;
}
+5 -3
View File
@@ -1,6 +1,7 @@
#include "common/emulatorConfig.h"
#include "common/logging/log.h"
#include "common/stringUtils.h"
#include "common/subsystems.h"
#include "common/threads.h"
#include "graphics/guest_gpu/hardwareContext.h"
#include "graphics/guest_gpu/pm4.h"
@@ -344,12 +345,13 @@ void SetIdentityInterpolatorSettings(ShaderPixelInputInfo* input_info) {
void EnsureConfigInitialized() {
static bool config_initialized = false;
if (!config_initialized) {
Common::ThreadsSubsystem::Instance()->Init(nullptr);
Config::ConfigSubsystem::Instance()->Init(nullptr);
static Common::Subsystems subsystems;
Common::InitializeThreads();
subsystems.Initialize<Config::Lifecycle>();
Config::ConfigOptions options;
options.printf_direction = Config::OutputDirection::Silent;
Config::Load(options);
Log::LogSubsystem::Instance()->Init(nullptr);
subsystems.Initialize<Log::Lifecycle>();
ShaderInit();
config_initialized = true;
}