Byte Engine Docs

Contribute to Byte Engine

Build, test, and document changes to Byte Engine.

This section is for contributors: people who change the engine repository. Its pages tell you how to build, test, measure, and document a change, and, for each system, how it's put together and what a change must keep true. To build an application with the engine instead, use Use Byte Engine.

Test your changes

Install and run the engine's default test harness from the workspace root:

cargo install cargo-nextest --version 0.9.140 --locked
cargo nextest run --workspace

Nextest doesn't run Rust documentation tests. If you add or change an example in API documentation, run it separately:

cargo test --doc --workspace

The default Nextest profile skips the graphics hardware interface (GHI) rendering integration tests because they need a local GPU. Run them explicitly when you change GHI rendering, resource lifetime, or backend command behavior:

cargo nextest run --ignore-default-filter \
  -p byte-engine-ghi \
  --test rendering

This command runs the rendering tests for your operating system's active GHI backend. Presentation and ray-tracing tests that are marked as ignored remain skipped.

The loader tests need a GPU too. Run them when you change resource loading, and read the loading timeline design first:

cargo nextest run --ignore-default-filter \
  -p byte-engine \
  --test loading

Run benchmarks

Run all available benchmarks from the repository root:

cargo bench --workspace

To run one benchmark target, pass its name and any required features. For example, run the audio graph benchmarks with:

cargo bench -p byte-engine --bench audio_graph

This Divan report compares callback-time evaluation for direct playback, sample-rate conversion, custom processing, and pitch shifting. Graph setup, sample loading, and buffer allocation happen before each measured loop.

To compare animation graph playback and inertialized transitions across different skeleton sizes, run:

cargo bench -p byte-engine --bench animation_graph

This benchmark also prepares graphs, resident clips, and retained pose buffers before each measured loop. Its characters_* benchmarks time a frame of many characters that share one graph and clip pool; read the animation system note before you change playback.

To check that one benchmark target builds and starts without collecting timing data, pass --test to Divan. For example:

cargo bench -p byte-engine --bench animation_graph -- --test

Measure performance

Every headed application serves its own timings while it runs, so you can measure a change without a profiler attached. The inspector listens on http://localhost:6680 and keeps the last 1024 ticks.

Read a summary of the CPU time in every engine span and the GPU time of the frame, each scene pipeline, and each render pass, in milliseconds:

curl -s 'http://localhost:6680/metrics?presented=true' | jq '.metrics[] | select(.kind == "gpu")'

presented=true drops ticks in which no window could reach the screen, such as while the window is hidden behind another one. Those ticks render nothing and would skew the numbers. Pass since=<tick> to compare the ticks after a change with the ticks before it.

Read the ticks themselves, one JSON object per line, to see where a spike landed:

curl -s 'http://localhost:6680/metrics/frames?limit=120' | jq -c '{tick, dt, gpu: .gpu.frame, bloom: .gpu["pass.Bloom"]}'

Each row names the renderer frame it submitted, which is the same number a screenshot of that frame reports, so you can pair a slow frame with its image. GPU values arrive once the frame completes, so the newest rows have none yet.

To measure a run without polling, let the application close itself and write the metrics on the way out:

cargo run -- --kill-after=600 --metrics-out=run.json

A path ending in .ndjson writes every retained tick instead of the summary. The same spans stream to Tracy when the tracy Cargo feature is enabled.

Measure code coverage

Install cargo-llvm-cov:

cargo install cargo-llvm-cov

Then generate an LCOV report:

cargo llvm-cov --lcov --output-path coverage/lcov.info

To view the report in Visual Studio Code, install the markis.code-coverage extension.

Write documentation

Every page in docs belongs to one section, chosen by who reads it and what they ask. Before you add, move, or rewrite a page, read Write documentation for the section charter, the page shape each section expects, and the style guides for pages and doc comments.

On this page