suyu/src/video_core/shader_notify.cpp
Jan Beich 1841ca4b9b video_core: add missing header after 468bd9c1b0
src/video_core/shader_notify.cpp: In member function 'void VideoCore::ShaderNotify::MarkShaderComplete()':
src/video_core/shader_notify.cpp:33:10: error: 'unique_lock' is not a member of 'std'
   33 |     std::unique_lock lock{mutex};
      |          ^~~~~~~~~~~
src/video_core/shader_notify.cpp:6:1: note: 'std::unique_lock' is defined in header '<mutex>'; did you forget to '#include <mutex>'?
    5 | #include "video_core/shader_notify.h"
  +++ |+#include <mutex>
    6 |
src/video_core/shader_notify.cpp: In member function 'void VideoCore::ShaderNotify::MarkSharderBuilding()':
src/video_core/shader_notify.cpp:38:10: error: 'unique_lock' is not a member of 'std'
   38 |     std::unique_lock lock{mutex};
      |          ^~~~~~~~~~~
src/video_core/shader_notify.cpp:38:10: note: 'std::unique_lock' is defined in header '<mutex>'; did you forget to '#include <mutex>'?
2021-02-23 00:04:36 +00:00

43 lines
1 KiB
C++

// Copyright 2020 yuzu Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include <mutex>
#include "video_core/shader_notify.h"
using namespace std::chrono_literals;
namespace VideoCore {
namespace {
constexpr auto UPDATE_TICK = 32ms;
}
ShaderNotify::ShaderNotify() = default;
ShaderNotify::~ShaderNotify() = default;
std::size_t ShaderNotify::GetShadersBuilding() {
const auto now = std::chrono::high_resolution_clock::now();
const auto diff = now - last_update;
if (diff > UPDATE_TICK) {
std::shared_lock lock(mutex);
last_updated_count = accurate_count;
}
return last_updated_count;
}
std::size_t ShaderNotify::GetShadersBuildingAccurate() {
std::shared_lock lock{mutex};
return accurate_count;
}
void ShaderNotify::MarkShaderComplete() {
std::unique_lock lock{mutex};
accurate_count--;
}
void ShaderNotify::MarkSharderBuilding() {
std::unique_lock lock{mutex};
accurate_count++;
}
} // namespace VideoCore