shader_notify.cpp 1017 B

12345678910111213141516171819202122232425262728293031323334
  1. // SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. #include <atomic>
  4. #include <chrono>
  5. #include "video_core/shader_notify.h"
  6. using namespace std::chrono_literals;
  7. namespace VideoCore {
  8. const auto TIME_TO_STOP_REPORTING = 2s;
  9. int ShaderNotify::ShadersBuilding() noexcept {
  10. const int now_complete = num_complete.load(std::memory_order::relaxed);
  11. const int now_building = num_building.load(std::memory_order::relaxed);
  12. if (now_complete == now_building) {
  13. const auto now = std::chrono::steady_clock::now();
  14. if (completed && num_complete == num_when_completed) {
  15. if (now - complete_time > TIME_TO_STOP_REPORTING) {
  16. report_base = now_complete;
  17. completed = false;
  18. }
  19. } else {
  20. completed = true;
  21. num_when_completed = num_complete;
  22. complete_time = now;
  23. }
  24. }
  25. return now_building - report_base;
  26. }
  27. } // namespace VideoCore