summaryrefslogtreecommitdiffstats
path: root/src/core/hle/service/nvdrv/syncpoint_manager.cpp
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2020-10-27 05:45:08 +0100
committerbunnei <bunneidev@gmail.com>2020-11-01 09:51:54 +0100
commitd567b7e841558a367e37d64b032b3492ed4d5cf4 (patch)
tree54d35c59ce52b9dead92f7a08b397278d92c2cbc /src/core/hle/service/nvdrv/syncpoint_manager.cpp
parentRename to align with switchbrew and remove gpu function (#4714) (diff)
downloadyuzu-d567b7e841558a367e37d64b032b3492ed4d5cf4.tar
yuzu-d567b7e841558a367e37d64b032b3492ed4d5cf4.tar.gz
yuzu-d567b7e841558a367e37d64b032b3492ed4d5cf4.tar.bz2
yuzu-d567b7e841558a367e37d64b032b3492ed4d5cf4.tar.lz
yuzu-d567b7e841558a367e37d64b032b3492ed4d5cf4.tar.xz
yuzu-d567b7e841558a367e37d64b032b3492ed4d5cf4.tar.zst
yuzu-d567b7e841558a367e37d64b032b3492ed4d5cf4.zip
Diffstat (limited to 'src/core/hle/service/nvdrv/syncpoint_manager.cpp')
-rw-r--r--src/core/hle/service/nvdrv/syncpoint_manager.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/core/hle/service/nvdrv/syncpoint_manager.cpp b/src/core/hle/service/nvdrv/syncpoint_manager.cpp
new file mode 100644
index 000000000..0151a03b7
--- /dev/null
+++ b/src/core/hle/service/nvdrv/syncpoint_manager.cpp
@@ -0,0 +1,39 @@
+// Copyright 2020 yuzu emulator team
+// Licensed under GPLv2 or any later version
+// Refer to the license.txt file included.
+
+#include "common/assert.h"
+#include "core/hle/service/nvdrv/syncpoint_manager.h"
+#include "video_core/gpu.h"
+
+namespace Service::Nvidia {
+
+SyncpointManager::SyncpointManager(Tegra::GPU& gpu) : gpu{gpu} {}
+
+SyncpointManager::~SyncpointManager() = default;
+
+u32 SyncpointManager::RefreshSyncpoint(u32 syncpoint_id) {
+ syncpoints[syncpoint_id].min = gpu.GetSyncpointValue(syncpoint_id);
+ return GetSyncpointMin(syncpoint_id);
+}
+
+u32 SyncpointManager::AllocateSyncpoint() {
+ for (u32 syncpoint_id = 1; syncpoint_id < MaxSyncPoints; syncpoint_id++) {
+ if (!syncpoints[syncpoint_id].is_allocated) {
+ syncpoints[syncpoint_id].is_allocated = true;
+ return syncpoint_id;
+ }
+ }
+ UNREACHABLE_MSG("No more available syncpoints!");
+ return {};
+}
+
+u32 SyncpointManager::IncreaseSyncpoint(u32 syncpoint_id, u32 value) {
+ for (u32 index = 0; index < value; ++index) {
+ syncpoints[syncpoint_id].max.fetch_add(1, std::memory_order_relaxed);
+ }
+
+ return GetSyncpointMax(syncpoint_id);
+}
+
+} // namespace Service::Nvidia