suyu/src/video_core/shader_notify.cpp

44 lines
1 KiB
C++
Raw Normal View History

2020-07-10 05:36:38 +02:00
// Copyright 2020 yuzu Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include <mutex>
2020-07-10 05:36:38 +02:00
#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() {
2020-07-18 06:24:32 +02:00
std::shared_lock lock{mutex};
2020-07-10 05:36:38 +02:00
return accurate_count;
}
void ShaderNotify::MarkShaderComplete() {
2020-07-18 06:24:32 +02:00
std::unique_lock lock{mutex};
2020-07-10 05:36:38 +02:00
accurate_count--;
}
void ShaderNotify::MarkSharderBuilding() {
2020-07-18 06:24:32 +02:00
std::unique_lock lock{mutex};
2020-07-10 05:36:38 +02:00
accurate_count++;
}
} // namespace VideoCore