summaryrefslogtreecommitdiffstats
path: root/src/video_core/shader_notify.cpp
diff options
context:
space:
mode:
authorDavid Marcec <dmarcecguzman@gmail.com>2020-07-10 05:36:38 +0200
committerDavid Marcec <dmarcecguzman@gmail.com>2020-07-17 06:24:57 +0200
commit468bd9c1b0f9e74f7c096b127a94a94e4ed7caec (patch)
tree50a0f28b7c817222247369400bedf5de1ccc4e19 /src/video_core/shader_notify.cpp
parentMerge pull request #4347 from lioncash/logging (diff)
downloadyuzu-468bd9c1b0f9e74f7c096b127a94a94e4ed7caec.tar
yuzu-468bd9c1b0f9e74f7c096b127a94a94e4ed7caec.tar.gz
yuzu-468bd9c1b0f9e74f7c096b127a94a94e4ed7caec.tar.bz2
yuzu-468bd9c1b0f9e74f7c096b127a94a94e4ed7caec.tar.lz
yuzu-468bd9c1b0f9e74f7c096b127a94a94e4ed7caec.tar.xz
yuzu-468bd9c1b0f9e74f7c096b127a94a94e4ed7caec.tar.zst
yuzu-468bd9c1b0f9e74f7c096b127a94a94e4ed7caec.zip
Diffstat (limited to '')
-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 @@
+// Copyright 2020 yuzu Emulator Project
+// Licensed under GPLv2 or any later version
+// Refer to the license.txt file included.
+
+#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