diff options
| author | 2022-01-30 23:13:46 +0100 | |
|---|---|---|
| committer | 2022-10-06 21:00:52 +0200 | |
| commit | 920429fde745b3bf6d33b6ca991628f64988f754 (patch) | |
| tree | 3c10b169e9e94041955500e4ed46e664255e4349 /src/core/hle | |
| parent | NVDRV: Refactor Host1x (diff) | |
| download | yuzu-920429fde745b3bf6d33b6ca991628f64988f754.tar.gz yuzu-920429fde745b3bf6d33b6ca991628f64988f754.tar.xz yuzu-920429fde745b3bf6d33b6ca991628f64988f754.zip | |
NVDRV: Further refactors and eliminate old code.
Diffstat (limited to 'src/core/hle')
| -rw-r--r-- | src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp | 26 | ||||
| -rw-r--r-- | src/core/hle/service/nvdrv/devices/nvhost_ctrl.h | 2 | ||||
| -rw-r--r-- | src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp | 7 | ||||
| -rw-r--r-- | src/core/hle/service/nvdrv/nvdrv.cpp | 21 | ||||
| -rw-r--r-- | src/core/hle/service/nvdrv/nvdrv.h | 7 | ||||
| -rw-r--r-- | src/core/hle/service/nvdrv/nvdrv_interface.cpp | 4 | ||||
| -rw-r--r-- | src/core/hle/service/nvdrv/nvdrv_interface.h | 2 |
7 files changed, 8 insertions, 61 deletions
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp index ffe42d423..076edb02f 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp | |||
| @@ -77,12 +77,9 @@ NvResult nvhost_ctrl::Ioctl3(DeviceFD fd, Ioctl command, const std::vector<u8>& | |||
| 77 | return NvResult::NotImplemented; | 77 | return NvResult::NotImplemented; |
| 78 | } | 78 | } |
| 79 | 79 | ||
| 80 | void nvhost_ctrl::OnOpen(DeviceFD fd) { | 80 | void nvhost_ctrl::OnOpen(DeviceFD fd) {} |
| 81 | events_interface.RegisterForSignal(this); | 81 | |
| 82 | } | 82 | void nvhost_ctrl::OnClose(DeviceFD fd) {} |
| 83 | void nvhost_ctrl::OnClose(DeviceFD fd) { | ||
| 84 | events_interface.UnregisterForSignal(this); | ||
| 85 | } | ||
| 86 | 83 | ||
| 87 | NvResult nvhost_ctrl::NvOsGetConfigU32(const std::vector<u8>& input, std::vector<u8>& output) { | 84 | NvResult nvhost_ctrl::NvOsGetConfigU32(const std::vector<u8>& input, std::vector<u8>& output) { |
| 88 | IocGetConfigParams params{}; | 85 | IocGetConfigParams params{}; |
| @@ -395,21 +392,4 @@ u32 nvhost_ctrl::FindFreeNvEvent(u32 syncpoint_id) { | |||
| 395 | return 0; | 392 | return 0; |
| 396 | } | 393 | } |
| 397 | 394 | ||
| 398 | void nvhost_ctrl::SignalNvEvent(u32 syncpoint_id, u32 value) { | ||
| 399 | u64 signal_mask = events_mask; | ||
| 400 | while (signal_mask != 0) { | ||
| 401 | const u64 event_id = std::countr_zero(signal_mask); | ||
| 402 | signal_mask &= ~(1ULL << event_id); | ||
| 403 | auto& event = events[event_id]; | ||
| 404 | if (event.assigned_syncpt != syncpoint_id || event.assigned_value != value) { | ||
| 405 | continue; | ||
| 406 | } | ||
| 407 | if (event.status.exchange(EventState::Signalling, std::memory_order_acq_rel) == | ||
| 408 | EventState::Waiting) { | ||
| 409 | event.kevent->GetWritableEvent().Signal(); | ||
| 410 | } | ||
| 411 | event.status.store(EventState::Signalled, std::memory_order_release); | ||
| 412 | } | ||
| 413 | } | ||
| 414 | |||
| 415 | } // namespace Service::Nvidia::Devices | 395 | } // namespace Service::Nvidia::Devices |
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.h b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.h index 136a1e925..f511c0296 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.h +++ b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.h | |||
| @@ -56,8 +56,6 @@ public: | |||
| 56 | }; | 56 | }; |
| 57 | static_assert(sizeof(SyncpointEventValue) == sizeof(u32)); | 57 | static_assert(sizeof(SyncpointEventValue) == sizeof(u32)); |
| 58 | 58 | ||
| 59 | void SignalNvEvent(u32 syncpoint_id, u32 value); | ||
| 60 | |||
| 61 | private: | 59 | private: |
| 62 | struct InternalEvent { | 60 | struct InternalEvent { |
| 63 | // Mask representing registered events | 61 | // Mask representing registered events |
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp b/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp index db3e266ad..3f981af5a 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp | |||
| @@ -14,6 +14,7 @@ | |||
| 14 | #include "video_core/control/channel_state.h" | 14 | #include "video_core/control/channel_state.h" |
| 15 | #include "video_core/engines/puller.h" | 15 | #include "video_core/engines/puller.h" |
| 16 | #include "video_core/gpu.h" | 16 | #include "video_core/gpu.h" |
| 17 | #include "video_core/host1x/host1x.h" | ||
| 17 | 18 | ||
| 18 | namespace Service::Nvidia::Devices { | 19 | namespace Service::Nvidia::Devices { |
| 19 | namespace { | 20 | namespace { |
| @@ -31,7 +32,8 @@ nvhost_gpu::nvhost_gpu(Core::System& system_, EventInterface& events_interface_, | |||
| 31 | syncpoint_manager{core_.GetSyncpointManager()}, nvmap{core.GetNvMapFile()}, | 32 | syncpoint_manager{core_.GetSyncpointManager()}, nvmap{core.GetNvMapFile()}, |
| 32 | channel_state{system.GPU().AllocateChannel()} { | 33 | channel_state{system.GPU().AllocateChannel()} { |
| 33 | channel_fence.id = syncpoint_manager.AllocateSyncpoint(); | 34 | channel_fence.id = syncpoint_manager.AllocateSyncpoint(); |
| 34 | channel_fence.value = system_.GPU().GetSyncpointValue(channel_fence.id); | 35 | channel_fence.value = |
| 36 | system_.Host1x().GetSyncpointManager().GetGuestSyncpointValue(channel_fence.id); | ||
| 35 | sm_exception_breakpoint_int_report_event = | 37 | sm_exception_breakpoint_int_report_event = |
| 36 | events_interface.CreateEvent("GpuChannelSMExceptionBreakpointInt"); | 38 | events_interface.CreateEvent("GpuChannelSMExceptionBreakpointInt"); |
| 37 | sm_exception_breakpoint_pause_report_event = | 39 | sm_exception_breakpoint_pause_report_event = |
| @@ -189,7 +191,8 @@ NvResult nvhost_gpu::AllocGPFIFOEx2(const std::vector<u8>& input, std::vector<u8 | |||
| 189 | } | 191 | } |
| 190 | 192 | ||
| 191 | system.GPU().InitChannel(*channel_state); | 193 | system.GPU().InitChannel(*channel_state); |
| 192 | channel_fence.value = system.GPU().GetSyncpointValue(channel_fence.id); | 194 | channel_fence.value = |
| 195 | system.Host1x().GetSyncpointManager().GetGuestSyncpointValue(channel_fence.id); | ||
| 193 | 196 | ||
| 194 | params.fence_out = channel_fence; | 197 | params.fence_out = channel_fence; |
| 195 | 198 | ||
diff --git a/src/core/hle/service/nvdrv/nvdrv.cpp b/src/core/hle/service/nvdrv/nvdrv.cpp index 8a9f3c717..1be51e401 100644 --- a/src/core/hle/service/nvdrv/nvdrv.cpp +++ b/src/core/hle/service/nvdrv/nvdrv.cpp | |||
| @@ -33,23 +33,6 @@ EventInterface::EventInterface(Module& module_) : module{module_}, guard{}, on_s | |||
| 33 | 33 | ||
| 34 | EventInterface::~EventInterface() = default; | 34 | EventInterface::~EventInterface() = default; |
| 35 | 35 | ||
| 36 | void EventInterface::RegisterForSignal(Devices::nvhost_ctrl* device) { | ||
| 37 | std::unique_lock<std::mutex> lk(guard); | ||
| 38 | on_signal.push_back(device); | ||
| 39 | } | ||
| 40 | |||
| 41 | void EventInterface::UnregisterForSignal(Devices::nvhost_ctrl* device) { | ||
| 42 | std::unique_lock<std::mutex> lk(guard); | ||
| 43 | on_signal.remove(device); | ||
| 44 | } | ||
| 45 | |||
| 46 | void EventInterface::Signal(u32 syncpoint_id, u32 value) { | ||
| 47 | std::unique_lock<std::mutex> lk(guard); | ||
| 48 | for (auto* device : on_signal) { | ||
| 49 | device->SignalNvEvent(syncpoint_id, value); | ||
| 50 | } | ||
| 51 | } | ||
| 52 | |||
| 53 | Kernel::KEvent* EventInterface::CreateEvent(std::string name) { | 36 | Kernel::KEvent* EventInterface::CreateEvent(std::string name) { |
| 54 | Kernel::KEvent* new_event = module.service_context.CreateEvent(std::move(name)); | 37 | Kernel::KEvent* new_event = module.service_context.CreateEvent(std::move(name)); |
| 55 | return new_event; | 38 | return new_event; |
| @@ -221,10 +204,6 @@ NvResult Module::Close(DeviceFD fd) { | |||
| 221 | return NvResult::Success; | 204 | return NvResult::Success; |
| 222 | } | 205 | } |
| 223 | 206 | ||
| 224 | void Module::SignalSyncpt(const u32 syncpoint_id, const u32 value) { | ||
| 225 | events_interface.Signal(syncpoint_id, value); | ||
| 226 | } | ||
| 227 | |||
| 228 | NvResult Module::QueryEvent(DeviceFD fd, u32 event_id, Kernel::KEvent*& event) { | 207 | NvResult Module::QueryEvent(DeviceFD fd, u32 event_id, Kernel::KEvent*& event) { |
| 229 | if (fd < 0) { | 208 | if (fd < 0) { |
| 230 | LOG_ERROR(Service_NVDRV, "Invalid DeviceFD={}!", fd); | 209 | LOG_ERROR(Service_NVDRV, "Invalid DeviceFD={}!", fd); |
diff --git a/src/core/hle/service/nvdrv/nvdrv.h b/src/core/hle/service/nvdrv/nvdrv.h index 1fe98cf32..31c45236e 100644 --- a/src/core/hle/service/nvdrv/nvdrv.h +++ b/src/core/hle/service/nvdrv/nvdrv.h | |||
| @@ -49,11 +49,6 @@ public: | |||
| 49 | EventInterface(Module& module_); | 49 | EventInterface(Module& module_); |
| 50 | ~EventInterface(); | 50 | ~EventInterface(); |
| 51 | 51 | ||
| 52 | void RegisterForSignal(Devices::nvhost_ctrl*); | ||
| 53 | void UnregisterForSignal(Devices::nvhost_ctrl*); | ||
| 54 | |||
| 55 | void Signal(u32 syncpoint_id, u32 value); | ||
| 56 | |||
| 57 | Kernel::KEvent* CreateEvent(std::string name); | 52 | Kernel::KEvent* CreateEvent(std::string name); |
| 58 | 53 | ||
| 59 | void FreeEvent(Kernel::KEvent* event); | 54 | void FreeEvent(Kernel::KEvent* event); |
| @@ -96,8 +91,6 @@ public: | |||
| 96 | /// Closes a device file descriptor and returns operation success. | 91 | /// Closes a device file descriptor and returns operation success. |
| 97 | NvResult Close(DeviceFD fd); | 92 | NvResult Close(DeviceFD fd); |
| 98 | 93 | ||
| 99 | void SignalSyncpt(const u32 syncpoint_id, const u32 value); | ||
| 100 | |||
| 101 | NvResult QueryEvent(DeviceFD fd, u32 event_id, Kernel::KEvent*& event); | 94 | NvResult QueryEvent(DeviceFD fd, u32 event_id, Kernel::KEvent*& event); |
| 102 | 95 | ||
| 103 | private: | 96 | private: |
diff --git a/src/core/hle/service/nvdrv/nvdrv_interface.cpp b/src/core/hle/service/nvdrv/nvdrv_interface.cpp index bd41205b8..5e50a04e8 100644 --- a/src/core/hle/service/nvdrv/nvdrv_interface.cpp +++ b/src/core/hle/service/nvdrv/nvdrv_interface.cpp | |||
| @@ -15,10 +15,6 @@ | |||
| 15 | 15 | ||
| 16 | namespace Service::Nvidia { | 16 | namespace Service::Nvidia { |
| 17 | 17 | ||
| 18 | void NVDRV::SignalGPUInterruptSyncpt(const u32 syncpoint_id, const u32 value) { | ||
| 19 | nvdrv->SignalSyncpt(syncpoint_id, value); | ||
| 20 | } | ||
| 21 | |||
| 22 | void NVDRV::Open(Kernel::HLERequestContext& ctx) { | 18 | void NVDRV::Open(Kernel::HLERequestContext& ctx) { |
| 23 | LOG_DEBUG(Service_NVDRV, "called"); | 19 | LOG_DEBUG(Service_NVDRV, "called"); |
| 24 | IPC::ResponseBuilder rb{ctx, 4}; | 20 | IPC::ResponseBuilder rb{ctx, 4}; |
diff --git a/src/core/hle/service/nvdrv/nvdrv_interface.h b/src/core/hle/service/nvdrv/nvdrv_interface.h index cbd37b52b..cd58a4f35 100644 --- a/src/core/hle/service/nvdrv/nvdrv_interface.h +++ b/src/core/hle/service/nvdrv/nvdrv_interface.h | |||
| @@ -18,8 +18,6 @@ public: | |||
| 18 | explicit NVDRV(Core::System& system_, std::shared_ptr<Module> nvdrv_, const char* name); | 18 | explicit NVDRV(Core::System& system_, std::shared_ptr<Module> nvdrv_, const char* name); |
| 19 | ~NVDRV() override; | 19 | ~NVDRV() override; |
| 20 | 20 | ||
| 21 | void SignalGPUInterruptSyncpt(u32 syncpoint_id, u32 value); | ||
| 22 | |||
| 23 | private: | 21 | private: |
| 24 | void Open(Kernel::HLERequestContext& ctx); | 22 | void Open(Kernel::HLERequestContext& ctx); |
| 25 | void Ioctl1(Kernel::HLERequestContext& ctx); | 23 | void Ioctl1(Kernel::HLERequestContext& ctx); |