chore: rename method in FpsTracker
This commit is contained in:
parent
5982fdea98
commit
e0523aea63
|
@ -79,7 +79,7 @@ pub fn runUnsynchronized(quit: *Atomic(bool), sched: *Scheduler, cpu: *Arm7tdmi,
|
||||||
runFrame(sched, cpu);
|
runFrame(sched, cpu);
|
||||||
if (audio_sync) syncToAudio(cpu);
|
if (audio_sync) syncToAudio(cpu);
|
||||||
|
|
||||||
tracker.completeFrame();
|
tracker.tick();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
while (!quit.load(.SeqCst)) {
|
while (!quit.load(.SeqCst)) {
|
||||||
|
@ -108,7 +108,7 @@ pub fn runSynchronized(quit: *Atomic(bool), sched: *Scheduler, cpu: *Arm7tdmi, f
|
||||||
if (audio_sync) syncToAudio(cpu) else spinLoop(&timer, wake_time);
|
if (audio_sync) syncToAudio(cpu) else spinLoop(&timer, wake_time);
|
||||||
wake_time = new_wake_time;
|
wake_time = new_wake_time;
|
||||||
|
|
||||||
tracker.completeFrame();
|
tracker.tick();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
while (!quit.load(.SeqCst)) {
|
while (!quit.load(.SeqCst)) {
|
||||||
|
|
|
@ -37,16 +37,12 @@ pub const FpsTracker = struct {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Rename
|
pub fn tick(self: *Self) void {
|
||||||
pub fn completeFrame(self: *Self) void {
|
|
||||||
_ = self.count.fetchAdd(1, .Monotonic);
|
_ = self.count.fetchAdd(1, .Monotonic);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn value(self: *Self) u32 {
|
pub fn value(self: *Self) u32 {
|
||||||
const expected = @intToFloat(f64, std.time.ns_per_s);
|
if (self.timer.read() >= std.time.ns_per_s) {
|
||||||
const actual = @intToFloat(f64, self.timer.read());
|
|
||||||
|
|
||||||
if (actual >= expected) {
|
|
||||||
self.fps = self.count.swap(0, .SeqCst);
|
self.fps = self.count.swap(0, .SeqCst);
|
||||||
self.timer.reset();
|
self.timer.reset();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue