diff options
author | Fernando Sahmkow <fsahmkow27@gmail.com> | 2022-09-01 05:45:22 +0200 |
---|---|---|
committer | Fernando Sahmkow <fsahmkow27@gmail.com> | 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 yuzu-ca3db0d7c94a20668781830ff852dbf512598efb.tar.gz yuzu-ca3db0d7c94a20668781830ff852dbf512598efb.tar.bz2 yuzu-ca3db0d7c94a20668781830ff852dbf512598efb.tar.lz yuzu-ca3db0d7c94a20668781830ff852dbf512598efb.tar.xz yuzu-ca3db0d7c94a20668781830ff852dbf512598efb.tar.zst yuzu-ca3db0d7c94a20668781830ff852dbf512598efb.zip |
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 { class Host1x { public: - Host1x(Core::System& system); + explicit Host1x(Core::System& system); SyncpointManager& GetSyncpointManager() { 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)); SyncpointManager::ActionHandle SyncpointManager::RegisterAction( std::atomic<u32>& syncpoint, std::list<RegisteredAction>& action_storage, u32 expected_value, - std::function<void(void)>& action) { + std::function<void()>&& action) { if (syncpoint.load(std::memory_order_acquire) >= expected_value) { action(); return {}; } - std::unique_lock<std::mutex> lk(guard); + std::unique_lock lk(guard); if (syncpoint.load(std::memory_order_relaxed) >= expected_value) { action(); return {}; @@ -30,12 +30,12 @@ SyncpointManager::ActionHandle SyncpointManager::RegisterAction( } ++it; } - return action_storage.emplace(it, expected_value, action); + return action_storage.emplace(it, expected_value, std::move(action)); } void SyncpointManager::DeregisterAction(std::list<RegisteredAction>& action_storage, ActionHandle& handle) { - std::unique_lock<std::mutex> lk(guard); + std::unique_lock lk(guard); action_storage.erase(handle); } @@ -68,7 +68,7 @@ void SyncpointManager::Increment(std::atomic<u32>& syncpoint, std::condition_var std::list<RegisteredAction>& action_storage) { auto new_value{syncpoint.fetch_add(1, std::memory_order_acq_rel) + 1}; - std::unique_lock<std::mutex> lk(guard); + std::unique_lock lk(guard); auto it = action_storage.begin(); while (it != action_storage.end()) { if (it->expected_value > new_value) { @@ -87,7 +87,7 @@ void SyncpointManager::Wait(std::atomic<u32>& syncpoint, std::condition_variable return; } - std::unique_lock<std::mutex> lk(guard); + std::unique_lock lk(guard); wait_cv.wait(lk, pred); } 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 { class SyncpointManager { public: - u32 GetGuestSyncpointValue(u32 id) { + u32 GetGuestSyncpointValue(u32 id) const { return syncpoints_guest[id].load(std::memory_order_acquire); } - u32 GetHostSyncpointValue(u32 id) { + u32 GetHostSyncpointValue(u32 id) const { return syncpoints_host[id].load(std::memory_order_acquire); } struct RegisteredAction { - RegisteredAction(u32 expected_value_, std::function<void(void)>& action_) - : expected_value{expected_value_}, action{action_} {} + explicit RegisteredAction(u32 expected_value_, std::function<void()>&& action_) + : expected_value{expected_value_}, action{std::move(action_)} {} u32 expected_value; - std::function<void(void)> action; + std::function<void()> action; }; using ActionHandle = std::list<RegisteredAction>::iterator; template <typename Func> ActionHandle RegisterGuestAction(u32 syncpoint_id, u32 expected_value, Func&& action) { - std::function<void(void)> func(action); + std::function<void()> func(action); return RegisterAction(syncpoints_guest[syncpoint_id], guest_action_storage[syncpoint_id], - expected_value, func); + expected_value, std::move(func)); } template <typename Func> ActionHandle RegisterHostAction(u32 syncpoint_id, u32 expected_value, Func&& action) { - std::function<void(void)> func(action); + std::function<void()> func(action); return RegisterAction(syncpoints_host[syncpoint_id], host_action_storage[syncpoint_id], - expected_value, func); + expected_value, std::move(func)); } void DeregisterGuestAction(u32 syncpoint_id, ActionHandle& handle); @@ -60,11 +60,11 @@ public: void WaitHost(u32 syncpoint_id, u32 expected_value); - bool IsReadyGuest(u32 syncpoint_id, u32 expected_value) { + bool IsReadyGuest(u32 syncpoint_id, u32 expected_value) const { return syncpoints_guest[syncpoint_id].load(std::memory_order_acquire) >= expected_value; } - bool IsReadyHost(u32 syncpoint_id, u32 expected_value) { + bool IsReadyHost(u32 syncpoint_id, u32 expected_value) const { return syncpoints_host[syncpoint_id].load(std::memory_order_acquire) >= expected_value; } @@ -74,7 +74,7 @@ private: ActionHandle RegisterAction(std::atomic<u32>& syncpoint, std::list<RegisteredAction>& action_storage, u32 expected_value, - std::function<void(void)>& action); + std::function<void()>&& action); void DeregisterAction(std::list<RegisteredAction>& action_storage, ActionHandle& handle); |