diff options
| author | 2020-07-10 13:36:38 +1000 | |
|---|---|---|
| committer | 2020-07-17 14:24:57 +1000 | |
| commit | 468bd9c1b0f9e74f7c096b127a94a94e4ed7caec (patch) | |
| tree | 50a0f28b7c817222247369400bedf5de1ccc4e19 /src/video_core/shader_notify.cpp | |
| parent | Merge pull request #4347 from lioncash/logging (diff) | |
| download | yuzu-468bd9c1b0f9e74f7c096b127a94a94e4ed7caec.tar.gz yuzu-468bd9c1b0f9e74f7c096b127a94a94e4ed7caec.tar.xz yuzu-468bd9c1b0f9e74f7c096b127a94a94e4ed7caec.zip | |
async shaders
Diffstat (limited to 'src/video_core/shader_notify.cpp')
| -rw-r--r-- | src/video_core/shader_notify.cpp | 42 |
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 | |||
| 7 | using namespace std::chrono_literals; | ||
| 8 | |||
| 9 | namespace VideoCore { | ||
| 10 | namespace { | ||
| 11 | constexpr auto UPDATE_TICK = 32ms; | ||
| 12 | } | ||
| 13 | |||
| 14 | ShaderNotify::ShaderNotify() = default; | ||
| 15 | ShaderNotify::~ShaderNotify() = default; | ||
| 16 | |||
| 17 | std::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 | |||
| 27 | std::size_t ShaderNotify::GetShadersBuildingAccurate() { | ||
| 28 | std::shared_lock lock(mutex); | ||
| 29 | return accurate_count; | ||
| 30 | } | ||
| 31 | |||
| 32 | void ShaderNotify::MarkShaderComplete() { | ||
| 33 | std::unique_lock lock(mutex); | ||
| 34 | accurate_count--; | ||
| 35 | } | ||
| 36 | |||
| 37 | void ShaderNotify::MarkSharderBuilding() { | ||
| 38 | std::unique_lock lock(mutex); | ||
| 39 | accurate_count++; | ||
| 40 | } | ||
| 41 | |||
| 42 | } // namespace VideoCore | ||