shader_notify.cpp 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // Copyright 2020 yuzu Emulator Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #include <mutex>
  5. #include "video_core/shader_notify.h"
  6. using namespace std::chrono_literals;
  7. namespace VideoCore {
  8. namespace {
  9. constexpr auto UPDATE_TICK = 32ms;
  10. }
  11. ShaderNotify::ShaderNotify() = default;
  12. ShaderNotify::~ShaderNotify() = default;
  13. std::size_t ShaderNotify::GetShadersBuilding() {
  14. const auto now = std::chrono::high_resolution_clock::now();
  15. const auto diff = now - last_update;
  16. if (diff > UPDATE_TICK) {
  17. std::shared_lock lock(mutex);
  18. last_updated_count = accurate_count;
  19. }
  20. return last_updated_count;
  21. }
  22. std::size_t ShaderNotify::GetShadersBuildingAccurate() {
  23. std::shared_lock lock{mutex};
  24. return accurate_count;
  25. }
  26. void ShaderNotify::MarkShaderComplete() {
  27. std::unique_lock lock{mutex};
  28. accurate_count--;
  29. }
  30. void ShaderNotify::MarkSharderBuilding() {
  31. std::unique_lock lock{mutex};
  32. accurate_count++;
  33. }
  34. } // namespace VideoCore