vkmEngine 1.0.0
A C++ game engine · vkmengine.com
Loading...
Searching...
No Matches
pacing.h
1#pragma once
2
3#include <cstdint>
4
5#include "net/prediction/command.h"
6
7namespace Vkm::Engine {
8
14constexpr uint32_t NET_QUEUE_DEPTH_BITS = 4;
15
17constexpr uint32_t NET_QUEUE_DEPTH_MAX = (1u << NET_QUEUE_DEPTH_BITS) - 1u;
18
19static_assert(
20 NET_QUEUE_DEPTH_MAX > NetCommandBuffer::MAX_DEPTH,
21 "a queue deep enough to be trimmed has to be able to say so"
22);
23
39class NetPacing {
40 public:
47 static constexpr float MAX_DILATION = 0.05f;
48
49 public:
50 NetPacing() = default;
51 ~NetPacing() = default;
52
53 NetPacing(const NetPacing& other) = default;
54 NetPacing& operator=(const NetPacing& other) = default;
55
56 NetPacing(NetPacing && other) = default;
57 NetPacing& operator=(NetPacing && other) = default;
58
59 public:
68 void report(uint32_t lowWater, float roundTrip, float tickRate);
69
76 float scale() const { return m_scale; }
77
79 float depth() const { return m_depth; }
80
82 float target() const;
83
84 void clear() { *this = NetPacing{}; }
85
86 private:
87 float m_depth = 0.0f;
88 float m_spread = 0.0f;
89 float m_drift = 0.0f;
90 float m_scale = 1.0f;
91 bool m_started = false;
92};
93
94} // namespace Vkm::Engine
static constexpr size_t MAX_DEPTH
Commands the queue may hold before the oldest are skipped, all at once.
Definition command.h:122
float depth() const
The low water as smoothed over the last few snapshots, in commands.
Definition pacing.h:79
static constexpr float MAX_DILATION
The most the pacing bends either way.
Definition pacing.h:47
float scale() const
How much faster than wall time to run ticks.
Definition pacing.h:76
float target() const
The low water this is steering toward, in commands.
void report(uint32_t lowWater, float roundTrip, float tickRate)
Take one snapshot's reading of the queue.