mirror of
https://gitlab.com/suyu-emu/suyu.git
synced 2024-03-15 23:15:44 +00:00
Merge pull request #958 from lioncash/nv-global
nvdrv: Get rid of global std::weak_ptr
This commit is contained in:
commit
448264e719
|
@ -16,19 +16,18 @@
|
||||||
#include "core/hle/service/nvdrv/interface.h"
|
#include "core/hle/service/nvdrv/interface.h"
|
||||||
#include "core/hle/service/nvdrv/nvdrv.h"
|
#include "core/hle/service/nvdrv/nvdrv.h"
|
||||||
#include "core/hle/service/nvdrv/nvmemp.h"
|
#include "core/hle/service/nvdrv/nvmemp.h"
|
||||||
|
#include "core/hle/service/nvflinger/nvflinger.h"
|
||||||
|
|
||||||
namespace Service::Nvidia {
|
namespace Service::Nvidia {
|
||||||
|
|
||||||
std::weak_ptr<Module> nvdrv;
|
void InstallInterfaces(SM::ServiceManager& service_manager, NVFlinger::NVFlinger& nvflinger) {
|
||||||
|
|
||||||
void InstallInterfaces(SM::ServiceManager& service_manager) {
|
|
||||||
auto module_ = std::make_shared<Module>();
|
auto module_ = std::make_shared<Module>();
|
||||||
std::make_shared<NVDRV>(module_, "nvdrv")->InstallAsService(service_manager);
|
std::make_shared<NVDRV>(module_, "nvdrv")->InstallAsService(service_manager);
|
||||||
std::make_shared<NVDRV>(module_, "nvdrv:a")->InstallAsService(service_manager);
|
std::make_shared<NVDRV>(module_, "nvdrv:a")->InstallAsService(service_manager);
|
||||||
std::make_shared<NVDRV>(module_, "nvdrv:s")->InstallAsService(service_manager);
|
std::make_shared<NVDRV>(module_, "nvdrv:s")->InstallAsService(service_manager);
|
||||||
std::make_shared<NVDRV>(module_, "nvdrv:t")->InstallAsService(service_manager);
|
std::make_shared<NVDRV>(module_, "nvdrv:t")->InstallAsService(service_manager);
|
||||||
std::make_shared<NVMEMP>()->InstallAsService(service_manager);
|
std::make_shared<NVMEMP>()->InstallAsService(service_manager);
|
||||||
nvdrv = module_;
|
nvflinger.SetNVDrvInstance(module_);
|
||||||
}
|
}
|
||||||
|
|
||||||
Module::Module() {
|
Module::Module() {
|
||||||
|
|
|
@ -10,6 +10,10 @@
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
#include "core/hle/service/service.h"
|
#include "core/hle/service/service.h"
|
||||||
|
|
||||||
|
namespace Service::NVFlinger {
|
||||||
|
class NVFlinger;
|
||||||
|
}
|
||||||
|
|
||||||
namespace Service::Nvidia {
|
namespace Service::Nvidia {
|
||||||
|
|
||||||
namespace Devices {
|
namespace Devices {
|
||||||
|
@ -56,8 +60,6 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Registers all NVDRV services with the specified service manager.
|
/// Registers all NVDRV services with the specified service manager.
|
||||||
void InstallInterfaces(SM::ServiceManager& service_manager);
|
void InstallInterfaces(SM::ServiceManager& service_manager, NVFlinger::NVFlinger& nvflinger);
|
||||||
|
|
||||||
extern std::weak_ptr<Module> nvdrv;
|
|
||||||
|
|
||||||
} // namespace Service::Nvidia
|
} // namespace Service::Nvidia
|
||||||
|
|
|
@ -46,6 +46,10 @@ NVFlinger::~NVFlinger() {
|
||||||
CoreTiming::UnscheduleEvent(composition_event, 0);
|
CoreTiming::UnscheduleEvent(composition_event, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NVFlinger::SetNVDrvInstance(std::shared_ptr<Nvidia::Module> instance) {
|
||||||
|
nvdrv = std::move(instance);
|
||||||
|
}
|
||||||
|
|
||||||
u64 NVFlinger::OpenDisplay(std::string_view name) {
|
u64 NVFlinger::OpenDisplay(std::string_view name) {
|
||||||
LOG_WARNING(Service, "Opening display {}", name);
|
LOG_WARNING(Service, "Opening display {}", name);
|
||||||
|
|
||||||
|
@ -141,9 +145,6 @@ void NVFlinger::Compose() {
|
||||||
auto& igbp_buffer = buffer->igbp_buffer;
|
auto& igbp_buffer = buffer->igbp_buffer;
|
||||||
|
|
||||||
// Now send the buffer to the GPU for drawing.
|
// Now send the buffer to the GPU for drawing.
|
||||||
auto nvdrv = Nvidia::nvdrv.lock();
|
|
||||||
ASSERT(nvdrv);
|
|
||||||
|
|
||||||
// TODO(Subv): Support more than just disp0. The display device selection is probably based
|
// TODO(Subv): Support more than just disp0. The display device selection is probably based
|
||||||
// on which display we're drawing (Default, Internal, External, etc)
|
// on which display we're drawing (Default, Internal, External, etc)
|
||||||
auto nvdisp = nvdrv->GetDevice<Nvidia::Devices::nvdisp_disp0>("/dev/nvdisp_disp0");
|
auto nvdisp = nvdrv->GetDevice<Nvidia::Devices::nvdisp_disp0>("/dev/nvdisp_disp0");
|
||||||
|
|
|
@ -16,6 +16,10 @@ namespace CoreTiming {
|
||||||
struct EventType;
|
struct EventType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace Service::Nvidia {
|
||||||
|
class Module;
|
||||||
|
}
|
||||||
|
|
||||||
namespace Service::NVFlinger {
|
namespace Service::NVFlinger {
|
||||||
|
|
||||||
class BufferQueue;
|
class BufferQueue;
|
||||||
|
@ -44,6 +48,9 @@ public:
|
||||||
NVFlinger();
|
NVFlinger();
|
||||||
~NVFlinger();
|
~NVFlinger();
|
||||||
|
|
||||||
|
/// Sets the NVDrv module instance to use to send buffers to the GPU.
|
||||||
|
void SetNVDrvInstance(std::shared_ptr<Nvidia::Module> instance);
|
||||||
|
|
||||||
/// Opens the specified display and returns the id.
|
/// Opens the specified display and returns the id.
|
||||||
u64 OpenDisplay(std::string_view name);
|
u64 OpenDisplay(std::string_view name);
|
||||||
|
|
||||||
|
@ -70,6 +77,8 @@ private:
|
||||||
/// Returns the layer identified by the specified id in the desired display.
|
/// Returns the layer identified by the specified id in the desired display.
|
||||||
Layer& GetLayer(u64 display_id, u64 layer_id);
|
Layer& GetLayer(u64 display_id, u64 layer_id);
|
||||||
|
|
||||||
|
std::shared_ptr<Nvidia::Module> nvdrv;
|
||||||
|
|
||||||
std::vector<Display> displays;
|
std::vector<Display> displays;
|
||||||
std::vector<std::shared_ptr<BufferQueue>> buffer_queues;
|
std::vector<std::shared_ptr<BufferQueue>> buffer_queues;
|
||||||
|
|
||||||
|
|
|
@ -238,7 +238,7 @@ void Init(std::shared_ptr<SM::ServiceManager>& sm) {
|
||||||
NIFM::InstallInterfaces(*sm);
|
NIFM::InstallInterfaces(*sm);
|
||||||
NIM::InstallInterfaces(*sm);
|
NIM::InstallInterfaces(*sm);
|
||||||
NS::InstallInterfaces(*sm);
|
NS::InstallInterfaces(*sm);
|
||||||
Nvidia::InstallInterfaces(*sm);
|
Nvidia::InstallInterfaces(*sm, *nv_flinger);
|
||||||
PCIe::InstallInterfaces(*sm);
|
PCIe::InstallInterfaces(*sm);
|
||||||
PCTL::InstallInterfaces(*sm);
|
PCTL::InstallInterfaces(*sm);
|
||||||
PCV::InstallInterfaces(*sm);
|
PCV::InstallInterfaces(*sm);
|
||||||
|
|
Loading…
Reference in a new issue