summaryrefslogtreecommitdiffstats
path: root/src/video_core/shader_notify.cpp
blob: 693e47158e30c842cc874fdabe8b0f5703023bec (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Copyright 2020 yuzu Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.

#include <mutex>
#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