Byte Engine Docs

Time and ticks

Look up the engine's time unit, the tick's clock and order, the two simulation loops and the fixed-step rules, and how a run ends.

The engine measures time in integer ticks of a fixed timebase, and a headed application advances in ticks that pull input, run the simulation, and render. This page specifies the unit, the clock, the order within a tick, and the two loops.

Time unit

RuleValue
Timebase28,224,000 ticks per second, which divides every conventional frame rate and the 44.1, 48, 96, and 192 kHz sample rates exactly.
RepresentationA signed 64-bit tick count.
From seconds, microseconds, or a durationRounded to the nearest tick.
From millisecondsExact, or an error.
From frames or samplesExact when the rate divides the timebase, otherwise none.
ArithmeticAddition, subtraction, scaling, and division are checked; overflow and division by zero are errors.

Tick time

Each tick carries the elapsed time since the application started and the delta since the previous tick, or the fixed step in the stepped loop.

RuleBehavior
Display cadenceWhen the swapchain reports a newer presented time, the delta is the display interval, so deltas follow the display rather than CPU noise.
OtherwiseThe delta is the wall time since the last tick. After an idle wait it's capped at one skipped-frame pace.
Stall capA delta never exceeds four skipped-frame paces, whichever cadence measured it. Elapsed time still advances by the full interval, so a stall lands in the clock but no system simulates through it.
Stale presentA presented time older than one frame before the previous tick is ignored.
Skipped-frame paceThe larger of the frame-rate cap and the display refresh, 16,667 µs by default, slept when nothing presents.

Tick order

OrderPhase
1The message bus begins the tick and the frame allocator resets.
2Window events are processed, raw input is recorded, and the loop waits in the window system only when rendering on demand and idle.
3A close event ends the run.
4Swapchain images are acquired when rendering is active; otherwise the loop sleeps the skipped-frame pace.
5The frame clock samples the tick's time.
6Gamepads are polled and the input sink resolves actions.
7The application's callback runs, or the fixed steps and the frame callback. The renderer steps after each simulation step.
8The renderer updates, adopts new windows and cameras, and renders when active.
9The tick's metrics are recorded.

Loops

LoopRule
Tied to framesThe simulation advances once per tick by the frame delta. With a simulation rate set, every tick asserts the rate matches the presentation cadence within 1 percent.
SteppedThe simulation runs zero or more fixed steps of the simulation rate, 60 per second by default, then the frame callback runs with the display-derived time.
Stepped loopValue
Steps per frameAt most 8. Any further debt is dropped, so simulated time is lost rather than stretching later frames.
RemainderCarries to the next frame.
Blend factorThe pending time over the step, so a frame shows the world one step behind, blended between the previous and latest steps. The same factor is available to application code.
Wake-upThe next step's deadline wakes an idle on-demand loop.

Ending a run

ParameterBehavior
kill-afterCloses the application after that many ticks and never waits while idle. Debug builds only.
metrics-outWrites the metrics once when the application closes.

Both are startup parameters.

Rust API

On this page