diff options
| author | bunnei <bunneidev@gmail.com> | 2020-07-18 00:48:27 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-07-18 00:48:27 -0400 |
| commit | 90cbcaa44a3901a832556258b5b97d8d7de34ca9 (patch) | |
| tree | 570ff95dae035757fb2831804aae4f4ca681d354 /src/video_core/shader_notify.cpp | |
| parent | 821d295f24136b7550fde1376810ca3756a58403 (diff) | |
| parent | 967307d3beb59b64e40c4b3f44ed839d87325e5c (diff) | |
Merge pull request #4273 from ogniK5377/async-shaders-prod
video_core: Add asynchronous shader decompilation and compilation
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..c3c71657d --- /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 |
