chore: make yuzu REUSE compliant
[REUSE] is a specification that aims at making file copyright
information consistent, so that it can be both human and machine
readable. It basically requires that all files have a header containing
copyright and licensing information. When this isn't possible, like
when dealing with binary assets, generated files or embedded third-party
dependencies, it is permitted to insert copyright information in the
`.reuse/dep5` file.
Oh, and it also requires that all the licenses used in the project are
present in the `LICENSES` folder, that's why the diff is so huge.
This can be done automatically with `reuse download --all`.
The `reuse` tool also contains a handy subcommand that analyzes the
project and tells whether or not the project is (still) compliant,
`reuse lint`.
Following REUSE has a few advantages over the current approach:
- Copyright information is easy to access for users / downstream
- Files like `dist/license.md` do not need to exist anymore, as
`.reuse/dep5` is used instead
- `reuse lint` makes it easy to ensure that copyright information of
files like binary assets / images is always accurate and up to date
To add copyright information of files that didn't have it I looked up
who committed what and when, for each file. As yuzu contributors do not
have to sign a CLA or similar I couldn't assume that copyright ownership
was of the "yuzu Emulator Project", so I used the name and/or email of
the commit author instead.
[REUSE]: https://reuse.software
Follow-up to 01cf05bc75b1e47beb08937439f3ed9339e7b254
2022-05-15 03:06:02 +03:00
|
|
|
// SPDX-FileCopyrightText: 2017 Citra Emulator Project
|
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2017-02-20 01:34:47 +03:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2019-08-26 18:29:08 +03:00
|
|
|
#include <array>
|
2021-05-16 03:34:20 +03:00
|
|
|
#include <atomic>
|
2017-02-20 01:34:47 +03:00
|
|
|
#include <chrono>
|
2019-09-10 13:57:45 +03:00
|
|
|
#include <cstddef>
|
2017-02-21 00:56:58 +03:00
|
|
|
#include <mutex>
|
2017-02-20 01:34:47 +03:00
|
|
|
#include "common/common_types.h"
|
|
|
|
|
|
|
|
namespace Core {
|
|
|
|
|
2018-08-31 19:21:34 +03:00
|
|
|
struct PerfStatsResults {
|
|
|
|
/// System FPS (LCD VBlanks) in Hz
|
|
|
|
double system_fps;
|
2021-05-16 03:34:20 +03:00
|
|
|
/// Average game FPS (GPU frame renders) in Hz
|
|
|
|
double average_game_fps;
|
2018-08-31 19:21:34 +03:00
|
|
|
/// Walltime per system frame, in seconds, excluding any waits
|
|
|
|
double frametime;
|
|
|
|
/// Ratio of walltime / emulated time elapsed
|
|
|
|
double emulation_speed;
|
|
|
|
};
|
|
|
|
|
2017-02-21 00:56:58 +03:00
|
|
|
/**
|
|
|
|
* Class to manage and query performance/timing statistics. All public functions of this class are
|
|
|
|
* thread-safe unless stated otherwise.
|
|
|
|
*/
|
2017-02-20 01:34:47 +03:00
|
|
|
class PerfStats {
|
|
|
|
public:
|
2021-05-16 08:46:30 +03:00
|
|
|
explicit PerfStats(u64 title_id_);
|
2019-08-26 18:29:08 +03:00
|
|
|
~PerfStats();
|
|
|
|
|
2021-12-02 22:20:43 +03:00
|
|
|
using Clock = std::chrono::steady_clock;
|
2017-02-20 01:34:47 +03:00
|
|
|
|
|
|
|
void BeginSystemFrame();
|
|
|
|
void EndSystemFrame();
|
|
|
|
void EndGameFrame();
|
|
|
|
|
2018-08-31 19:21:34 +03:00
|
|
|
PerfStatsResults GetAndResetStats(std::chrono::microseconds current_system_time_us);
|
2017-02-20 01:34:47 +03:00
|
|
|
|
2019-08-26 18:29:08 +03:00
|
|
|
/**
|
2020-08-03 15:12:03 +03:00
|
|
|
* Returns the arithmetic mean of all frametime values stored in the performance history.
|
2019-08-26 18:29:08 +03:00
|
|
|
*/
|
2020-08-03 15:12:03 +03:00
|
|
|
double GetMeanFrametime() const;
|
2019-08-26 18:29:08 +03:00
|
|
|
|
2017-02-20 05:18:26 +03:00
|
|
|
/**
|
|
|
|
* Gets the ratio between walltime and the emulated time of the previous system frame. This is
|
|
|
|
* useful for scaling inputs or outputs moving between the two time domains.
|
|
|
|
*/
|
2020-08-03 15:12:03 +03:00
|
|
|
double GetLastFrameTimeScale() const;
|
2017-02-20 05:18:26 +03:00
|
|
|
|
2017-02-20 01:34:47 +03:00
|
|
|
private:
|
2020-08-03 15:12:03 +03:00
|
|
|
mutable std::mutex object_mutex;
|
2019-08-26 18:29:08 +03:00
|
|
|
|
|
|
|
/// Title ID for the game that is running. 0 if there is no game running yet
|
|
|
|
u64 title_id{0};
|
|
|
|
/// Current index for writing to the perf_history array
|
|
|
|
std::size_t current_index{0};
|
|
|
|
/// Stores an hour of historical frametime data useful for processing and tracking performance
|
|
|
|
/// regressions with code changes.
|
2020-08-03 15:12:03 +03:00
|
|
|
std::array<double, 216000> perf_history{};
|
2017-02-21 00:56:58 +03:00
|
|
|
|
2017-02-27 04:13:12 +03:00
|
|
|
/// Point when the cumulative counters were reset
|
2017-02-20 01:34:47 +03:00
|
|
|
Clock::time_point reset_point = Clock::now();
|
2017-02-27 04:13:12 +03:00
|
|
|
/// System time when the cumulative counters were reset
|
2018-08-06 05:07:28 +03:00
|
|
|
std::chrono::microseconds reset_point_system_us{0};
|
2017-02-20 01:34:47 +03:00
|
|
|
|
2017-02-27 04:13:12 +03:00
|
|
|
/// Cumulative duration (excluding v-sync/frame-limiting) of frames since last reset
|
2017-02-20 01:34:47 +03:00
|
|
|
Clock::duration accumulated_frametime = Clock::duration::zero();
|
2017-02-27 04:13:12 +03:00
|
|
|
/// Cumulative number of system frames (LCD VBlanks) presented since last reset
|
2017-02-20 01:34:47 +03:00
|
|
|
u32 system_frames = 0;
|
2017-02-27 04:13:12 +03:00
|
|
|
/// Cumulative number of game frames (GSP frame submissions) since last reset
|
2021-05-16 03:34:20 +03:00
|
|
|
std::atomic<u32> game_frames = 0;
|
2017-02-27 04:13:12 +03:00
|
|
|
|
|
|
|
/// Point when the previous system frame ended
|
|
|
|
Clock::time_point previous_frame_end = reset_point;
|
|
|
|
/// Point when the current system frame began
|
|
|
|
Clock::time_point frame_begin = reset_point;
|
|
|
|
/// Total visible duration (including frame-limiting, etc.) of the previous system frame
|
|
|
|
Clock::duration previous_frame_length = Clock::duration::zero();
|
2021-05-16 03:34:20 +03:00
|
|
|
/// Previously computed fps
|
|
|
|
double previous_fps = 0;
|
2017-02-20 01:34:47 +03:00
|
|
|
};
|
|
|
|
|
2021-07-23 02:56:21 +03:00
|
|
|
class SpeedLimiter {
|
2017-02-21 03:31:59 +03:00
|
|
|
public:
|
2021-12-02 22:20:43 +03:00
|
|
|
using Clock = std::chrono::steady_clock;
|
2017-02-21 03:31:59 +03:00
|
|
|
|
2021-07-23 02:56:21 +03:00
|
|
|
void DoSpeedLimiting(std::chrono::microseconds current_system_time_us);
|
2017-02-21 03:31:59 +03:00
|
|
|
|
|
|
|
private:
|
|
|
|
/// Emulated system time (in microseconds) at the last limiter invocation
|
2018-08-06 05:07:28 +03:00
|
|
|
std::chrono::microseconds previous_system_time_us{0};
|
2017-02-21 03:31:59 +03:00
|
|
|
/// Walltime at the last limiter invocation
|
|
|
|
Clock::time_point previous_walltime = Clock::now();
|
|
|
|
|
|
|
|
/// Accumulated difference between walltime and emulated time
|
2021-07-23 02:56:21 +03:00
|
|
|
std::chrono::microseconds speed_limiting_delta_err{0};
|
2017-02-21 03:31:59 +03:00
|
|
|
};
|
|
|
|
|
2017-02-20 01:34:47 +03:00
|
|
|
} // namespace Core
|