diff options
| author | 2022-09-01 05:45:22 +0200 | |
|---|---|---|
| committer | 2022-10-06 21:00:54 +0200 | |
| commit | ca3db0d7c94a20668781830ff852dbf512598efb (patch) | |
| tree | edd20d669000e980169db27a896adc09078ceeaa /src/video_core/host1x | |
| parent | state_tracker: workaround channel setup for homebrew (diff) | |
| download | yuzu-ca3db0d7c94a20668781830ff852dbf512598efb.tar.gz yuzu-ca3db0d7c94a20668781830ff852dbf512598efb.tar.xz yuzu-ca3db0d7c94a20668781830ff852dbf512598efb.zip | |
General: address feedback
Diffstat (limited to 'src/video_core/host1x')
| -rw-r--r-- | src/video_core/host1x/host1x.h | 2 | ||||
| -rw-r--r-- | src/video_core/host1x/syncpoint_manager.cpp | 12 | ||||
| -rw-r--r-- | src/video_core/host1x/syncpoint_manager.h | 24 |
3 files changed, 19 insertions, 19 deletions
diff --git a/src/video_core/host1x/host1x.h b/src/video_core/host1x/host1x.h index 7ecf853d9..57082ae54 100644 --- a/src/video_core/host1x/host1x.h +++ b/src/video_core/host1x/host1x.h | |||
| @@ -19,7 +19,7 @@ namespace Host1x { | |||
| 19 | 19 | ||
| 20 | class Host1x { | 20 | class Host1x { |
| 21 | public: | 21 | public: |
| 22 | Host1x(Core::System& system); | 22 | explicit Host1x(Core::System& system); |
| 23 | 23 | ||
| 24 | SyncpointManager& GetSyncpointManager() { | 24 | SyncpointManager& GetSyncpointManager() { |
| 25 | return syncpoint_manager; | 25 | return syncpoint_manager; |
diff --git a/src/video_core/host1x/syncpoint_manager.cpp b/src/video_core/host1x/syncpoint_manager.cpp index 4471bacae..326e8355a 100644 --- a/src/video_core/host1x/syncpoint_manager.cpp +++ b/src/video_core/host1x/syncpoint_manager.cpp | |||
| @@ -12,13 +12,13 @@ MICROPROFILE_DEFINE(GPU_wait, "GPU", "Wait for the GPU", MP_RGB(128, 128, 192)); | |||
| 12 | 12 | ||
| 13 | SyncpointManager::ActionHandle SyncpointManager::RegisterAction( | 13 | SyncpointManager::ActionHandle SyncpointManager::RegisterAction( |
| 14 | std::atomic<u32>& syncpoint, std::list<RegisteredAction>& action_storage, u32 expected_value, | 14 | std::atomic<u32>& syncpoint, std::list<RegisteredAction>& action_storage, u32 expected_value, |
| 15 | std::function<void(void)>& action) { | 15 | std::function<void()>&& action) { |
| 16 | if (syncpoint.load(std::memory_order_acquire) >= expected_value) { | 16 | if (syncpoint.load(std::memory_order_acquire) >= expected_value) { |
| 17 | action(); | 17 | action(); |
| 18 | return {}; | 18 | return {}; |
| 19 | } | 19 | } |
| 20 | 20 | ||
| 21 | std::unique_lock<std::mutex> lk(guard); | 21 | std::unique_lock lk(guard); |
| 22 | if (syncpoint.load(std::memory_order_relaxed) >= expected_value) { | 22 | if (syncpoint.load(std::memory_order_relaxed) >= expected_value) { |
| 23 | action(); | 23 | action(); |
| 24 | return {}; | 24 | return {}; |
| @@ -30,12 +30,12 @@ SyncpointManager::ActionHandle SyncpointManager::RegisterAction( | |||
| 30 | } | 30 | } |
| 31 | ++it; | 31 | ++it; |
| 32 | } | 32 | } |
| 33 | return action_storage.emplace(it, expected_value, action); | 33 | return action_storage.emplace(it, expected_value, std::move(action)); |
| 34 | } | 34 | } |
| 35 | 35 | ||
| 36 | void SyncpointManager::DeregisterAction(std::list<RegisteredAction>& action_storage, | 36 | void SyncpointManager::DeregisterAction(std::list<RegisteredAction>& action_storage, |
| 37 | ActionHandle& handle) { | 37 | ActionHandle& handle) { |
| 38 | std::unique_lock<std::mutex> lk(guard); | 38 | std::unique_lock lk(guard); |
| 39 | action_storage.erase(handle); | 39 | action_storage.erase(handle); |
| 40 | } | 40 | } |
| 41 | 41 | ||
| @@ -68,7 +68,7 @@ void SyncpointManager::Increment(std::atomic<u32>& syncpoint, std::condition_var | |||
| 68 | std::list<RegisteredAction>& action_storage) { | 68 | std::list<RegisteredAction>& action_storage) { |
| 69 | auto new_value{syncpoint.fetch_add(1, std::memory_order_acq_rel) + 1}; | 69 | auto new_value{syncpoint.fetch_add(1, std::memory_order_acq_rel) + 1}; |
| 70 | 70 | ||
| 71 | std::unique_lock<std::mutex> lk(guard); | 71 | std::unique_lock lk(guard); |
| 72 | auto it = action_storage.begin(); | 72 | auto it = action_storage.begin(); |
| 73 | while (it != action_storage.end()) { | 73 | while (it != action_storage.end()) { |
| 74 | if (it->expected_value > new_value) { | 74 | if (it->expected_value > new_value) { |
| @@ -87,7 +87,7 @@ void SyncpointManager::Wait(std::atomic<u32>& syncpoint, std::condition_variable | |||
| 87 | return; | 87 | return; |
| 88 | } | 88 | } |
| 89 | 89 | ||
| 90 | std::unique_lock<std::mutex> lk(guard); | 90 | std::unique_lock lk(guard); |
| 91 | wait_cv.wait(lk, pred); | 91 | wait_cv.wait(lk, pred); |
| 92 | } | 92 | } |
| 93 | 93 | ||
diff --git a/src/video_core/host1x/syncpoint_manager.h b/src/video_core/host1x/syncpoint_manager.h index 72220a09a..50a264e23 100644 --- a/src/video_core/host1x/syncpoint_manager.h +++ b/src/video_core/host1x/syncpoint_manager.h | |||
| @@ -18,34 +18,34 @@ namespace Host1x { | |||
| 18 | 18 | ||
| 19 | class SyncpointManager { | 19 | class SyncpointManager { |
| 20 | public: | 20 | public: |
| 21 | u32 GetGuestSyncpointValue(u32 id) { | 21 | u32 GetGuestSyncpointValue(u32 id) const { |
| 22 | return syncpoints_guest[id].load(std::memory_order_acquire); | 22 | return syncpoints_guest[id].load(std::memory_order_acquire); |
| 23 | } | 23 | } |
| 24 | 24 | ||
| 25 | u32 GetHostSyncpointValue(u32 id) { | 25 | u32 GetHostSyncpointValue(u32 id) const { |
| 26 | return syncpoints_host[id].load(std::memory_order_acquire); | 26 | return syncpoints_host[id].load(std::memory_order_acquire); |
| 27 | } | 27 | } |
| 28 | 28 | ||
| 29 | struct RegisteredAction { | 29 | struct RegisteredAction { |
| 30 | RegisteredAction(u32 expected_value_, std::function<void(void)>& action_) | 30 | explicit RegisteredAction(u32 expected_value_, std::function<void()>&& action_) |
| 31 | : expected_value{expected_value_}, action{action_} {} | 31 | : expected_value{expected_value_}, action{std::move(action_)} {} |
| 32 | u32 expected_value; | 32 | u32 expected_value; |
| 33 | std::function<void(void)> action; | 33 | std::function<void()> action; |
| 34 | }; | 34 | }; |
| 35 | using ActionHandle = std::list<RegisteredAction>::iterator; | 35 | using ActionHandle = std::list<RegisteredAction>::iterator; |
| 36 | 36 | ||
| 37 | template <typename Func> | 37 | template <typename Func> |
| 38 | ActionHandle RegisterGuestAction(u32 syncpoint_id, u32 expected_value, Func&& action) { | 38 | ActionHandle RegisterGuestAction(u32 syncpoint_id, u32 expected_value, Func&& action) { |
| 39 | std::function<void(void)> func(action); | 39 | std::function<void()> func(action); |
| 40 | return RegisterAction(syncpoints_guest[syncpoint_id], guest_action_storage[syncpoint_id], | 40 | return RegisterAction(syncpoints_guest[syncpoint_id], guest_action_storage[syncpoint_id], |
| 41 | expected_value, func); | 41 | expected_value, std::move(func)); |
| 42 | } | 42 | } |
| 43 | 43 | ||
| 44 | template <typename Func> | 44 | template <typename Func> |
| 45 | ActionHandle RegisterHostAction(u32 syncpoint_id, u32 expected_value, Func&& action) { | 45 | ActionHandle RegisterHostAction(u32 syncpoint_id, u32 expected_value, Func&& action) { |
| 46 | std::function<void(void)> func(action); | 46 | std::function<void()> func(action); |
| 47 | return RegisterAction(syncpoints_host[syncpoint_id], host_action_storage[syncpoint_id], | 47 | return RegisterAction(syncpoints_host[syncpoint_id], host_action_storage[syncpoint_id], |
| 48 | expected_value, func); | 48 | expected_value, std::move(func)); |
| 49 | } | 49 | } |
| 50 | 50 | ||
| 51 | void DeregisterGuestAction(u32 syncpoint_id, ActionHandle& handle); | 51 | void DeregisterGuestAction(u32 syncpoint_id, ActionHandle& handle); |
| @@ -60,11 +60,11 @@ public: | |||
| 60 | 60 | ||
| 61 | void WaitHost(u32 syncpoint_id, u32 expected_value); | 61 | void WaitHost(u32 syncpoint_id, u32 expected_value); |
| 62 | 62 | ||
| 63 | bool IsReadyGuest(u32 syncpoint_id, u32 expected_value) { | 63 | bool IsReadyGuest(u32 syncpoint_id, u32 expected_value) const { |
| 64 | return syncpoints_guest[syncpoint_id].load(std::memory_order_acquire) >= expected_value; | 64 | return syncpoints_guest[syncpoint_id].load(std::memory_order_acquire) >= expected_value; |
| 65 | } | 65 | } |
| 66 | 66 | ||
| 67 | bool IsReadyHost(u32 syncpoint_id, u32 expected_value) { | 67 | bool IsReadyHost(u32 syncpoint_id, u32 expected_value) const { |
| 68 | return syncpoints_host[syncpoint_id].load(std::memory_order_acquire) >= expected_value; | 68 | return syncpoints_host[syncpoint_id].load(std::memory_order_acquire) >= expected_value; |
| 69 | } | 69 | } |
| 70 | 70 | ||
| @@ -74,7 +74,7 @@ private: | |||
| 74 | 74 | ||
| 75 | ActionHandle RegisterAction(std::atomic<u32>& syncpoint, | 75 | ActionHandle RegisterAction(std::atomic<u32>& syncpoint, |
| 76 | std::list<RegisteredAction>& action_storage, u32 expected_value, | 76 | std::list<RegisteredAction>& action_storage, u32 expected_value, |
| 77 | std::function<void(void)>& action); | 77 | std::function<void()>&& action); |
| 78 | 78 | ||
| 79 | void DeregisterAction(std::list<RegisteredAction>& action_storage, ActionHandle& handle); | 79 | void DeregisterAction(std::list<RegisteredAction>& action_storage, ActionHandle& handle); |
| 80 | 80 | ||