VERY experimental Nintendo Switch 2 emulator
C++
Services: Vi shouldn't be responsible for creating nvflinger.
Subv696b61b9c3da
diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cppindex 3f5ce56c60..403cce8e5b 100644--- a/src/core/hle/service/service.cpp+++ b/src/core/hle/service/service.cpp@@ -165,6 +165,10 @@ void AddNamedPort(std::string name, SharedPtr<ClientPort> port) {/// Initialize ServiceManagervoid Init() {+ // NVFlinger needs to be accessed by several services like Vi and AppletOE so we instantiate it+ // here and pass it into the respective InstallInterfaces functions.+ auto nv_flinger = std::make_shared<NVFlinger::NVFlinger>();+SM::g_service_manager = std::make_shared<SM::ServiceManager>();SM::ServiceManager::InstallInterfaces(SM::g_service_manager);@@ -180,7 +184,7 @@ void Init() {PCTL::InstallInterfaces(*SM::g_service_manager);Sockets::InstallInterfaces(*SM::g_service_manager);Time::InstallInterfaces(*SM::g_service_manager);- VI::InstallInterfaces(*SM::g_service_manager);+ VI::InstallInterfaces(*SM::g_service_manager, nv_flinger);Set::InstallInterfaces(*SM::g_service_manager);LOG_DEBUG(Service, "initialized OK");diff --git a/src/core/hle/service/vi/vi.cpp b/src/core/hle/service/vi/vi.cppindex e0bfad2909..6576f81db1 100644--- a/src/core/hle/service/vi/vi.cpp+++ b/src/core/hle/service/vi/vi.cpp@@ -753,8 +753,9 @@ IApplicationDisplayService::IApplicationDisplayService(RegisterHandlers(functions);}-void InstallInterfaces(SM::ServiceManager& service_manager) {- std::make_shared<VI_M>()->InstallAsService(service_manager);+void InstallInterfaces(SM::ServiceManager& service_manager,+ std::shared_ptr<NVFlinger::NVFlinger> nv_flinger) {+ std::make_shared<VI_M>(nv_flinger)->InstallAsService(service_manager);}} // namespace VIdiff --git a/src/core/hle/service/vi/vi.h b/src/core/hle/service/vi/vi.hindex 5e9b7e6cf2..a6e084f874 100644--- a/src/core/hle/service/vi/vi.h+++ b/src/core/hle/service/vi/vi.h@@ -39,7 +39,8 @@ private:};/// Registers all VI services with the specified service manager.-void InstallInterfaces(SM::ServiceManager& service_manager);+void InstallInterfaces(SM::ServiceManager& service_manager,+ std::shared_ptr<NVFlinger::NVFlinger> nv_flinger);} // namespace VI} // namespace Servicediff --git a/src/core/hle/service/vi/vi_m.cpp b/src/core/hle/service/vi/vi_m.cppindex 6deedf8423..20b24658e7 100644--- a/src/core/hle/service/vi/vi_m.cpp+++ b/src/core/hle/service/vi/vi_m.cpp@@ -17,13 +17,13 @@ void VI_M::GetDisplayService(Kernel::HLERequestContext& ctx) {rb.PushIpcInterface<IApplicationDisplayService>(nv_flinger);}-VI_M::VI_M() : ServiceFramework("vi:m") {+VI_M::VI_M(std::shared_ptr<NVFlinger::NVFlinger> nv_flinger)+ : ServiceFramework("vi:m"), nv_flinger(std::move(nv_flinger)) {static const FunctionInfo functions[] = {{2, &VI_M::GetDisplayService, "GetDisplayService"},{3, nullptr, "GetDisplayServiceWithProxyNameExchange"},};RegisterHandlers(functions);- nv_flinger = std::make_shared<NVFlinger::NVFlinger>();}} // namespace VIdiff --git a/src/core/hle/service/vi/vi_m.h b/src/core/hle/service/vi/vi_m.hindex ebe79d5c73..e5319b1e79 100644--- a/src/core/hle/service/vi/vi_m.h+++ b/src/core/hle/service/vi/vi_m.h@@ -16,7 +16,7 @@ namespace VI {class VI_M final : public ServiceFramework<VI_M> {public:- VI_M();+ VI_M(std::shared_ptr<NVFlinger::NVFlinger> nv_flinger);~VI_M() = default;private: