2022-04-23 09:59:50 +01:00
|
|
|
// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
|
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2020-07-10 04:36:38 +01:00
|
|
|
|
2021-06-06 04:11:36 +01:00
|
|
|
#include <atomic>
|
|
|
|
#include <chrono>
|
|
|
|
|
2020-07-10 04:36:38 +01:00
|
|
|
#include "video_core/shader_notify.h"
|
|
|
|
|
|
|
|
using namespace std::chrono_literals;
|
|
|
|
|
|
|
|
namespace VideoCore {
|
|
|
|
|
2021-06-06 04:11:36 +01:00
|
|
|
const auto TIME_TO_STOP_REPORTING = 2s;
|
|
|
|
|
|
|
|
int ShaderNotify::ShadersBuilding() noexcept {
|
|
|
|
const int now_complete = num_complete.load(std::memory_order::relaxed);
|
|
|
|
const int now_building = num_building.load(std::memory_order::relaxed);
|
|
|
|
if (now_complete == now_building) {
|
2021-12-02 19:20:43 +00:00
|
|
|
const auto now = std::chrono::steady_clock::now();
|
2021-06-06 04:11:36 +01:00
|
|
|
if (completed && num_complete == num_when_completed) {
|
|
|
|
if (now - complete_time > TIME_TO_STOP_REPORTING) {
|
|
|
|
report_base = now_complete;
|
|
|
|
completed = false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
completed = true;
|
|
|
|
num_when_completed = num_complete;
|
|
|
|
complete_time = now;
|
|
|
|
}
|
2020-07-10 04:36:38 +01:00
|
|
|
}
|
2021-06-06 04:11:36 +01:00
|
|
|
return now_building - report_base;
|
2020-07-10 04:36:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace VideoCore
|