shader_notify.cpp 1017 B

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