summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Lioncash2018-08-07 09:17:09 -0400
committerGravatar Lioncash2018-08-07 21:53:05 -0400
commitd378d98e2628f83fa56242ec6b53e3cce7c6bb56 (patch)
treec50db5a6d7840f493d970ba449aa7010124e9a88 /src
parentMerge pull request #971 from DarkLordZach/mbedtls-2.12.0 (diff)
downloadyuzu-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.cpp7
-rw-r--r--src/core/hle/service/nvdrv/nvdrv.h8
-rw-r--r--src/core/hle/service/nvflinger/nvflinger.cpp7
-rw-r--r--src/core/hle/service/nvflinger/nvflinger.h9
-rw-r--r--src/core/hle/service/service.cpp2
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
20namespace Service::Nvidia { 21namespace Service::Nvidia {
21 22
22std::weak_ptr<Module> nvdrv; 23void InstallInterfaces(SM::ServiceManager& service_manager, NVFlinger::NVFlinger& nvflinger) {
23
24void 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
34Module::Module() { 33Module::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
13namespace Service::NVFlinger {
14class NVFlinger;
15}
16
13namespace Service::Nvidia { 17namespace Service::Nvidia {
14 18
15namespace Devices { 19namespace 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.
59void InstallInterfaces(SM::ServiceManager& service_manager); 63void InstallInterfaces(SM::ServiceManager& service_manager, NVFlinger::NVFlinger& nvflinger);
60
61extern 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
49void NVFlinger::SetNVDrvInstance(std::shared_ptr<Nvidia::Module> instance) {
50 nvdrv = std::move(instance);
51}
52
49u64 NVFlinger::OpenDisplay(std::string_view name) { 53u64 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 {
16struct EventType; 16struct EventType;
17} 17}
18 18
19namespace Service::Nvidia {
20class Module;
21}
22
19namespace Service::NVFlinger { 23namespace Service::NVFlinger {
20 24
21class BufferQueue; 25class 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);