diff options
| author | 2020-10-26 22:04:13 -0700 | |
|---|---|---|
| committer | 2020-11-01 01:52:37 -0700 | |
| commit | 66edfd61c67182761dacadf3c45011702b47c071 (patch) | |
| tree | b5e3b957d8225f2695c4ddbdfdaf95273c4e7f6e /src/core | |
| parent | hle service: nvdrv: Update to instantiate SyncpointManager. (diff) | |
| download | yuzu-66edfd61c67182761dacadf3c45011702b47c071.tar.gz yuzu-66edfd61c67182761dacadf3c45011702b47c071.tar.xz yuzu-66edfd61c67182761dacadf3c45011702b47c071.zip | |
hle service: nvdrv: nvhost_ctrl: Update to use SyncpointManager.
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp | 33 | ||||
| -rw-r--r-- | src/core/hle/service/nvdrv/devices/nvhost_ctrl.h | 4 | ||||
| -rw-r--r-- | src/core/hle/service/nvdrv/nvdrv.cpp | 3 |
3 files changed, 31 insertions, 9 deletions
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp index 75d9191ff..8356a8139 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp | |||
| @@ -15,8 +15,9 @@ | |||
| 15 | 15 | ||
| 16 | namespace Service::Nvidia::Devices { | 16 | namespace Service::Nvidia::Devices { |
| 17 | 17 | ||
| 18 | nvhost_ctrl::nvhost_ctrl(Core::System& system, EventInterface& events_interface) | 18 | nvhost_ctrl::nvhost_ctrl(Core::System& system, EventInterface& events_interface, |
| 19 | : nvdevice(system), events_interface{events_interface} {} | 19 | SyncpointManager& syncpoint_manager) |
| 20 | : nvdevice(system), events_interface{events_interface}, syncpoint_manager{syncpoint_manager} {} | ||
| 20 | nvhost_ctrl::~nvhost_ctrl() = default; | 21 | nvhost_ctrl::~nvhost_ctrl() = default; |
| 21 | 22 | ||
| 22 | u32 nvhost_ctrl::ioctl(Ioctl command, const std::vector<u8>& input, const std::vector<u8>& input2, | 23 | u32 nvhost_ctrl::ioctl(Ioctl command, const std::vector<u8>& input, const std::vector<u8>& input2, |
| @@ -70,19 +71,33 @@ u32 nvhost_ctrl::IocCtrlEventWait(const std::vector<u8>& input, std::vector<u8>& | |||
| 70 | return NvResult::BadParameter; | 71 | return NvResult::BadParameter; |
| 71 | } | 72 | } |
| 72 | 73 | ||
| 74 | if (syncpoint_manager.IsSyncpointExpired(params.syncpt_id, params.threshold)) { | ||
| 75 | params.value = syncpoint_manager.GetSyncpointMin(params.syncpt_id); | ||
| 76 | std::memcpy(output.data(), ¶ms, sizeof(params)); | ||
| 77 | return NvResult::Success; | ||
| 78 | } | ||
| 79 | |||
| 80 | if (const auto new_value = syncpoint_manager.RefreshSyncpoint(params.syncpt_id); | ||
| 81 | syncpoint_manager.IsSyncpointExpired(params.syncpt_id, params.threshold)) { | ||
| 82 | params.value = new_value; | ||
| 83 | std::memcpy(output.data(), ¶ms, sizeof(params)); | ||
| 84 | return NvResult::Success; | ||
| 85 | } | ||
| 86 | |||
| 73 | auto event = events_interface.events[event_id]; | 87 | auto event = events_interface.events[event_id]; |
| 74 | auto& gpu = system.GPU(); | 88 | auto& gpu = system.GPU(); |
| 89 | |||
| 75 | // This is mostly to take into account unimplemented features. As synced | 90 | // This is mostly to take into account unimplemented features. As synced |
| 76 | // gpu is always synced. | 91 | // gpu is always synced. |
| 77 | if (!gpu.IsAsync()) { | 92 | if (!gpu.IsAsync()) { |
| 78 | event.writable->Signal(); | 93 | event.event.writable->Signal(); |
| 79 | return NvResult::Success; | 94 | return NvResult::Success; |
| 80 | } | 95 | } |
| 81 | auto lock = gpu.LockSync(); | 96 | auto lock = gpu.LockSync(); |
| 82 | const u32 current_syncpoint_value = gpu.GetSyncpointValue(params.syncpt_id); | 97 | const u32 current_syncpoint_value = event.fence.value; |
| 83 | const s32 diff = current_syncpoint_value - params.threshold; | 98 | const s32 diff = current_syncpoint_value - params.threshold; |
| 84 | if (diff >= 0) { | 99 | if (diff >= 0) { |
| 85 | event.writable->Signal(); | 100 | event.event.writable->Signal(); |
| 86 | params.value = current_syncpoint_value; | 101 | params.value = current_syncpoint_value; |
| 87 | std::memcpy(output.data(), ¶ms, sizeof(params)); | 102 | std::memcpy(output.data(), ¶ms, sizeof(params)); |
| 88 | return NvResult::Success; | 103 | return NvResult::Success; |
| @@ -109,7 +124,7 @@ u32 nvhost_ctrl::IocCtrlEventWait(const std::vector<u8>& input, std::vector<u8>& | |||
| 109 | params.value = ((params.syncpt_id & 0xfff) << 16) | 0x10000000; | 124 | params.value = ((params.syncpt_id & 0xfff) << 16) | 0x10000000; |
| 110 | } | 125 | } |
| 111 | params.value |= event_id; | 126 | params.value |= event_id; |
| 112 | event.writable->Clear(); | 127 | event.event.writable->Clear(); |
| 113 | gpu.RegisterSyncptInterrupt(params.syncpt_id, target_value); | 128 | gpu.RegisterSyncptInterrupt(params.syncpt_id, target_value); |
| 114 | if (!is_async && ctrl.fresh_call) { | 129 | if (!is_async && ctrl.fresh_call) { |
| 115 | ctrl.must_delay = true; | 130 | ctrl.must_delay = true; |
| @@ -157,15 +172,19 @@ u32 nvhost_ctrl::IocCtrlEventUnregister(const std::vector<u8>& input, std::vecto | |||
| 157 | u32 nvhost_ctrl::IocCtrlClearEventWait(const std::vector<u8>& input, std::vector<u8>& output) { | 172 | u32 nvhost_ctrl::IocCtrlClearEventWait(const std::vector<u8>& input, std::vector<u8>& output) { |
| 158 | IocCtrlEventSignalParams params{}; | 173 | IocCtrlEventSignalParams params{}; |
| 159 | std::memcpy(¶ms, input.data(), sizeof(params)); | 174 | std::memcpy(¶ms, input.data(), sizeof(params)); |
| 175 | |||
| 160 | u32 event_id = params.event_id & 0x00FF; | 176 | u32 event_id = params.event_id & 0x00FF; |
| 161 | LOG_WARNING(Service_NVDRV, "cleared event wait on, event_id: {:X}", event_id); | 177 | LOG_WARNING(Service_NVDRV, "cleared event wait on, event_id: {:X}", event_id); |
| 178 | |||
| 162 | if (event_id >= MaxNvEvents) { | 179 | if (event_id >= MaxNvEvents) { |
| 163 | return NvResult::BadParameter; | 180 | return NvResult::BadParameter; |
| 164 | } | 181 | } |
| 165 | if (events_interface.status[event_id] == EventState::Waiting) { | 182 | if (events_interface.status[event_id] == EventState::Waiting) { |
| 166 | events_interface.LiberateEvent(event_id); | 183 | events_interface.LiberateEvent(event_id); |
| 167 | events_interface.events[event_id].writable->Signal(); | ||
| 168 | } | 184 | } |
| 185 | |||
| 186 | syncpoint_manager.RefreshSyncpoint(events_interface.events[event_id].fence.id); | ||
| 187 | |||
| 169 | return NvResult::Success; | 188 | return NvResult::Success; |
| 170 | } | 189 | } |
| 171 | 190 | ||
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.h b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.h index f7b04d9f1..24ad96cb9 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.h +++ b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.h | |||
| @@ -14,7 +14,8 @@ namespace Service::Nvidia::Devices { | |||
| 14 | 14 | ||
| 15 | class nvhost_ctrl final : public nvdevice { | 15 | class nvhost_ctrl final : public nvdevice { |
| 16 | public: | 16 | public: |
| 17 | explicit nvhost_ctrl(Core::System& system, EventInterface& events_interface); | 17 | explicit nvhost_ctrl(Core::System& system, EventInterface& events_interface, |
| 18 | SyncpointManager& syncpoint_manager); | ||
| 18 | ~nvhost_ctrl() override; | 19 | ~nvhost_ctrl() override; |
| 19 | 20 | ||
| 20 | u32 ioctl(Ioctl command, const std::vector<u8>& input, const std::vector<u8>& input2, | 21 | u32 ioctl(Ioctl command, const std::vector<u8>& input, const std::vector<u8>& input2, |
| @@ -145,6 +146,7 @@ private: | |||
| 145 | u32 IocCtrlClearEventWait(const std::vector<u8>& input, std::vector<u8>& output); | 146 | u32 IocCtrlClearEventWait(const std::vector<u8>& input, std::vector<u8>& output); |
| 146 | 147 | ||
| 147 | EventInterface& events_interface; | 148 | EventInterface& events_interface; |
| 149 | SyncpointManager& syncpoint_manager; | ||
| 148 | }; | 150 | }; |
| 149 | 151 | ||
| 150 | } // namespace Service::Nvidia::Devices | 152 | } // namespace Service::Nvidia::Devices |
diff --git a/src/core/hle/service/nvdrv/nvdrv.cpp b/src/core/hle/service/nvdrv/nvdrv.cpp index 26c1bf751..2e52f8bd6 100644 --- a/src/core/hle/service/nvdrv/nvdrv.cpp +++ b/src/core/hle/service/nvdrv/nvdrv.cpp | |||
| @@ -51,7 +51,8 @@ Module::Module(Core::System& system) : syncpoint_manager{system.GPU()} { | |||
| 51 | devices["/dev/nvhost-ctrl-gpu"] = std::make_shared<Devices::nvhost_ctrl_gpu>(system); | 51 | devices["/dev/nvhost-ctrl-gpu"] = std::make_shared<Devices::nvhost_ctrl_gpu>(system); |
| 52 | devices["/dev/nvmap"] = nvmap_dev; | 52 | devices["/dev/nvmap"] = nvmap_dev; |
| 53 | devices["/dev/nvdisp_disp0"] = std::make_shared<Devices::nvdisp_disp0>(system, nvmap_dev); | 53 | devices["/dev/nvdisp_disp0"] = std::make_shared<Devices::nvdisp_disp0>(system, nvmap_dev); |
| 54 | devices["/dev/nvhost-ctrl"] = std::make_shared<Devices::nvhost_ctrl>(system, events_interface); | 54 | devices["/dev/nvhost-ctrl"] = |
| 55 | std::make_shared<Devices::nvhost_ctrl>(system, events_interface, syncpoint_manager); | ||
| 55 | devices["/dev/nvhost-nvdec"] = std::make_shared<Devices::nvhost_nvdec>(system, nvmap_dev); | 56 | devices["/dev/nvhost-nvdec"] = std::make_shared<Devices::nvhost_nvdec>(system, nvmap_dev); |
| 56 | devices["/dev/nvhost-nvjpg"] = std::make_shared<Devices::nvhost_nvjpg>(system); | 57 | devices["/dev/nvhost-nvjpg"] = std::make_shared<Devices::nvhost_nvjpg>(system); |
| 57 | devices["/dev/nvhost-vic"] = std::make_shared<Devices::nvhost_vic>(system, nvmap_dev); | 58 | devices["/dev/nvhost-vic"] = std::make_shared<Devices::nvhost_vic>(system, nvmap_dev); |