syncpoint_manager.cpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. // SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. #include "common/assert.h"
  4. #include "core/hle/service/nvdrv/syncpoint_manager.h"
  5. #include "video_core/gpu.h"
  6. namespace Service::Nvidia {
  7. SyncpointManager::SyncpointManager(Tegra::GPU& gpu_) : gpu{gpu_} {}
  8. SyncpointManager::~SyncpointManager() = default;
  9. u32 SyncpointManager::RefreshSyncpoint(u32 syncpoint_id) {
  10. syncpoints[syncpoint_id].min = gpu.GetSyncpointValue(syncpoint_id);
  11. return GetSyncpointMin(syncpoint_id);
  12. }
  13. u32 SyncpointManager::AllocateSyncpoint() {
  14. for (u32 syncpoint_id = 1; syncpoint_id < MaxSyncPoints; syncpoint_id++) {
  15. if (!syncpoints[syncpoint_id].is_allocated) {
  16. syncpoints[syncpoint_id].is_allocated = true;
  17. return syncpoint_id;
  18. }
  19. }
  20. ASSERT_MSG(false, "No more available syncpoints!");
  21. return {};
  22. }
  23. u32 SyncpointManager::IncreaseSyncpoint(u32 syncpoint_id, u32 value) {
  24. for (u32 index = 0; index < value; ++index) {
  25. syncpoints[syncpoint_id].max.fetch_add(1, std::memory_order_relaxed);
  26. }
  27. return GetSyncpointMax(syncpoint_id);
  28. }
  29. } // namespace Service::Nvidia