diff options
| author | 2018-08-07 09:17:09 -0400 | |
|---|---|---|
| committer | 2018-08-07 21:53:05 -0400 | |
| commit | d378d98e2628f83fa56242ec6b53e3cce7c6bb56 (patch) | |
| tree | c50db5a6d7840f493d970ba449aa7010124e9a88 /src | |
| parent | Merge pull request #971 from DarkLordZach/mbedtls-2.12.0 (diff) | |
| download | yuzu-d378d98e2628f83fa56242ec6b53e3cce7c6bb56.tar.gz yuzu-d378d98e2628f83fa56242ec6b53e3cce7c6bb56.tar.xz yuzu-d378d98e2628f83fa56242ec6b53e3cce7c6bb56.zip | |
nvdrv: Get rid of global std::weak_ptr
Rather than use global state, we can simply pass the instance into the
NVFlinger instance directly.
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/hle/service/nvdrv/nvdrv.cpp | 7 | ||||
| -rw-r--r-- | src/core/hle/service/nvdrv/nvdrv.h | 8 | ||||
| -rw-r--r-- | src/core/hle/service/nvflinger/nvflinger.cpp | 7 | ||||
| -rw-r--r-- | src/core/hle/service/nvflinger/nvflinger.h | 9 | ||||
| -rw-r--r-- | src/core/hle/service/service.cpp | 2 |
5 files changed, 22 insertions, 11 deletions
diff --git a/src/core/hle/service/nvdrv/nvdrv.cpp b/src/core/hle/service/nvdrv/nvdrv.cpp index e8b30921a..427f4b574 100644 --- a/src/core/hle/service/nvdrv/nvdrv.cpp +++ b/src/core/hle/service/nvdrv/nvdrv.cpp | |||
| @@ -16,19 +16,18 @@ | |||
| 16 | #include "core/hle/service/nvdrv/interface.h" | 16 | #include "core/hle/service/nvdrv/interface.h" |
| 17 | #include "core/hle/service/nvdrv/nvdrv.h" | 17 | #include "core/hle/service/nvdrv/nvdrv.h" |
| 18 | #include "core/hle/service/nvdrv/nvmemp.h" | 18 | #include "core/hle/service/nvdrv/nvmemp.h" |
| 19 | #include "core/hle/service/nvflinger/nvflinger.h" | ||
| 19 | 20 | ||
| 20 | namespace Service::Nvidia { | 21 | namespace Service::Nvidia { |
| 21 | 22 | ||
| 22 | std::weak_ptr<Module> nvdrv; | 23 | void InstallInterfaces(SM::ServiceManager& service_manager, NVFlinger::NVFlinger& nvflinger) { |
| 23 | |||
| 24 | void InstallInterfaces(SM::ServiceManager& service_manager) { | ||
| 25 | auto module_ = std::make_shared<Module>(); | 24 | auto module_ = std::make_shared<Module>(); |
| 26 | std::make_shared<NVDRV>(module_, "nvdrv")->InstallAsService(service_manager); | 25 | std::make_shared<NVDRV>(module_, "nvdrv")->InstallAsService(service_manager); |
| 27 | std::make_shared<NVDRV>(module_, "nvdrv:a")->InstallAsService(service_manager); | 26 | std::make_shared<NVDRV>(module_, "nvdrv:a")->InstallAsService(service_manager); |
| 28 | std::make_shared<NVDRV>(module_, "nvdrv:s")->InstallAsService(service_manager); | 27 | std::make_shared<NVDRV>(module_, "nvdrv:s")->InstallAsService(service_manager); |
| 29 | std::make_shared<NVDRV>(module_, "nvdrv:t")->InstallAsService(service_manager); | 28 | std::make_shared<NVDRV>(module_, "nvdrv:t")->InstallAsService(service_manager); |
| 30 | std::make_shared<NVMEMP>()->InstallAsService(service_manager); | 29 | std::make_shared<NVMEMP>()->InstallAsService(service_manager); |
| 31 | nvdrv = module_; | 30 | nvflinger.SetNVDrvInstance(module_); |
| 32 | } | 31 | } |
| 33 | 32 | ||
| 34 | Module::Module() { | 33 | Module::Module() { |
diff --git a/src/core/hle/service/nvdrv/nvdrv.h b/src/core/hle/service/nvdrv/nvdrv.h index 184f3c9fc..99eb1128a 100644 --- a/src/core/hle/service/nvdrv/nvdrv.h +++ b/src/core/hle/service/nvdrv/nvdrv.h | |||
| @@ -10,6 +10,10 @@ | |||
| 10 | #include "common/common_types.h" | 10 | #include "common/common_types.h" |
| 11 | #include "core/hle/service/service.h" | 11 | #include "core/hle/service/service.h" |
| 12 | 12 | ||
| 13 | namespace Service::NVFlinger { | ||
| 14 | class NVFlinger; | ||
| 15 | } | ||
| 16 | |||
| 13 | namespace Service::Nvidia { | 17 | namespace Service::Nvidia { |
| 14 | 18 | ||
| 15 | namespace Devices { | 19 | namespace Devices { |
| @@ -56,8 +60,6 @@ private: | |||
| 56 | }; | 60 | }; |
| 57 | 61 | ||
| 58 | /// Registers all NVDRV services with the specified service manager. | 62 | /// Registers all NVDRV services with the specified service manager. |
| 59 | void InstallInterfaces(SM::ServiceManager& service_manager); | 63 | void InstallInterfaces(SM::ServiceManager& service_manager, NVFlinger::NVFlinger& nvflinger); |
| 60 | |||
| 61 | extern std::weak_ptr<Module> nvdrv; | ||
| 62 | 64 | ||
| 63 | } // namespace Service::Nvidia | 65 | } // namespace Service::Nvidia |
diff --git a/src/core/hle/service/nvflinger/nvflinger.cpp b/src/core/hle/service/nvflinger/nvflinger.cpp index 570aa8493..a26a5f812 100644 --- a/src/core/hle/service/nvflinger/nvflinger.cpp +++ b/src/core/hle/service/nvflinger/nvflinger.cpp | |||
| @@ -46,6 +46,10 @@ NVFlinger::~NVFlinger() { | |||
| 46 | CoreTiming::UnscheduleEvent(composition_event, 0); | 46 | CoreTiming::UnscheduleEvent(composition_event, 0); |
| 47 | } | 47 | } |
| 48 | 48 | ||
| 49 | void NVFlinger::SetNVDrvInstance(std::shared_ptr<Nvidia::Module> instance) { | ||
| 50 | nvdrv = std::move(instance); | ||
| 51 | } | ||
| 52 | |||
| 49 | u64 NVFlinger::OpenDisplay(std::string_view name) { | 53 | u64 NVFlinger::OpenDisplay(std::string_view name) { |
| 50 | LOG_WARNING(Service, "Opening display {}", name); | 54 | LOG_WARNING(Service, "Opening display {}", name); |
| 51 | 55 | ||
| @@ -141,9 +145,6 @@ void NVFlinger::Compose() { | |||
| 141 | auto& igbp_buffer = buffer->igbp_buffer; | 145 | auto& igbp_buffer = buffer->igbp_buffer; |
| 142 | 146 | ||
| 143 | // Now send the buffer to the GPU for drawing. | 147 | // Now send the buffer to the GPU for drawing. |
| 144 | auto nvdrv = Nvidia::nvdrv.lock(); | ||
| 145 | ASSERT(nvdrv); | ||
| 146 | |||
| 147 | // TODO(Subv): Support more than just disp0. The display device selection is probably based | 148 | // TODO(Subv): Support more than just disp0. The display device selection is probably based |
| 148 | // on which display we're drawing (Default, Internal, External, etc) | 149 | // on which display we're drawing (Default, Internal, External, etc) |
| 149 | auto nvdisp = nvdrv->GetDevice<Nvidia::Devices::nvdisp_disp0>("/dev/nvdisp_disp0"); | 150 | auto nvdisp = nvdrv->GetDevice<Nvidia::Devices::nvdisp_disp0>("/dev/nvdisp_disp0"); |
diff --git a/src/core/hle/service/nvflinger/nvflinger.h b/src/core/hle/service/nvflinger/nvflinger.h index 5374df175..f7112949f 100644 --- a/src/core/hle/service/nvflinger/nvflinger.h +++ b/src/core/hle/service/nvflinger/nvflinger.h | |||
| @@ -16,6 +16,10 @@ namespace CoreTiming { | |||
| 16 | struct EventType; | 16 | struct EventType; |
| 17 | } | 17 | } |
| 18 | 18 | ||
| 19 | namespace Service::Nvidia { | ||
| 20 | class Module; | ||
| 21 | } | ||
| 22 | |||
| 19 | namespace Service::NVFlinger { | 23 | namespace Service::NVFlinger { |
| 20 | 24 | ||
| 21 | class BufferQueue; | 25 | class BufferQueue; |
| @@ -44,6 +48,9 @@ public: | |||
| 44 | NVFlinger(); | 48 | NVFlinger(); |
| 45 | ~NVFlinger(); | 49 | ~NVFlinger(); |
| 46 | 50 | ||
| 51 | /// Sets the NVDrv module instance to use to send buffers to the GPU. | ||
| 52 | void SetNVDrvInstance(std::shared_ptr<Nvidia::Module> instance); | ||
| 53 | |||
| 47 | /// Opens the specified display and returns the id. | 54 | /// Opens the specified display and returns the id. |
| 48 | u64 OpenDisplay(std::string_view name); | 55 | u64 OpenDisplay(std::string_view name); |
| 49 | 56 | ||
| @@ -70,6 +77,8 @@ private: | |||
| 70 | /// Returns the layer identified by the specified id in the desired display. | 77 | /// Returns the layer identified by the specified id in the desired display. |
| 71 | Layer& GetLayer(u64 display_id, u64 layer_id); | 78 | Layer& GetLayer(u64 display_id, u64 layer_id); |
| 72 | 79 | ||
| 80 | std::shared_ptr<Nvidia::Module> nvdrv; | ||
| 81 | |||
| 73 | std::vector<Display> displays; | 82 | std::vector<Display> displays; |
| 74 | std::vector<std::shared_ptr<BufferQueue>> buffer_queues; | 83 | std::vector<std::shared_ptr<BufferQueue>> buffer_queues; |
| 75 | 84 | ||
diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp index 889cdd41a..6f286ea74 100644 --- a/src/core/hle/service/service.cpp +++ b/src/core/hle/service/service.cpp | |||
| @@ -238,7 +238,7 @@ void Init(std::shared_ptr<SM::ServiceManager>& sm) { | |||
| 238 | NIFM::InstallInterfaces(*sm); | 238 | NIFM::InstallInterfaces(*sm); |
| 239 | NIM::InstallInterfaces(*sm); | 239 | NIM::InstallInterfaces(*sm); |
| 240 | NS::InstallInterfaces(*sm); | 240 | NS::InstallInterfaces(*sm); |
| 241 | Nvidia::InstallInterfaces(*sm); | 241 | Nvidia::InstallInterfaces(*sm, *nv_flinger); |
| 242 | PCIe::InstallInterfaces(*sm); | 242 | PCIe::InstallInterfaces(*sm); |
| 243 | PCTL::InstallInterfaces(*sm); | 243 | PCTL::InstallInterfaces(*sm); |
| 244 | PCV::InstallInterfaces(*sm); | 244 | PCV::InstallInterfaces(*sm); |