mirror of
https://github.com/TomHarte/CLK.git
synced 2025-01-27 06:35:04 +00:00
Makes effort to round out draft 1 of Outputs::Display::Metrics.
This commit is contained in:
parent
5660007221
commit
f18132d674
@ -8,7 +8,7 @@
|
||||
|
||||
#include "DisplayMetrics.hpp"
|
||||
|
||||
#include <iostream>
|
||||
#include <numeric>
|
||||
|
||||
using namespace Outputs::Display;
|
||||
|
||||
@ -19,8 +19,10 @@ void Metrics::announce_event(ScanTarget::Event event) {
|
||||
case ScanTarget::Event::EndHorizontalRetrace:
|
||||
++lines_this_frame_;
|
||||
break;
|
||||
case ScanTarget::Event::EndVerticalRetrace:
|
||||
case ScanTarget::Event::BeginVerticalRetrace:
|
||||
add_line_total(lines_this_frame_);
|
||||
break;
|
||||
case ScanTarget::Event::EndVerticalRetrace:
|
||||
lines_this_frame_ = 0;
|
||||
break;
|
||||
default: break;
|
||||
@ -28,11 +30,18 @@ void Metrics::announce_event(ScanTarget::Event event) {
|
||||
}
|
||||
|
||||
void Metrics::add_line_total(int total) {
|
||||
// std::cout << total << '\n';
|
||||
line_total_history_[line_total_history_pointer_] = total;
|
||||
line_total_history_pointer_ = (line_total_history_pointer_ + 1) % line_total_history_.size();
|
||||
}
|
||||
|
||||
float Metrics::lines_per_frame_estimate() {
|
||||
return 1.0f; // TODO.
|
||||
float Metrics::visible_lines_per_frame_estimate() {
|
||||
// Just average the number of records contained in line_total_history_ to provide this estimate;
|
||||
// that array should be an even number, to allow for potential interlaced sources.
|
||||
return float(std::accumulate(line_total_history_.begin(), line_total_history_.end(), 0)) / float(line_total_history_.size());
|
||||
}
|
||||
|
||||
int Metrics::current_line() {
|
||||
return lines_this_frame_;
|
||||
}
|
||||
|
||||
// MARK: GPU processing speed decisions.
|
||||
|
@ -10,6 +10,8 @@
|
||||
#define DisplayMetrics_hpp
|
||||
|
||||
#include "ScanTarget.hpp"
|
||||
|
||||
#include <array>
|
||||
#include <chrono>
|
||||
|
||||
namespace Outputs {
|
||||
@ -22,16 +24,27 @@ namespace Display {
|
||||
*/
|
||||
class Metrics {
|
||||
public:
|
||||
/// Notifies Metrics of a beam event.
|
||||
void announce_event(ScanTarget::Event event);
|
||||
|
||||
/// Notifies Metrics that the size of the output buffer has changed.
|
||||
void announce_did_resize();
|
||||
/// Provides Metrics with a new data point for output speed estimation.
|
||||
void announce_draw_status(size_t lines, std::chrono::high_resolution_clock::duration duration, bool complete);
|
||||
|
||||
/// @returns @c true if Metrics thinks a lower output buffer resolution is desirable in the abstract; @c false otherwise.
|
||||
bool should_lower_resolution();
|
||||
float lines_per_frame_estimate();
|
||||
|
||||
/// @returns An estimate of the number of lines being produced per frame, excluding vertical sync.
|
||||
float visible_lines_per_frame_estimate();
|
||||
|
||||
/// @returns The number of lines since vertical retrace ended.
|
||||
int current_line();
|
||||
|
||||
private:
|
||||
int lines_this_frame_ = 0;
|
||||
std::array<int, 20> line_total_history_;
|
||||
size_t line_total_history_pointer_ = 0;
|
||||
void add_line_total(int);
|
||||
|
||||
int frames_hit_ = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user