vkmEngine 1.0.0
A C++ game engine · vkmengine.com
Loading...
Searching...
No Matches
engine_config.h
1#pragma once
2
3#include <cstdint>
4
5namespace Vkm::Engine {
6
17namespace Config {
18
19 // Lights uploaded per frame.
20 constexpr uint32_t MAX_LIGHTS = 256;
21
22 // Forward+ grid: screen tiles by exponential depth slices. Read the trade-off
23 // in docs/reference/lighting.md before changing it.
24 constexpr uint32_t CLUSTER_X = 32;
25 constexpr uint32_t CLUSTER_Y = 18;
26 constexpr uint32_t CLUSTER_Z = 24;
27 constexpr uint32_t MAX_LIGHTS_PER_CLUSTER = 64;
28
29 // Casters in the 2D atlas (directional + spot).
30 constexpr uint32_t MAX_SHADOW_CASTERS_2D = 6;
31
32 // Point-light casters, one depth cube each.
33 constexpr uint32_t MAX_SHADOW_CASTERS_CUBE = 2;
34
35 // Sun shadow cascades, each taking one of the MAX_SHADOW_CASTERS_2D atlas tiles; see GLShadowData.
36 constexpr uint32_t NUM_CASCADES = 4;
37
38 // Spot/point shadow near plane: small enough not to clip inside a small light,
39 // large enough to keep depth resolution at typical occluder distances.
40 constexpr float SHADOW_NEAR = 0.1f;
41
42 // fixedUpdate ticks per second, and the wire's clock, when a project names none.
43 constexpr uint32_t DEFAULT_TICK_RATE = 64;
44
45 // Below four, a step is longer than MAX_FRAME_ACCUMULATOR can consume and
46 // fixedUpdate silently never runs.
47 constexpr uint32_t MIN_TICK_RATE = 4;
48 constexpr uint32_t MAX_TICK_RATE = 480;
49
59 constexpr uint32_t clampTickRate(uint32_t ticksPerSecond) {
60 return ticksPerSecond < MIN_TICK_RATE ? MIN_TICK_RATE
61 : ticksPerSecond > MAX_TICK_RATE ? MAX_TICK_RATE
62 : ticksPerSecond;
63 }
64
65 // Caps the accumulator so a hitch cannot queue ticks faster than frames run
66 // ("spiral of death"). A higher rate gets more ticks per hitch, not a longer stall.
67 constexpr float MAX_FRAME_ACCUMULATOR = 0.25f;
68
69 static_assert(
70 1.0f / static_cast<float>(MIN_TICK_RATE) <= MAX_FRAME_ACCUMULATOR,
71 "A step longer than the accumulator cap can never be consumed, "
72 "so the slowest allowed tick rate would never tick at all"
73 );
74
75 // Seat cap: a host's per-tick work scales with it, and it comes from a
76 // hand-authored project.json.
77 constexpr uint32_t MAX_PLAYERS_PER_GAME = 64;
78
87 constexpr uint32_t clampSeats(uint32_t seats) {
88 return seats > MAX_PLAYERS_PER_GAME ? MAX_PLAYERS_PER_GAME : seats;
89 }
90
91} // namespace Config
92
93} // namespace Vkm::Engine
Engine-level configuration constants.
Definition engine_config.h:17
constexpr uint32_t clampTickRate(uint32_t ticksPerSecond)
What a project's requested tick rate is honoured as.
Definition engine_config.h:59
constexpr uint32_t clampSeats(uint32_t seats)
What a project's requested seat count is honoured as.
Definition engine_config.h:87