summaryrefslogtreecommitdiff
path: root/src/video_core/shader_notify.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/video_core/shader_notify.cpp')
-rw-r--r--src/video_core/shader_notify.cpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/video_core/shader_notify.cpp b/src/video_core/shader_notify.cpp
new file mode 100644
index 000000000..46fd0baae
--- /dev/null
+++ b/src/video_core/shader_notify.cpp
@@ -0,0 +1,42 @@
1// Copyright 2020 yuzu Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#include "video_core/shader_notify.h"
6
7using namespace std::chrono_literals;
8
9namespace VideoCore {
10namespace {
11constexpr auto UPDATE_TICK = 32ms;
12}
13
14ShaderNotify::ShaderNotify() = default;
15ShaderNotify::~ShaderNotify() = default;
16
17std::size_t ShaderNotify::GetShadersBuilding() {
18 const auto now = std::chrono::high_resolution_clock::now();
19 const auto diff = now - last_update;
20 if (diff > UPDATE_TICK) {
21 std::shared_lock lock(mutex);
22 last_updated_count = accurate_count;
23 }
24 return last_updated_count;
25}
26
27std::size_t ShaderNotify::GetShadersBuildingAccurate() {
28 std::shared_lock lock(mutex);
29 return accurate_count;
30}
31
32void ShaderNotify::MarkShaderComplete() {
33 std::unique_lock lock(mutex);
34 accurate_count--;
35}
36
37void ShaderNotify::MarkSharderBuilding() {
38 std::unique_lock lock(mutex);
39 accurate_count++;
40}
41
42} // namespace VideoCore