diff options
20 files changed, 134 insertions, 101 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index f598bd634..bf1268bbb 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt | |||
| @@ -798,8 +798,6 @@ add_library(core STATIC | |||
| 798 | hle/service/nvnflinger/consumer_base.cpp | 798 | hle/service/nvnflinger/consumer_base.cpp |
| 799 | hle/service/nvnflinger/consumer_base.h | 799 | hle/service/nvnflinger/consumer_base.h |
| 800 | hle/service/nvnflinger/consumer_listener.h | 800 | hle/service/nvnflinger/consumer_listener.h |
| 801 | hle/service/nvnflinger/fb_share_buffer_manager.cpp | ||
| 802 | hle/service/nvnflinger/fb_share_buffer_manager.h | ||
| 803 | hle/service/nvnflinger/graphic_buffer_producer.cpp | 801 | hle/service/nvnflinger/graphic_buffer_producer.cpp |
| 804 | hle/service/nvnflinger/graphic_buffer_producer.h | 802 | hle/service/nvnflinger/graphic_buffer_producer.h |
| 805 | hle/service/nvnflinger/hos_binder_driver_server.cpp | 803 | hle/service/nvnflinger/hos_binder_driver_server.cpp |
| @@ -963,6 +961,8 @@ add_library(core STATIC | |||
| 963 | hle/service/vi/application_display_service.h | 961 | hle/service/vi/application_display_service.h |
| 964 | hle/service/vi/application_root_service.cpp | 962 | hle/service/vi/application_root_service.cpp |
| 965 | hle/service/vi/application_root_service.h | 963 | hle/service/vi/application_root_service.h |
| 964 | hle/service/vi/fbshare_buffer_manager.cpp | ||
| 965 | hle/service/vi/fbshare_buffer_manager.h | ||
| 966 | hle/service/vi/manager_display_service.cpp | 966 | hle/service/vi/manager_display_service.cpp |
| 967 | hle/service/vi/manager_display_service.h | 967 | hle/service/vi/manager_display_service.h |
| 968 | hle/service/vi/manager_root_service.cpp | 968 | hle/service/vi/manager_root_service.cpp |
diff --git a/src/core/hle/service/am/display_layer_manager.cpp b/src/core/hle/service/am/display_layer_manager.cpp index 6cf3c369c..dc742c1f6 100644 --- a/src/core/hle/service/am/display_layer_manager.cpp +++ b/src/core/hle/service/am/display_layer_manager.cpp | |||
| @@ -3,11 +3,13 @@ | |||
| 3 | 3 | ||
| 4 | #include "core/core.h" | 4 | #include "core/core.h" |
| 5 | #include "core/hle/service/am/display_layer_manager.h" | 5 | #include "core/hle/service/am/display_layer_manager.h" |
| 6 | #include "core/hle/service/nvnflinger/fb_share_buffer_manager.h" | ||
| 7 | #include "core/hle/service/nvnflinger/hos_binder_driver.h" | 6 | #include "core/hle/service/nvnflinger/hos_binder_driver.h" |
| 8 | #include "core/hle/service/nvnflinger/nvnflinger.h" | ||
| 9 | #include "core/hle/service/sm/sm.h" | 7 | #include "core/hle/service/sm/sm.h" |
| 8 | #include "core/hle/service/vi/application_display_service.h" | ||
| 9 | #include "core/hle/service/vi/fbshare_buffer_manager.h" | ||
| 10 | #include "core/hle/service/vi/manager_root_service.h" | ||
| 10 | #include "core/hle/service/vi/vi_results.h" | 11 | #include "core/hle/service/vi/vi_results.h" |
| 12 | #include "core/hle/service/vi/vi_types.h" | ||
| 11 | 13 | ||
| 12 | namespace Service::AM { | 14 | namespace Service::AM { |
| 13 | 15 | ||
| @@ -18,10 +20,14 @@ DisplayLayerManager::~DisplayLayerManager() { | |||
| 18 | 20 | ||
| 19 | void DisplayLayerManager::Initialize(Core::System& system, Kernel::KProcess* process, | 21 | void DisplayLayerManager::Initialize(Core::System& system, Kernel::KProcess* process, |
| 20 | AppletId applet_id, LibraryAppletMode mode) { | 22 | AppletId applet_id, LibraryAppletMode mode) { |
| 21 | m_process = process; | ||
| 22 | m_surface_flinger = system.ServiceManager() | 23 | m_surface_flinger = system.ServiceManager() |
| 23 | .GetService<Nvnflinger::IHOSBinderDriver>("dispdrv", true) | 24 | .GetService<Nvnflinger::IHOSBinderDriver>("dispdrv", true) |
| 24 | ->GetSurfaceFlinger(); | 25 | ->GetSurfaceFlinger(); |
| 26 | R_ASSERT(system.ServiceManager() | ||
| 27 | .GetService<VI::IManagerRootService>("vi:m", true) | ||
| 28 | ->GetDisplayService(&m_display_service, VI::Policy::Compositor)); | ||
| 29 | |||
| 30 | m_process = process; | ||
| 25 | m_system_shared_buffer_id = 0; | 31 | m_system_shared_buffer_id = 0; |
| 26 | m_system_shared_layer_id = 0; | 32 | m_system_shared_layer_id = 0; |
| 27 | m_applet_id = applet_id; | 33 | m_applet_id = applet_id; |
| @@ -46,7 +52,7 @@ void DisplayLayerManager::Finalize() { | |||
| 46 | 52 | ||
| 47 | // Clean up shared layers. | 53 | // Clean up shared layers. |
| 48 | if (m_buffer_sharing_enabled) { | 54 | if (m_buffer_sharing_enabled) { |
| 49 | m_surface_flinger->GetSystemBufferManager().Finalize(m_process); | 55 | m_display_service->GetSharedBufferManager()->Finalize(m_process); |
| 50 | } | 56 | } |
| 51 | 57 | ||
| 52 | m_surface_flinger = nullptr; | 58 | m_surface_flinger = nullptr; |
| @@ -103,7 +109,7 @@ Result DisplayLayerManager::IsSystemBufferSharingEnabled() { | |||
| 103 | const auto blend = | 109 | const auto blend = |
| 104 | m_blending_enabled ? Nvnflinger::LayerBlending::Coverage : Nvnflinger::LayerBlending::None; | 110 | m_blending_enabled ? Nvnflinger::LayerBlending::Coverage : Nvnflinger::LayerBlending::None; |
| 105 | const auto display_id = m_surface_flinger->OpenDisplay("Default").value(); | 111 | const auto display_id = m_surface_flinger->OpenDisplay("Default").value(); |
| 106 | R_TRY(m_surface_flinger->GetSystemBufferManager().Initialize( | 112 | R_TRY(m_display_service->GetSharedBufferManager()->Initialize( |
| 107 | m_process, &m_system_shared_buffer_id, &m_system_shared_layer_id, display_id, blend)); | 113 | m_process, &m_system_shared_buffer_id, &m_system_shared_layer_id, display_id, blend)); |
| 108 | 114 | ||
| 109 | // We succeeded, so set up remaining state. | 115 | // We succeeded, so set up remaining state. |
| @@ -147,7 +153,7 @@ bool DisplayLayerManager::GetWindowVisibility() const { | |||
| 147 | Result DisplayLayerManager::WriteAppletCaptureBuffer(bool* out_was_written, | 153 | Result DisplayLayerManager::WriteAppletCaptureBuffer(bool* out_was_written, |
| 148 | s32* out_fbshare_layer_index) { | 154 | s32* out_fbshare_layer_index) { |
| 149 | R_UNLESS(m_buffer_sharing_enabled, VI::ResultPermissionDenied); | 155 | R_UNLESS(m_buffer_sharing_enabled, VI::ResultPermissionDenied); |
| 150 | R_RETURN(m_surface_flinger->GetSystemBufferManager().WriteAppletCaptureBuffer( | 156 | R_RETURN(m_display_service->GetSharedBufferManager()->WriteAppletCaptureBuffer( |
| 151 | out_was_written, out_fbshare_layer_index)); | 157 | out_was_written, out_fbshare_layer_index)); |
| 152 | } | 158 | } |
| 153 | 159 | ||
diff --git a/src/core/hle/service/am/display_layer_manager.h b/src/core/hle/service/am/display_layer_manager.h index 92ab9399f..7591b0e60 100644 --- a/src/core/hle/service/am/display_layer_manager.h +++ b/src/core/hle/service/am/display_layer_manager.h | |||
| @@ -21,6 +21,10 @@ namespace Service::Nvnflinger { | |||
| 21 | class Nvnflinger; | 21 | class Nvnflinger; |
| 22 | } | 22 | } |
| 23 | 23 | ||
| 24 | namespace Service::VI { | ||
| 25 | class IApplicationDisplayService; | ||
| 26 | } | ||
| 27 | |||
| 24 | namespace Service::AM { | 28 | namespace Service::AM { |
| 25 | 29 | ||
| 26 | class DisplayLayerManager { | 30 | class DisplayLayerManager { |
| @@ -47,6 +51,7 @@ public: | |||
| 47 | private: | 51 | private: |
| 48 | Kernel::KProcess* m_process{}; | 52 | Kernel::KProcess* m_process{}; |
| 49 | std::shared_ptr<Nvnflinger::Nvnflinger> m_surface_flinger{}; | 53 | std::shared_ptr<Nvnflinger::Nvnflinger> m_surface_flinger{}; |
| 54 | std::shared_ptr<VI::IApplicationDisplayService> m_display_service{}; | ||
| 50 | std::set<u64> m_managed_display_layers{}; | 55 | std::set<u64> m_managed_display_layers{}; |
| 51 | std::set<u64> m_managed_display_recording_layers{}; | 56 | std::set<u64> m_managed_display_recording_layers{}; |
| 52 | u64 m_system_shared_buffer_id{}; | 57 | u64 m_system_shared_buffer_id{}; |
diff --git a/src/core/hle/service/nvnflinger/nvnflinger.cpp b/src/core/hle/service/nvnflinger/nvnflinger.cpp index cd8062a2b..a20ef14af 100644 --- a/src/core/hle/service/nvnflinger/nvnflinger.cpp +++ b/src/core/hle/service/nvnflinger/nvnflinger.cpp | |||
| @@ -9,7 +9,6 @@ | |||
| 9 | #include "core/hle/service/nvdrv/devices/nvdisp_disp0.h" | 9 | #include "core/hle/service/nvdrv/devices/nvdisp_disp0.h" |
| 10 | #include "core/hle/service/nvdrv/nvdrv.h" | 10 | #include "core/hle/service/nvdrv/nvdrv.h" |
| 11 | #include "core/hle/service/nvdrv/nvdrv_interface.h" | 11 | #include "core/hle/service/nvdrv/nvdrv_interface.h" |
| 12 | #include "core/hle/service/nvnflinger/fb_share_buffer_manager.h" | ||
| 13 | #include "core/hle/service/nvnflinger/hardware_composer.h" | 12 | #include "core/hle/service/nvnflinger/hardware_composer.h" |
| 14 | #include "core/hle/service/nvnflinger/hos_binder_driver.h" | 13 | #include "core/hle/service/nvnflinger/hos_binder_driver.h" |
| 15 | #include "core/hle/service/nvnflinger/hos_binder_driver_server.h" | 14 | #include "core/hle/service/nvnflinger/hos_binder_driver_server.h" |
| @@ -311,16 +310,6 @@ s64 Nvnflinger::GetNextTicks() const { | |||
| 311 | return static_cast<s64>(speed_scale * (1000000000.f / effective_fps)); | 310 | return static_cast<s64>(speed_scale * (1000000000.f / effective_fps)); |
| 312 | } | 311 | } |
| 313 | 312 | ||
| 314 | FbShareBufferManager& Nvnflinger::GetSystemBufferManager() { | ||
| 315 | const auto lock_guard = Lock(); | ||
| 316 | |||
| 317 | if (!system_buffer_manager) { | ||
| 318 | system_buffer_manager = std::make_unique<FbShareBufferManager>(system, *this, nvdrv); | ||
| 319 | } | ||
| 320 | |||
| 321 | return *system_buffer_manager; | ||
| 322 | } | ||
| 323 | |||
| 324 | void LoopProcess(Core::System& system) { | 313 | void LoopProcess(Core::System& system) { |
| 325 | const auto binder_server = std::make_shared<HosBinderDriverServer>(system); | 314 | const auto binder_server = std::make_shared<HosBinderDriverServer>(system); |
| 326 | const auto surface_flinger = std::make_shared<Nvnflinger>(system, *binder_server); | 315 | const auto surface_flinger = std::make_shared<Nvnflinger>(system, *binder_server); |
diff --git a/src/core/hle/service/nvnflinger/nvnflinger.h b/src/core/hle/service/nvnflinger/nvnflinger.h index 5ed7dc317..941a98418 100644 --- a/src/core/hle/service/nvnflinger/nvnflinger.h +++ b/src/core/hle/service/nvnflinger/nvnflinger.h | |||
| @@ -35,6 +35,7 @@ class Module; | |||
| 35 | 35 | ||
| 36 | namespace Service::VI { | 36 | namespace Service::VI { |
| 37 | class Display; | 37 | class Display; |
| 38 | class FbshareBufferManager; | ||
| 38 | class Layer; | 39 | class Layer; |
| 39 | } // namespace Service::VI | 40 | } // namespace Service::VI |
| 40 | 41 | ||
| @@ -45,7 +46,6 @@ class BufferQueueProducer; | |||
| 45 | 46 | ||
| 46 | namespace Service::Nvnflinger { | 47 | namespace Service::Nvnflinger { |
| 47 | 48 | ||
| 48 | class FbShareBufferManager; | ||
| 49 | class HardwareComposer; | 49 | class HardwareComposer; |
| 50 | class HosBinderDriverServer; | 50 | class HosBinderDriverServer; |
| 51 | 51 | ||
| @@ -101,17 +101,9 @@ public: | |||
| 101 | 101 | ||
| 102 | [[nodiscard]] s64 GetNextTicks() const; | 102 | [[nodiscard]] s64 GetNextTicks() const; |
| 103 | 103 | ||
| 104 | FbShareBufferManager& GetSystemBufferManager(); | ||
| 105 | |||
| 106 | private: | 104 | private: |
| 107 | struct Layer { | 105 | friend class VI::FbshareBufferManager; |
| 108 | std::unique_ptr<android::BufferQueueCore> core; | ||
| 109 | std::unique_ptr<android::BufferQueueProducer> producer; | ||
| 110 | }; | ||
| 111 | |||
| 112 | friend class FbShareBufferManager; | ||
| 113 | 106 | ||
| 114 | private: | ||
| 115 | [[nodiscard]] std::unique_lock<std::mutex> Lock() const { | 107 | [[nodiscard]] std::unique_lock<std::mutex> Lock() const { |
| 116 | return std::unique_lock{*guard}; | 108 | return std::unique_lock{*guard}; |
| 117 | } | 109 | } |
| @@ -150,8 +142,6 @@ private: | |||
| 150 | std::shared_ptr<Core::Timing::EventType> multi_composition_event; | 142 | std::shared_ptr<Core::Timing::EventType> multi_composition_event; |
| 151 | std::shared_ptr<Core::Timing::EventType> single_composition_event; | 143 | std::shared_ptr<Core::Timing::EventType> single_composition_event; |
| 152 | 144 | ||
| 153 | std::unique_ptr<FbShareBufferManager> system_buffer_manager; | ||
| 154 | |||
| 155 | std::shared_ptr<std::mutex> guard; | 145 | std::shared_ptr<std::mutex> guard; |
| 156 | 146 | ||
| 157 | Core::System& system; | 147 | Core::System& system; |
diff --git a/src/core/hle/service/vi/application_display_service.cpp b/src/core/hle/service/vi/application_display_service.cpp index a6e04bf60..9c009f902 100644 --- a/src/core/hle/service/vi/application_display_service.cpp +++ b/src/core/hle/service/vi/application_display_service.cpp | |||
| @@ -13,10 +13,12 @@ | |||
| 13 | namespace Service::VI { | 13 | namespace Service::VI { |
| 14 | 14 | ||
| 15 | IApplicationDisplayService::IApplicationDisplayService( | 15 | IApplicationDisplayService::IApplicationDisplayService( |
| 16 | Core::System& system_, std::shared_ptr<Nvnflinger::IHOSBinderDriver> binder_service) | 16 | Core::System& system_, std::shared_ptr<Nvnflinger::IHOSBinderDriver> binder_service, |
| 17 | std::shared_ptr<FbshareBufferManager> shared_buffer_manager) | ||
| 17 | : ServiceFramework{system_, "IApplicationDisplayService"}, | 18 | : ServiceFramework{system_, "IApplicationDisplayService"}, |
| 18 | m_binder_service{std::move(binder_service)}, | 19 | m_binder_service{std::move(binder_service)}, |
| 19 | m_surface_flinger{m_binder_service->GetSurfaceFlinger()} { | 20 | m_surface_flinger{m_binder_service->GetSurfaceFlinger()}, |
| 21 | m_shared_buffer_manager{std::move(shared_buffer_manager)} { | ||
| 20 | 22 | ||
| 21 | // clang-format off | 23 | // clang-format off |
| 22 | static const FunctionInfo functions[] = { | 24 | static const FunctionInfo functions[] = { |
| @@ -64,7 +66,7 @@ Result IApplicationDisplayService::GetSystemDisplayService( | |||
| 64 | Out<SharedPointer<ISystemDisplayService>> out_system_display_service) { | 66 | Out<SharedPointer<ISystemDisplayService>> out_system_display_service) { |
| 65 | LOG_WARNING(Service_VI, "(STUBBED) called"); | 67 | LOG_WARNING(Service_VI, "(STUBBED) called"); |
| 66 | *out_system_display_service = | 68 | *out_system_display_service = |
| 67 | std::make_shared<ISystemDisplayService>(system, m_surface_flinger); | 69 | std::make_shared<ISystemDisplayService>(system, m_surface_flinger, m_shared_buffer_manager); |
| 68 | R_SUCCEED(); | 70 | R_SUCCEED(); |
| 69 | } | 71 | } |
| 70 | 72 | ||
diff --git a/src/core/hle/service/vi/application_display_service.h b/src/core/hle/service/vi/application_display_service.h index e56490f9f..5022b2f63 100644 --- a/src/core/hle/service/vi/application_display_service.h +++ b/src/core/hle/service/vi/application_display_service.h | |||
| @@ -16,15 +16,21 @@ class IHOSBinderDriver; | |||
| 16 | 16 | ||
| 17 | namespace Service::VI { | 17 | namespace Service::VI { |
| 18 | 18 | ||
| 19 | class FbshareBufferManager; | ||
| 19 | class IManagerDisplayService; | 20 | class IManagerDisplayService; |
| 20 | class ISystemDisplayService; | 21 | class ISystemDisplayService; |
| 21 | 22 | ||
| 22 | class IApplicationDisplayService final : public ServiceFramework<IApplicationDisplayService> { | 23 | class IApplicationDisplayService final : public ServiceFramework<IApplicationDisplayService> { |
| 23 | public: | 24 | public: |
| 24 | IApplicationDisplayService(Core::System& system_, | 25 | IApplicationDisplayService(Core::System& system_, |
| 25 | std::shared_ptr<Nvnflinger::IHOSBinderDriver> binder_service); | 26 | std::shared_ptr<Nvnflinger::IHOSBinderDriver> binder_service, |
| 27 | std::shared_ptr<FbshareBufferManager> shared_buffer_manager); | ||
| 26 | ~IApplicationDisplayService() override; | 28 | ~IApplicationDisplayService() override; |
| 27 | 29 | ||
| 30 | std::shared_ptr<FbshareBufferManager> GetSharedBufferManager() const { | ||
| 31 | return m_shared_buffer_manager; | ||
| 32 | } | ||
| 33 | |||
| 28 | private: | 34 | private: |
| 29 | Result GetRelayService(Out<SharedPointer<Nvnflinger::IHOSBinderDriver>> out_relay_service); | 35 | Result GetRelayService(Out<SharedPointer<Nvnflinger::IHOSBinderDriver>> out_relay_service); |
| 30 | Result GetSystemDisplayService( | 36 | Result GetSystemDisplayService( |
| @@ -62,6 +68,7 @@ private: | |||
| 62 | private: | 68 | private: |
| 63 | const std::shared_ptr<Nvnflinger::IHOSBinderDriver> m_binder_service; | 69 | const std::shared_ptr<Nvnflinger::IHOSBinderDriver> m_binder_service; |
| 64 | const std::shared_ptr<Nvnflinger::Nvnflinger> m_surface_flinger; | 70 | const std::shared_ptr<Nvnflinger::Nvnflinger> m_surface_flinger; |
| 71 | const std::shared_ptr<FbshareBufferManager> m_shared_buffer_manager; | ||
| 65 | std::vector<u64> m_stray_layer_ids; | 72 | std::vector<u64> m_stray_layer_ids; |
| 66 | bool m_vsync_event_fetched{false}; | 73 | bool m_vsync_event_fetched{false}; |
| 67 | }; | 74 | }; |
diff --git a/src/core/hle/service/vi/application_root_service.cpp b/src/core/hle/service/vi/application_root_service.cpp index 501fbdd6a..ed8c9b1b3 100644 --- a/src/core/hle/service/vi/application_root_service.cpp +++ b/src/core/hle/service/vi/application_root_service.cpp | |||
| @@ -11,8 +11,10 @@ | |||
| 11 | namespace Service::VI { | 11 | namespace Service::VI { |
| 12 | 12 | ||
| 13 | IApplicationRootService::IApplicationRootService( | 13 | IApplicationRootService::IApplicationRootService( |
| 14 | Core::System& system_, std::shared_ptr<Nvnflinger::IHOSBinderDriver> binder_service) | 14 | Core::System& system_, std::shared_ptr<Nvnflinger::IHOSBinderDriver> binder_service, |
| 15 | : ServiceFramework{system_, "vi:u"}, m_binder_service{std::move(binder_service)} { | 15 | std::shared_ptr<FbshareBufferManager> shared_buffer_manager) |
| 16 | : ServiceFramework{system_, "vi:u"}, m_binder_service{std::move(binder_service)}, | ||
| 17 | m_shared_buffer_manager{std::move(shared_buffer_manager)} { | ||
| 16 | static const FunctionInfo functions[] = { | 18 | static const FunctionInfo functions[] = { |
| 17 | {0, C<&IApplicationRootService::GetDisplayService>, "GetDisplayService"}, | 19 | {0, C<&IApplicationRootService::GetDisplayService>, "GetDisplayService"}, |
| 18 | {1, nullptr, "GetDisplayServiceWithProxyNameExchange"}, | 20 | {1, nullptr, "GetDisplayServiceWithProxyNameExchange"}, |
| @@ -26,7 +28,7 @@ Result IApplicationRootService::GetDisplayService( | |||
| 26 | Out<SharedPointer<IApplicationDisplayService>> out_application_display_service, Policy policy) { | 28 | Out<SharedPointer<IApplicationDisplayService>> out_application_display_service, Policy policy) { |
| 27 | LOG_DEBUG(Service_VI, "called"); | 29 | LOG_DEBUG(Service_VI, "called"); |
| 28 | R_RETURN(GetApplicationDisplayService(out_application_display_service, system, m_binder_service, | 30 | R_RETURN(GetApplicationDisplayService(out_application_display_service, system, m_binder_service, |
| 29 | Permission::User, policy)); | 31 | m_shared_buffer_manager, Permission::User, policy)); |
| 30 | } | 32 | } |
| 31 | 33 | ||
| 32 | } // namespace Service::VI | 34 | } // namespace Service::VI |
diff --git a/src/core/hle/service/vi/application_root_service.h b/src/core/hle/service/vi/application_root_service.h index d1f023e9e..5970b6e68 100644 --- a/src/core/hle/service/vi/application_root_service.h +++ b/src/core/hle/service/vi/application_root_service.h | |||
| @@ -16,13 +16,15 @@ class IHOSBinderDriver; | |||
| 16 | 16 | ||
| 17 | namespace Service::VI { | 17 | namespace Service::VI { |
| 18 | 18 | ||
| 19 | class FbshareBufferManager; | ||
| 19 | class IApplicationDisplayService; | 20 | class IApplicationDisplayService; |
| 20 | enum class Policy : u32; | 21 | enum class Policy : u32; |
| 21 | 22 | ||
| 22 | class IApplicationRootService final : public ServiceFramework<IApplicationRootService> { | 23 | class IApplicationRootService final : public ServiceFramework<IApplicationRootService> { |
| 23 | public: | 24 | public: |
| 24 | explicit IApplicationRootService(Core::System& system_, | 25 | explicit IApplicationRootService(Core::System& system_, |
| 25 | std::shared_ptr<Nvnflinger::IHOSBinderDriver> binder_service); | 26 | std::shared_ptr<Nvnflinger::IHOSBinderDriver> binder_service, |
| 27 | std::shared_ptr<FbshareBufferManager> shared_buffer_manager); | ||
| 26 | ~IApplicationRootService() override; | 28 | ~IApplicationRootService() override; |
| 27 | 29 | ||
| 28 | private: | 30 | private: |
| @@ -32,6 +34,7 @@ private: | |||
| 32 | 34 | ||
| 33 | private: | 35 | private: |
| 34 | const std::shared_ptr<Nvnflinger::IHOSBinderDriver> m_binder_service; | 36 | const std::shared_ptr<Nvnflinger::IHOSBinderDriver> m_binder_service; |
| 37 | const std::shared_ptr<FbshareBufferManager> m_shared_buffer_manager; | ||
| 35 | }; | 38 | }; |
| 36 | 39 | ||
| 37 | } // namespace Service::VI | 40 | } // namespace Service::VI |
diff --git a/src/core/hle/service/nvnflinger/fb_share_buffer_manager.cpp b/src/core/hle/service/vi/fbshare_buffer_manager.cpp index 90f7248a0..e61c02e1c 100644 --- a/src/core/hle/service/nvnflinger/fb_share_buffer_manager.cpp +++ b/src/core/hle/service/vi/fbshare_buffer_manager.cpp | |||
| @@ -9,15 +9,15 @@ | |||
| 9 | #include "core/hle/service/nvdrv/devices/nvmap.h" | 9 | #include "core/hle/service/nvdrv/devices/nvmap.h" |
| 10 | #include "core/hle/service/nvdrv/nvdrv.h" | 10 | #include "core/hle/service/nvdrv/nvdrv.h" |
| 11 | #include "core/hle/service/nvnflinger/buffer_queue_producer.h" | 11 | #include "core/hle/service/nvnflinger/buffer_queue_producer.h" |
| 12 | #include "core/hle/service/nvnflinger/fb_share_buffer_manager.h" | ||
| 13 | #include "core/hle/service/nvnflinger/pixel_format.h" | 12 | #include "core/hle/service/nvnflinger/pixel_format.h" |
| 14 | #include "core/hle/service/nvnflinger/ui/graphic_buffer.h" | 13 | #include "core/hle/service/nvnflinger/ui/graphic_buffer.h" |
| 14 | #include "core/hle/service/vi/fbshare_buffer_manager.h" | ||
| 15 | #include "core/hle/service/vi/layer/vi_layer.h" | 15 | #include "core/hle/service/vi/layer/vi_layer.h" |
| 16 | #include "core/hle/service/vi/vi_results.h" | 16 | #include "core/hle/service/vi/vi_results.h" |
| 17 | #include "video_core/gpu.h" | 17 | #include "video_core/gpu.h" |
| 18 | #include "video_core/host1x/host1x.h" | 18 | #include "video_core/host1x/host1x.h" |
| 19 | 19 | ||
| 20 | namespace Service::Nvnflinger { | 20 | namespace Service::VI { |
| 21 | 21 | ||
| 22 | namespace { | 22 | namespace { |
| 23 | 23 | ||
| @@ -26,7 +26,6 @@ Result AllocateSharedBufferMemory(std::unique_ptr<Kernel::KPageGroup>* out_page_ | |||
| 26 | using Core::Memory::YUZU_PAGESIZE; | 26 | using Core::Memory::YUZU_PAGESIZE; |
| 27 | 27 | ||
| 28 | // Allocate memory for the system shared buffer. | 28 | // Allocate memory for the system shared buffer. |
| 29 | // FIXME: This memory belongs to vi's .data section. | ||
| 30 | auto& kernel = system.Kernel(); | 29 | auto& kernel = system.Kernel(); |
| 31 | 30 | ||
| 32 | // Hold a temporary page group reference while we try to map it. | 31 | // Hold a temporary page group reference while we try to map it. |
| @@ -204,15 +203,16 @@ void MakeGraphicBuffer(android::BufferQueueProducer& producer, u32 slot, u32 han | |||
| 204 | 203 | ||
| 205 | } // namespace | 204 | } // namespace |
| 206 | 205 | ||
| 207 | FbShareBufferManager::FbShareBufferManager(Core::System& system, Nvnflinger& flinger, | 206 | FbshareBufferManager::FbshareBufferManager(Core::System& system, |
| 207 | std::shared_ptr<Nvnflinger::Nvnflinger> surface_flinger, | ||
| 208 | std::shared_ptr<Nvidia::Module> nvdrv) | 208 | std::shared_ptr<Nvidia::Module> nvdrv) |
| 209 | : m_system(system), m_flinger(flinger), m_nvdrv(std::move(nvdrv)) {} | 209 | : m_system(system), m_surface_flinger(std::move(surface_flinger)), m_nvdrv(std::move(nvdrv)) {} |
| 210 | 210 | ||
| 211 | FbShareBufferManager::~FbShareBufferManager() = default; | 211 | FbshareBufferManager::~FbshareBufferManager() = default; |
| 212 | 212 | ||
| 213 | Result FbShareBufferManager::Initialize(Kernel::KProcess* owner_process, u64* out_buffer_id, | 213 | Result FbshareBufferManager::Initialize(Kernel::KProcess* owner_process, u64* out_buffer_id, |
| 214 | u64* out_layer_handle, u64 display_id, | 214 | u64* out_layer_handle, u64 display_id, |
| 215 | LayerBlending blending) { | 215 | Nvnflinger::LayerBlending blending) { |
| 216 | std::scoped_lock lk{m_guard}; | 216 | std::scoped_lock lk{m_guard}; |
| 217 | 217 | ||
| 218 | // Ensure we haven't already created. | 218 | // Ensure we haven't already created. |
| @@ -237,7 +237,7 @@ Result FbShareBufferManager::Initialize(Kernel::KProcess* owner_process, u64* ou | |||
| 237 | owner_process, m_system)); | 237 | owner_process, m_system)); |
| 238 | 238 | ||
| 239 | // Create new session. | 239 | // Create new session. |
| 240 | auto [it, was_emplaced] = m_sessions.emplace(aruid, FbShareSession{}); | 240 | auto [it, was_emplaced] = m_sessions.emplace(aruid, FbshareSession{}); |
| 241 | auto& session = it->second; | 241 | auto& session = it->second; |
| 242 | 242 | ||
| 243 | auto& container = m_nvdrv->GetContainer(); | 243 | auto& container = m_nvdrv->GetContainer(); |
| @@ -249,11 +249,11 @@ Result FbShareBufferManager::Initialize(Kernel::KProcess* owner_process, u64* ou | |||
| 249 | session.nvmap_fd, map_address, SharedBufferSize)); | 249 | session.nvmap_fd, map_address, SharedBufferSize)); |
| 250 | 250 | ||
| 251 | // Create and open a layer for the display. | 251 | // Create and open a layer for the display. |
| 252 | session.layer_id = m_flinger.CreateLayer(m_display_id, blending).value(); | 252 | session.layer_id = m_surface_flinger->CreateLayer(m_display_id, blending).value(); |
| 253 | m_flinger.OpenLayer(session.layer_id); | 253 | m_surface_flinger->OpenLayer(session.layer_id); |
| 254 | 254 | ||
| 255 | // Get the layer. | 255 | // Get the layer. |
| 256 | VI::Layer* layer = m_flinger.FindLayer(m_display_id, session.layer_id); | 256 | VI::Layer* layer = m_surface_flinger->FindLayer(m_display_id, session.layer_id); |
| 257 | ASSERT(layer != nullptr); | 257 | ASSERT(layer != nullptr); |
| 258 | 258 | ||
| 259 | // Get the producer and set preallocated buffers. | 259 | // Get the producer and set preallocated buffers. |
| @@ -269,7 +269,7 @@ Result FbShareBufferManager::Initialize(Kernel::KProcess* owner_process, u64* ou | |||
| 269 | R_SUCCEED(); | 269 | R_SUCCEED(); |
| 270 | } | 270 | } |
| 271 | 271 | ||
| 272 | void FbShareBufferManager::Finalize(Kernel::KProcess* owner_process) { | 272 | void FbshareBufferManager::Finalize(Kernel::KProcess* owner_process) { |
| 273 | std::scoped_lock lk{m_guard}; | 273 | std::scoped_lock lk{m_guard}; |
| 274 | 274 | ||
| 275 | if (m_buffer_id == 0) { | 275 | if (m_buffer_id == 0) { |
| @@ -285,7 +285,7 @@ void FbShareBufferManager::Finalize(Kernel::KProcess* owner_process) { | |||
| 285 | auto& session = it->second; | 285 | auto& session = it->second; |
| 286 | 286 | ||
| 287 | // Destroy the layer. | 287 | // Destroy the layer. |
| 288 | m_flinger.DestroyLayer(session.layer_id); | 288 | m_surface_flinger->DestroyLayer(session.layer_id); |
| 289 | 289 | ||
| 290 | // Close nvmap handle. | 290 | // Close nvmap handle. |
| 291 | FreeHandle(session.buffer_nvmap_handle, *m_nvdrv, session.nvmap_fd); | 291 | FreeHandle(session.buffer_nvmap_handle, *m_nvdrv, session.nvmap_fd); |
| @@ -301,7 +301,7 @@ void FbShareBufferManager::Finalize(Kernel::KProcess* owner_process) { | |||
| 301 | m_sessions.erase(it); | 301 | m_sessions.erase(it); |
| 302 | } | 302 | } |
| 303 | 303 | ||
| 304 | Result FbShareBufferManager::GetSharedBufferMemoryHandleId(u64* out_buffer_size, | 304 | Result FbshareBufferManager::GetSharedBufferMemoryHandleId(u64* out_buffer_size, |
| 305 | s32* out_nvmap_handle, | 305 | s32* out_nvmap_handle, |
| 306 | SharedMemoryPoolLayout* out_pool_layout, | 306 | SharedMemoryPoolLayout* out_pool_layout, |
| 307 | u64 buffer_id, | 307 | u64 buffer_id, |
| @@ -319,12 +319,12 @@ Result FbShareBufferManager::GetSharedBufferMemoryHandleId(u64* out_buffer_size, | |||
| 319 | R_SUCCEED(); | 319 | R_SUCCEED(); |
| 320 | } | 320 | } |
| 321 | 321 | ||
| 322 | Result FbShareBufferManager::GetLayerFromId(VI::Layer** out_layer, u64 layer_id) { | 322 | Result FbshareBufferManager::GetLayerFromId(VI::Layer** out_layer, u64 layer_id) { |
| 323 | // Ensure the layer id is valid. | 323 | // Ensure the layer id is valid. |
| 324 | R_UNLESS(layer_id > 0, VI::ResultNotFound); | 324 | R_UNLESS(layer_id > 0, VI::ResultNotFound); |
| 325 | 325 | ||
| 326 | // Get the layer. | 326 | // Get the layer. |
| 327 | VI::Layer* layer = m_flinger.FindLayer(m_display_id, layer_id); | 327 | VI::Layer* layer = m_surface_flinger->FindLayer(m_display_id, layer_id); |
| 328 | R_UNLESS(layer != nullptr, VI::ResultNotFound); | 328 | R_UNLESS(layer != nullptr, VI::ResultNotFound); |
| 329 | 329 | ||
| 330 | // We succeeded. | 330 | // We succeeded. |
| @@ -332,7 +332,7 @@ Result FbShareBufferManager::GetLayerFromId(VI::Layer** out_layer, u64 layer_id) | |||
| 332 | R_SUCCEED(); | 332 | R_SUCCEED(); |
| 333 | } | 333 | } |
| 334 | 334 | ||
| 335 | Result FbShareBufferManager::AcquireSharedFrameBuffer(android::Fence* out_fence, | 335 | Result FbshareBufferManager::AcquireSharedFrameBuffer(android::Fence* out_fence, |
| 336 | std::array<s32, 4>& out_slot_indexes, | 336 | std::array<s32, 4>& out_slot_indexes, |
| 337 | s64* out_target_slot, u64 layer_id) { | 337 | s64* out_target_slot, u64 layer_id) { |
| 338 | std::scoped_lock lk{m_guard}; | 338 | std::scoped_lock lk{m_guard}; |
| @@ -359,7 +359,7 @@ Result FbShareBufferManager::AcquireSharedFrameBuffer(android::Fence* out_fence, | |||
| 359 | R_SUCCEED(); | 359 | R_SUCCEED(); |
| 360 | } | 360 | } |
| 361 | 361 | ||
| 362 | Result FbShareBufferManager::PresentSharedFrameBuffer(android::Fence fence, | 362 | Result FbshareBufferManager::PresentSharedFrameBuffer(android::Fence fence, |
| 363 | Common::Rectangle<s32> crop_region, | 363 | Common::Rectangle<s32> crop_region, |
| 364 | u32 transform, s32 swap_interval, | 364 | u32 transform, s32 swap_interval, |
| 365 | u64 layer_id, s64 slot) { | 365 | u64 layer_id, s64 slot) { |
| @@ -397,7 +397,7 @@ Result FbShareBufferManager::PresentSharedFrameBuffer(android::Fence fence, | |||
| 397 | R_SUCCEED(); | 397 | R_SUCCEED(); |
| 398 | } | 398 | } |
| 399 | 399 | ||
| 400 | Result FbShareBufferManager::GetSharedFrameBufferAcquirableEvent(Kernel::KReadableEvent** out_event, | 400 | Result FbshareBufferManager::GetSharedFrameBufferAcquirableEvent(Kernel::KReadableEvent** out_event, |
| 401 | u64 layer_id) { | 401 | u64 layer_id) { |
| 402 | std::scoped_lock lk{m_guard}; | 402 | std::scoped_lock lk{m_guard}; |
| 403 | 403 | ||
| @@ -415,7 +415,7 @@ Result FbShareBufferManager::GetSharedFrameBufferAcquirableEvent(Kernel::KReadab | |||
| 415 | R_SUCCEED(); | 415 | R_SUCCEED(); |
| 416 | } | 416 | } |
| 417 | 417 | ||
| 418 | Result FbShareBufferManager::WriteAppletCaptureBuffer(bool* out_was_written, s32* out_layer_index) { | 418 | Result FbshareBufferManager::WriteAppletCaptureBuffer(bool* out_was_written, s32* out_layer_index) { |
| 419 | std::vector<u8> capture_buffer(m_system.GPU().GetAppletCaptureBuffer()); | 419 | std::vector<u8> capture_buffer(m_system.GPU().GetAppletCaptureBuffer()); |
| 420 | Common::ScratchBuffer<u32> scratch; | 420 | Common::ScratchBuffer<u32> scratch; |
| 421 | 421 | ||
| @@ -444,4 +444,4 @@ Result FbShareBufferManager::WriteAppletCaptureBuffer(bool* out_was_written, s32 | |||
| 444 | R_SUCCEED(); | 444 | R_SUCCEED(); |
| 445 | } | 445 | } |
| 446 | 446 | ||
| 447 | } // namespace Service::Nvnflinger | 447 | } // namespace Service::VI |
diff --git a/src/core/hle/service/nvnflinger/fb_share_buffer_manager.h b/src/core/hle/service/vi/fbshare_buffer_manager.h index b79a7d23a..b9e99e61f 100644 --- a/src/core/hle/service/nvnflinger/fb_share_buffer_manager.h +++ b/src/core/hle/service/vi/fbshare_buffer_manager.h | |||
| @@ -16,7 +16,7 @@ namespace Kernel { | |||
| 16 | class KPageGroup; | 16 | class KPageGroup; |
| 17 | } | 17 | } |
| 18 | 18 | ||
| 19 | namespace Service::Nvnflinger { | 19 | namespace Service::VI { |
| 20 | 20 | ||
| 21 | struct SharedMemorySlot { | 21 | struct SharedMemorySlot { |
| 22 | u64 buffer_offset; | 22 | u64 buffer_offset; |
| @@ -32,16 +32,17 @@ struct SharedMemoryPoolLayout { | |||
| 32 | }; | 32 | }; |
| 33 | static_assert(sizeof(SharedMemoryPoolLayout) == 0x188, "SharedMemoryPoolLayout has wrong size"); | 33 | static_assert(sizeof(SharedMemoryPoolLayout) == 0x188, "SharedMemoryPoolLayout has wrong size"); |
| 34 | 34 | ||
| 35 | struct FbShareSession; | 35 | struct FbshareSession; |
| 36 | 36 | ||
| 37 | class FbShareBufferManager final { | 37 | class FbshareBufferManager final { |
| 38 | public: | 38 | public: |
| 39 | explicit FbShareBufferManager(Core::System& system, Nvnflinger& flinger, | 39 | explicit FbshareBufferManager(Core::System& system, |
| 40 | std::shared_ptr<Nvnflinger::Nvnflinger> surface_flinger, | ||
| 40 | std::shared_ptr<Nvidia::Module> nvdrv); | 41 | std::shared_ptr<Nvidia::Module> nvdrv); |
| 41 | ~FbShareBufferManager(); | 42 | ~FbshareBufferManager(); |
| 42 | 43 | ||
| 43 | Result Initialize(Kernel::KProcess* owner_process, u64* out_buffer_id, u64* out_layer_handle, | 44 | Result Initialize(Kernel::KProcess* owner_process, u64* out_buffer_id, u64* out_layer_handle, |
| 44 | u64 display_id, LayerBlending blending); | 45 | u64 display_id, Nvnflinger::LayerBlending blending); |
| 45 | void Finalize(Kernel::KProcess* owner_process); | 46 | void Finalize(Kernel::KProcess* owner_process); |
| 46 | 47 | ||
| 47 | Result GetSharedBufferMemoryHandleId(u64* out_buffer_size, s32* out_nvmap_handle, | 48 | Result GetSharedBufferMemoryHandleId(u64* out_buffer_size, s32* out_nvmap_handle, |
| @@ -63,20 +64,20 @@ private: | |||
| 63 | u64 m_display_id = 0; | 64 | u64 m_display_id = 0; |
| 64 | u64 m_buffer_id = 0; | 65 | u64 m_buffer_id = 0; |
| 65 | SharedMemoryPoolLayout m_pool_layout = {}; | 66 | SharedMemoryPoolLayout m_pool_layout = {}; |
| 66 | std::map<u64, FbShareSession> m_sessions; | 67 | std::map<u64, FbshareSession> m_sessions; |
| 67 | std::unique_ptr<Kernel::KPageGroup> m_buffer_page_group; | 68 | std::unique_ptr<Kernel::KPageGroup> m_buffer_page_group; |
| 68 | 69 | ||
| 69 | std::mutex m_guard; | 70 | std::mutex m_guard; |
| 70 | Core::System& m_system; | 71 | Core::System& m_system; |
| 71 | Nvnflinger& m_flinger; | 72 | const std::shared_ptr<Nvnflinger::Nvnflinger> m_surface_flinger; |
| 72 | std::shared_ptr<Nvidia::Module> m_nvdrv; | 73 | const std::shared_ptr<Nvidia::Module> m_nvdrv; |
| 73 | }; | 74 | }; |
| 74 | 75 | ||
| 75 | struct FbShareSession { | 76 | struct FbshareSession { |
| 76 | Nvidia::DeviceFD nvmap_fd = {}; | 77 | Nvidia::DeviceFD nvmap_fd = {}; |
| 77 | Nvidia::NvCore::SessionId session_id = {}; | 78 | Nvidia::NvCore::SessionId session_id = {}; |
| 78 | u64 layer_id = {}; | 79 | u64 layer_id = {}; |
| 79 | u32 buffer_nvmap_handle = 0; | 80 | u32 buffer_nvmap_handle = 0; |
| 80 | }; | 81 | }; |
| 81 | 82 | ||
| 82 | } // namespace Service::Nvnflinger | 83 | } // namespace Service::VI |
diff --git a/src/core/hle/service/vi/manager_root_service.cpp b/src/core/hle/service/vi/manager_root_service.cpp index 36b84909a..b61f0ecb6 100644 --- a/src/core/hle/service/vi/manager_root_service.cpp +++ b/src/core/hle/service/vi/manager_root_service.cpp | |||
| @@ -2,6 +2,7 @@ | |||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | 3 | ||
| 4 | #include "core/hle/service/cmif_serialization.h" | 4 | #include "core/hle/service/cmif_serialization.h" |
| 5 | #include "core/hle/service/nvnflinger/hos_binder_driver.h" | ||
| 5 | #include "core/hle/service/vi/application_display_service.h" | 6 | #include "core/hle/service/vi/application_display_service.h" |
| 6 | #include "core/hle/service/vi/manager_root_service.h" | 7 | #include "core/hle/service/vi/manager_root_service.h" |
| 7 | #include "core/hle/service/vi/service_creator.h" | 8 | #include "core/hle/service/vi/service_creator.h" |
| @@ -11,8 +12,10 @@ | |||
| 11 | namespace Service::VI { | 12 | namespace Service::VI { |
| 12 | 13 | ||
| 13 | IManagerRootService::IManagerRootService( | 14 | IManagerRootService::IManagerRootService( |
| 14 | Core::System& system_, std::shared_ptr<Nvnflinger::IHOSBinderDriver> binder_service) | 15 | Core::System& system_, std::shared_ptr<Nvnflinger::IHOSBinderDriver> binder_service, |
| 15 | : ServiceFramework{system_, "vi:m"}, m_binder_service{std::move(binder_service)} { | 16 | std::shared_ptr<FbshareBufferManager> shared_buffer_manager) |
| 17 | : ServiceFramework{system_, "vi:m"}, m_binder_service{std::move(binder_service)}, | ||
| 18 | m_shared_buffer_manager{std::move(shared_buffer_manager)} { | ||
| 16 | static const FunctionInfo functions[] = { | 19 | static const FunctionInfo functions[] = { |
| 17 | {2, C<&IManagerRootService::GetDisplayService>, "GetDisplayService"}, | 20 | {2, C<&IManagerRootService::GetDisplayService>, "GetDisplayService"}, |
| 18 | {3, nullptr, "GetDisplayServiceWithProxyNameExchange"}, | 21 | {3, nullptr, "GetDisplayServiceWithProxyNameExchange"}, |
| @@ -30,7 +33,7 @@ Result IManagerRootService::GetDisplayService( | |||
| 30 | Out<SharedPointer<IApplicationDisplayService>> out_application_display_service, Policy policy) { | 33 | Out<SharedPointer<IApplicationDisplayService>> out_application_display_service, Policy policy) { |
| 31 | LOG_DEBUG(Service_VI, "called"); | 34 | LOG_DEBUG(Service_VI, "called"); |
| 32 | R_RETURN(GetApplicationDisplayService(out_application_display_service, system, m_binder_service, | 35 | R_RETURN(GetApplicationDisplayService(out_application_display_service, system, m_binder_service, |
| 33 | Permission::Manager, policy)); | 36 | m_shared_buffer_manager, Permission::Manager, policy)); |
| 34 | } | 37 | } |
| 35 | 38 | ||
| 36 | } // namespace Service::VI | 39 | } // namespace Service::VI |
diff --git a/src/core/hle/service/vi/manager_root_service.h b/src/core/hle/service/vi/manager_root_service.h index 26aa95a88..509445b7b 100644 --- a/src/core/hle/service/vi/manager_root_service.h +++ b/src/core/hle/service/vi/manager_root_service.h | |||
| @@ -16,21 +16,24 @@ class IHOSBinderDriver; | |||
| 16 | 16 | ||
| 17 | namespace Service::VI { | 17 | namespace Service::VI { |
| 18 | 18 | ||
| 19 | class FbshareBufferManager; | ||
| 19 | class IApplicationDisplayService; | 20 | class IApplicationDisplayService; |
| 20 | enum class Policy : u32; | 21 | enum class Policy : u32; |
| 21 | 22 | ||
| 22 | class IManagerRootService final : public ServiceFramework<IManagerRootService> { | 23 | class IManagerRootService final : public ServiceFramework<IManagerRootService> { |
| 23 | public: | 24 | public: |
| 24 | explicit IManagerRootService(Core::System& system_, | 25 | explicit IManagerRootService(Core::System& system_, |
| 25 | std::shared_ptr<Nvnflinger::IHOSBinderDriver> binder_service); | 26 | std::shared_ptr<Nvnflinger::IHOSBinderDriver> binder_service, |
| 27 | std::shared_ptr<FbshareBufferManager> shared_buffer_manager); | ||
| 26 | ~IManagerRootService() override; | 28 | ~IManagerRootService() override; |
| 27 | 29 | ||
| 28 | private: | ||
| 29 | Result GetDisplayService( | 30 | Result GetDisplayService( |
| 30 | Out<SharedPointer<IApplicationDisplayService>> out_application_display_service, | 31 | Out<SharedPointer<IApplicationDisplayService>> out_application_display_service, |
| 31 | Policy policy); | 32 | Policy policy); |
| 32 | 33 | ||
| 34 | private: | ||
| 33 | const std::shared_ptr<Nvnflinger::IHOSBinderDriver> m_binder_service; | 35 | const std::shared_ptr<Nvnflinger::IHOSBinderDriver> m_binder_service; |
| 36 | const std::shared_ptr<FbshareBufferManager> m_shared_buffer_manager; | ||
| 34 | }; | 37 | }; |
| 35 | 38 | ||
| 36 | } // namespace Service::VI | 39 | } // namespace Service::VI |
diff --git a/src/core/hle/service/vi/service_creator.cpp b/src/core/hle/service/vi/service_creator.cpp index 594e57398..414bd6655 100644 --- a/src/core/hle/service/vi/service_creator.cpp +++ b/src/core/hle/service/vi/service_creator.cpp | |||
| @@ -23,7 +23,8 @@ static bool IsValidServiceAccess(Permission permission, Policy policy) { | |||
| 23 | Result GetApplicationDisplayService( | 23 | Result GetApplicationDisplayService( |
| 24 | std::shared_ptr<IApplicationDisplayService>* out_application_display_service, | 24 | std::shared_ptr<IApplicationDisplayService>* out_application_display_service, |
| 25 | Core::System& system, std::shared_ptr<Nvnflinger::IHOSBinderDriver> binder_service, | 25 | Core::System& system, std::shared_ptr<Nvnflinger::IHOSBinderDriver> binder_service, |
| 26 | Permission permission, Policy policy) { | 26 | std::shared_ptr<FbshareBufferManager> shared_buffer_manager, Permission permission, |
| 27 | Policy policy) { | ||
| 27 | 28 | ||
| 28 | if (!IsValidServiceAccess(permission, policy)) { | 29 | if (!IsValidServiceAccess(permission, policy)) { |
| 29 | LOG_ERROR(Service_VI, "Permission denied for policy {}", policy); | 30 | LOG_ERROR(Service_VI, "Permission denied for policy {}", policy); |
| @@ -31,7 +32,7 @@ Result GetApplicationDisplayService( | |||
| 31 | } | 32 | } |
| 32 | 33 | ||
| 33 | *out_application_display_service = | 34 | *out_application_display_service = |
| 34 | std::make_shared<IApplicationDisplayService>(system, binder_service); | 35 | std::make_shared<IApplicationDisplayService>(system, binder_service, shared_buffer_manager); |
| 35 | R_SUCCEED(); | 36 | R_SUCCEED(); |
| 36 | } | 37 | } |
| 37 | 38 | ||
diff --git a/src/core/hle/service/vi/service_creator.h b/src/core/hle/service/vi/service_creator.h index bdfac8a08..6691f25c0 100644 --- a/src/core/hle/service/vi/service_creator.h +++ b/src/core/hle/service/vi/service_creator.h | |||
| @@ -19,6 +19,7 @@ union Result; | |||
| 19 | 19 | ||
| 20 | namespace Service::VI { | 20 | namespace Service::VI { |
| 21 | 21 | ||
| 22 | class FbshareBufferManager; | ||
| 22 | class IApplicationDisplayService; | 23 | class IApplicationDisplayService; |
| 23 | enum class Permission; | 24 | enum class Permission; |
| 24 | enum class Policy : u32; | 25 | enum class Policy : u32; |
| @@ -26,6 +27,7 @@ enum class Policy : u32; | |||
| 26 | Result GetApplicationDisplayService( | 27 | Result GetApplicationDisplayService( |
| 27 | std::shared_ptr<IApplicationDisplayService>* out_application_display_service, | 28 | std::shared_ptr<IApplicationDisplayService>* out_application_display_service, |
| 28 | Core::System& system, std::shared_ptr<Nvnflinger::IHOSBinderDriver> binder_service, | 29 | Core::System& system, std::shared_ptr<Nvnflinger::IHOSBinderDriver> binder_service, |
| 29 | Permission permission, Policy policy); | 30 | std::shared_ptr<FbshareBufferManager> shared_buffer_manager, Permission permission, |
| 31 | Policy policy); | ||
| 30 | 32 | ||
| 31 | } // namespace Service::VI | 33 | } // namespace Service::VI |
diff --git a/src/core/hle/service/vi/system_display_service.cpp b/src/core/hle/service/vi/system_display_service.cpp index 8d6c3f04c..4670cf4cc 100644 --- a/src/core/hle/service/vi/system_display_service.cpp +++ b/src/core/hle/service/vi/system_display_service.cpp | |||
| @@ -3,16 +3,17 @@ | |||
| 3 | 3 | ||
| 4 | #include "common/settings.h" | 4 | #include "common/settings.h" |
| 5 | #include "core/hle/service/cmif_serialization.h" | 5 | #include "core/hle/service/cmif_serialization.h" |
| 6 | #include "core/hle/service/nvnflinger/fb_share_buffer_manager.h" | ||
| 7 | #include "core/hle/service/vi/system_display_service.h" | 6 | #include "core/hle/service/vi/system_display_service.h" |
| 8 | #include "core/hle/service/vi/vi_types.h" | 7 | #include "core/hle/service/vi/vi_types.h" |
| 9 | 8 | ||
| 10 | namespace Service::VI { | 9 | namespace Service::VI { |
| 11 | 10 | ||
| 12 | ISystemDisplayService::ISystemDisplayService( | 11 | ISystemDisplayService::ISystemDisplayService( |
| 13 | Core::System& system_, std::shared_ptr<Nvnflinger::Nvnflinger> surface_flinger) | 12 | Core::System& system_, std::shared_ptr<Nvnflinger::Nvnflinger> surface_flinger, |
| 13 | std::shared_ptr<FbshareBufferManager> shared_buffer_manager) | ||
| 14 | : ServiceFramework{system_, "ISystemDisplayService"}, | 14 | : ServiceFramework{system_, "ISystemDisplayService"}, |
| 15 | m_surface_flinger{std::move(surface_flinger)} { | 15 | m_surface_flinger{std::move(surface_flinger)}, |
| 16 | m_shared_buffer_manager{std::move(shared_buffer_manager)} { | ||
| 16 | // clang-format off | 17 | // clang-format off |
| 17 | static const FunctionInfo functions[] = { | 18 | static const FunctionInfo functions[] = { |
| 18 | {1200, nullptr, "GetZOrderCountMin"}, | 19 | {1200, nullptr, "GetZOrderCountMin"}, |
| @@ -101,11 +102,11 @@ Result ISystemDisplayService::GetDisplayMode(Out<u32> out_width, Out<u32> out_he | |||
| 101 | 102 | ||
| 102 | Result ISystemDisplayService::GetSharedBufferMemoryHandleId( | 103 | Result ISystemDisplayService::GetSharedBufferMemoryHandleId( |
| 103 | Out<s32> out_nvmap_handle, Out<u64> out_size, | 104 | Out<s32> out_nvmap_handle, Out<u64> out_size, |
| 104 | OutLargeData<Nvnflinger::SharedMemoryPoolLayout, BufferAttr_HipcMapAlias> out_pool_layout, | 105 | OutLargeData<SharedMemoryPoolLayout, BufferAttr_HipcMapAlias> out_pool_layout, u64 buffer_id, |
| 105 | u64 buffer_id, ClientAppletResourceUserId aruid) { | 106 | ClientAppletResourceUserId aruid) { |
| 106 | LOG_INFO(Service_VI, "called. buffer_id={}, aruid={:#x}", buffer_id, aruid.pid); | 107 | LOG_INFO(Service_VI, "called. buffer_id={}, aruid={:#x}", buffer_id, aruid.pid); |
| 107 | 108 | ||
| 108 | R_RETURN(m_surface_flinger->GetSystemBufferManager().GetSharedBufferMemoryHandleId( | 109 | R_RETURN(m_shared_buffer_manager->GetSharedBufferMemoryHandleId( |
| 109 | out_size, out_nvmap_handle, out_pool_layout, buffer_id, aruid.pid)); | 110 | out_size, out_nvmap_handle, out_pool_layout, buffer_id, aruid.pid)); |
| 110 | } | 111 | } |
| 111 | 112 | ||
| @@ -123,8 +124,8 @@ Result ISystemDisplayService::AcquireSharedFrameBuffer(Out<android::Fence> out_f | |||
| 123 | Out<std::array<s32, 4>> out_slots, | 124 | Out<std::array<s32, 4>> out_slots, |
| 124 | Out<s64> out_target_slot, u64 layer_id) { | 125 | Out<s64> out_target_slot, u64 layer_id) { |
| 125 | LOG_DEBUG(Service_VI, "called"); | 126 | LOG_DEBUG(Service_VI, "called"); |
| 126 | R_RETURN(m_surface_flinger->GetSystemBufferManager().AcquireSharedFrameBuffer( | 127 | R_RETURN(m_shared_buffer_manager->AcquireSharedFrameBuffer(out_fence, *out_slots, |
| 127 | out_fence, *out_slots, out_target_slot, layer_id)); | 128 | out_target_slot, layer_id)); |
| 128 | } | 129 | } |
| 129 | 130 | ||
| 130 | Result ISystemDisplayService::PresentSharedFrameBuffer(android::Fence fence, | 131 | Result ISystemDisplayService::PresentSharedFrameBuffer(android::Fence fence, |
| @@ -132,15 +133,14 @@ Result ISystemDisplayService::PresentSharedFrameBuffer(android::Fence fence, | |||
| 132 | u32 window_transform, s32 swap_interval, | 133 | u32 window_transform, s32 swap_interval, |
| 133 | u64 layer_id, s64 surface_id) { | 134 | u64 layer_id, s64 surface_id) { |
| 134 | LOG_DEBUG(Service_VI, "called"); | 135 | LOG_DEBUG(Service_VI, "called"); |
| 135 | R_RETURN(m_surface_flinger->GetSystemBufferManager().PresentSharedFrameBuffer( | 136 | R_RETURN(m_shared_buffer_manager->PresentSharedFrameBuffer( |
| 136 | fence, crop_region, window_transform, swap_interval, layer_id, surface_id)); | 137 | fence, crop_region, window_transform, swap_interval, layer_id, surface_id)); |
| 137 | } | 138 | } |
| 138 | 139 | ||
| 139 | Result ISystemDisplayService::GetSharedFrameBufferAcquirableEvent( | 140 | Result ISystemDisplayService::GetSharedFrameBufferAcquirableEvent( |
| 140 | OutCopyHandle<Kernel::KReadableEvent> out_event, u64 layer_id) { | 141 | OutCopyHandle<Kernel::KReadableEvent> out_event, u64 layer_id) { |
| 141 | LOG_DEBUG(Service_VI, "called"); | 142 | LOG_DEBUG(Service_VI, "called"); |
| 142 | R_RETURN(m_surface_flinger->GetSystemBufferManager().GetSharedFrameBufferAcquirableEvent( | 143 | R_RETURN(m_shared_buffer_manager->GetSharedFrameBufferAcquirableEvent(out_event, layer_id)); |
| 143 | out_event, layer_id)); | ||
| 144 | } | 144 | } |
| 145 | 145 | ||
| 146 | } // namespace Service::VI | 146 | } // namespace Service::VI |
diff --git a/src/core/hle/service/vi/system_display_service.h b/src/core/hle/service/vi/system_display_service.h index 6c3f57ad7..b84c9725f 100644 --- a/src/core/hle/service/vi/system_display_service.h +++ b/src/core/hle/service/vi/system_display_service.h | |||
| @@ -5,18 +5,21 @@ | |||
| 5 | #include "core/hle/service/cmif_types.h" | 5 | #include "core/hle/service/cmif_types.h" |
| 6 | #include "core/hle/service/nvnflinger/ui/fence.h" | 6 | #include "core/hle/service/nvnflinger/ui/fence.h" |
| 7 | #include "core/hle/service/service.h" | 7 | #include "core/hle/service/service.h" |
| 8 | #include "core/hle/service/vi/fbshare_buffer_manager.h" | ||
| 8 | 9 | ||
| 9 | namespace Service::Nvnflinger { | 10 | namespace Service::Nvnflinger { |
| 10 | class Nvnflinger; | 11 | class Nvnflinger; |
| 11 | struct SharedMemoryPoolLayout; | ||
| 12 | } // namespace Service::Nvnflinger | 12 | } // namespace Service::Nvnflinger |
| 13 | 13 | ||
| 14 | namespace Service::VI { | 14 | namespace Service::VI { |
| 15 | 15 | ||
| 16 | class FbshareBufferManager; | ||
| 17 | |||
| 16 | class ISystemDisplayService final : public ServiceFramework<ISystemDisplayService> { | 18 | class ISystemDisplayService final : public ServiceFramework<ISystemDisplayService> { |
| 17 | public: | 19 | public: |
| 18 | explicit ISystemDisplayService(Core::System& system_, | 20 | explicit ISystemDisplayService(Core::System& system_, |
| 19 | std::shared_ptr<Nvnflinger::Nvnflinger> surface_flinger); | 21 | std::shared_ptr<Nvnflinger::Nvnflinger> surface_flinger, |
| 22 | std::shared_ptr<FbshareBufferManager> shared_buffer_manager); | ||
| 20 | ~ISystemDisplayService() override; | 23 | ~ISystemDisplayService() override; |
| 21 | 24 | ||
| 22 | private: | 25 | private: |
| @@ -27,7 +30,7 @@ private: | |||
| 27 | 30 | ||
| 28 | Result GetSharedBufferMemoryHandleId( | 31 | Result GetSharedBufferMemoryHandleId( |
| 29 | Out<s32> out_nvmap_handle, Out<u64> out_size, | 32 | Out<s32> out_nvmap_handle, Out<u64> out_size, |
| 30 | OutLargeData<Nvnflinger::SharedMemoryPoolLayout, BufferAttr_HipcMapAlias> out_pool_layout, | 33 | OutLargeData<SharedMemoryPoolLayout, BufferAttr_HipcMapAlias> out_pool_layout, |
| 31 | u64 buffer_id, ClientAppletResourceUserId aruid); | 34 | u64 buffer_id, ClientAppletResourceUserId aruid); |
| 32 | Result OpenSharedLayer(u64 layer_id); | 35 | Result OpenSharedLayer(u64 layer_id); |
| 33 | Result ConnectSharedLayer(u64 layer_id); | 36 | Result ConnectSharedLayer(u64 layer_id); |
| @@ -42,6 +45,7 @@ private: | |||
| 42 | 45 | ||
| 43 | private: | 46 | private: |
| 44 | const std::shared_ptr<Nvnflinger::Nvnflinger> m_surface_flinger; | 47 | const std::shared_ptr<Nvnflinger::Nvnflinger> m_surface_flinger; |
| 48 | const std::shared_ptr<FbshareBufferManager> m_shared_buffer_manager; | ||
| 45 | }; | 49 | }; |
| 46 | 50 | ||
| 47 | } // namespace Service::VI | 51 | } // namespace Service::VI |
diff --git a/src/core/hle/service/vi/system_root_service.cpp b/src/core/hle/service/vi/system_root_service.cpp index 1d435ed6b..2254ed111 100644 --- a/src/core/hle/service/vi/system_root_service.cpp +++ b/src/core/hle/service/vi/system_root_service.cpp | |||
| @@ -11,8 +11,10 @@ | |||
| 11 | namespace Service::VI { | 11 | namespace Service::VI { |
| 12 | 12 | ||
| 13 | ISystemRootService::ISystemRootService(Core::System& system_, | 13 | ISystemRootService::ISystemRootService(Core::System& system_, |
| 14 | std::shared_ptr<Nvnflinger::IHOSBinderDriver> binder_service) | 14 | std::shared_ptr<Nvnflinger::IHOSBinderDriver> binder_service, |
| 15 | : ServiceFramework{system_, "vi:s"}, m_binder_service{std::move(binder_service)} { | 15 | std::shared_ptr<FbshareBufferManager> shared_buffer_manager) |
| 16 | : ServiceFramework{system_, "vi:s"}, m_binder_service{std::move(binder_service)}, | ||
| 17 | m_shared_buffer_manager{std::move(shared_buffer_manager)} { | ||
| 16 | static const FunctionInfo functions[] = { | 18 | static const FunctionInfo functions[] = { |
| 17 | {1, C<&ISystemRootService::GetDisplayService>, "GetDisplayService"}, | 19 | {1, C<&ISystemRootService::GetDisplayService>, "GetDisplayService"}, |
| 18 | {3, nullptr, "GetDisplayServiceWithProxyNameExchange"}, | 20 | {3, nullptr, "GetDisplayServiceWithProxyNameExchange"}, |
| @@ -26,7 +28,7 @@ Result ISystemRootService::GetDisplayService( | |||
| 26 | Out<SharedPointer<IApplicationDisplayService>> out_application_display_service, Policy policy) { | 28 | Out<SharedPointer<IApplicationDisplayService>> out_application_display_service, Policy policy) { |
| 27 | LOG_DEBUG(Service_VI, "called"); | 29 | LOG_DEBUG(Service_VI, "called"); |
| 28 | R_RETURN(GetApplicationDisplayService(out_application_display_service, system, m_binder_service, | 30 | R_RETURN(GetApplicationDisplayService(out_application_display_service, system, m_binder_service, |
| 29 | Permission::System, policy)); | 31 | m_shared_buffer_manager, Permission::System, policy)); |
| 30 | } | 32 | } |
| 31 | 33 | ||
| 32 | } // namespace Service::VI | 34 | } // namespace Service::VI |
diff --git a/src/core/hle/service/vi/system_root_service.h b/src/core/hle/service/vi/system_root_service.h index 6f07c39fd..16c997422 100644 --- a/src/core/hle/service/vi/system_root_service.h +++ b/src/core/hle/service/vi/system_root_service.h | |||
| @@ -16,13 +16,15 @@ class IHOSBinderDriver; | |||
| 16 | 16 | ||
| 17 | namespace Service::VI { | 17 | namespace Service::VI { |
| 18 | 18 | ||
| 19 | class FbshareBufferManager; | ||
| 19 | class IApplicationDisplayService; | 20 | class IApplicationDisplayService; |
| 20 | enum class Policy : u32; | 21 | enum class Policy : u32; |
| 21 | 22 | ||
| 22 | class ISystemRootService final : public ServiceFramework<ISystemRootService> { | 23 | class ISystemRootService final : public ServiceFramework<ISystemRootService> { |
| 23 | public: | 24 | public: |
| 24 | explicit ISystemRootService(Core::System& system_, | 25 | explicit ISystemRootService(Core::System& system_, |
| 25 | std::shared_ptr<Nvnflinger::IHOSBinderDriver> binder_service); | 26 | std::shared_ptr<Nvnflinger::IHOSBinderDriver> binder_service, |
| 27 | std::shared_ptr<FbshareBufferManager> shared_buffer_manager); | ||
| 26 | ~ISystemRootService() override; | 28 | ~ISystemRootService() override; |
| 27 | 29 | ||
| 28 | private: | 30 | private: |
| @@ -31,6 +33,7 @@ private: | |||
| 31 | Policy policy); | 33 | Policy policy); |
| 32 | 34 | ||
| 33 | const std::shared_ptr<Nvnflinger::IHOSBinderDriver> m_binder_service; | 35 | const std::shared_ptr<Nvnflinger::IHOSBinderDriver> m_binder_service; |
| 36 | const std::shared_ptr<FbshareBufferManager> m_shared_buffer_manager; | ||
| 34 | }; | 37 | }; |
| 35 | 38 | ||
| 36 | } // namespace Service::VI | 39 | } // namespace Service::VI |
diff --git a/src/core/hle/service/vi/vi.cpp b/src/core/hle/service/vi/vi.cpp index d20f1fdea..f361b9f4c 100644 --- a/src/core/hle/service/vi/vi.cpp +++ b/src/core/hle/service/vi/vi.cpp | |||
| @@ -2,11 +2,13 @@ | |||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | 3 | ||
| 4 | #include "core/core.h" | 4 | #include "core/core.h" |
| 5 | #include "core/hle/service/nvdrv/nvdrv_interface.h" | ||
| 5 | #include "core/hle/service/nvnflinger/hos_binder_driver.h" | 6 | #include "core/hle/service/nvnflinger/hos_binder_driver.h" |
| 6 | #include "core/hle/service/server_manager.h" | 7 | #include "core/hle/service/server_manager.h" |
| 7 | #include "core/hle/service/sm/sm.h" | 8 | #include "core/hle/service/sm/sm.h" |
| 8 | #include "core/hle/service/vi/application_display_service.h" | 9 | #include "core/hle/service/vi/application_display_service.h" |
| 9 | #include "core/hle/service/vi/application_root_service.h" | 10 | #include "core/hle/service/vi/application_root_service.h" |
| 11 | #include "core/hle/service/vi/fbshare_buffer_manager.h" | ||
| 10 | #include "core/hle/service/vi/manager_root_service.h" | 12 | #include "core/hle/service/vi/manager_root_service.h" |
| 11 | #include "core/hle/service/vi/system_root_service.h" | 13 | #include "core/hle/service/vi/system_root_service.h" |
| 12 | #include "core/hle/service/vi/vi.h" | 14 | #include "core/hle/service/vi/vi.h" |
| @@ -16,14 +18,22 @@ namespace Service::VI { | |||
| 16 | void LoopProcess(Core::System& system) { | 18 | void LoopProcess(Core::System& system) { |
| 17 | const auto binder_service = | 19 | const auto binder_service = |
| 18 | system.ServiceManager().GetService<Nvnflinger::IHOSBinderDriver>("dispdrv", true); | 20 | system.ServiceManager().GetService<Nvnflinger::IHOSBinderDriver>("dispdrv", true); |
| 21 | const auto nvdrv = | ||
| 22 | system.ServiceManager().GetService<Nvidia::NVDRV>("nvdrv:s", true)->GetModule(); | ||
| 23 | const auto shared_buffer_manager = | ||
| 24 | std::make_shared<FbshareBufferManager>(system, binder_service->GetSurfaceFlinger(), nvdrv); | ||
| 25 | |||
| 19 | auto server_manager = std::make_unique<ServerManager>(system); | 26 | auto server_manager = std::make_unique<ServerManager>(system); |
| 20 | 27 | ||
| 21 | server_manager->RegisterNamedService( | 28 | server_manager->RegisterNamedService( |
| 22 | "vi:m", std::make_shared<IManagerRootService>(system, binder_service)); | 29 | "vi:m", |
| 30 | std::make_shared<IManagerRootService>(system, binder_service, shared_buffer_manager)); | ||
| 23 | server_manager->RegisterNamedService( | 31 | server_manager->RegisterNamedService( |
| 24 | "vi:s", std::make_shared<ISystemRootService>(system, binder_service)); | 32 | "vi:s", |
| 33 | std::make_shared<ISystemRootService>(system, binder_service, shared_buffer_manager)); | ||
| 25 | server_manager->RegisterNamedService( | 34 | server_manager->RegisterNamedService( |
| 26 | "vi:u", std::make_shared<IApplicationRootService>(system, binder_service)); | 35 | "vi:u", |
| 36 | std::make_shared<IApplicationRootService>(system, binder_service, shared_buffer_manager)); | ||
| 27 | ServerManager::RunServer(std::move(server_manager)); | 37 | ServerManager::RunServer(std::move(server_manager)); |
| 28 | } | 38 | } |
| 29 | 39 | ||