Files
horizon-airdef/crates
chexit 3428a571bd Instance one mass group of mod models on the GPU (#147)
After the retained meshes of #126 a frame still transformed and uploaded
every model's vertices every frame (~3.1 MB vertex + ~4 MB motion at ~135
models in the #126 M5 report). The one mass group of identical models now
draws from a GPU mesh retained per pack generation: a frame writes only
instance records (current and previous drawn pose, model id, light, glow)
and the same stream feeds the HD G-buffer, the HD motion pass, the sun
shadow cascades and the classic entity pass (main and mod cameras). The
instance shader mirrors the CPU bake's transform, normal quantization and
light/material rules; a static model carries identical poses and keeps
zero object velocity (#143's contract, unchanged jitter conventions).

Everything else stays on the per-vertex path, bit-identical to before:
groups under eight models, HORIZON_MODEL_INSTANCING=0, a shader pack that
draws entities, or a missing renderer fall back whole. The diagnostic
runtime toggle `model-instancing on|off` (control command) switches paths
without a restart so the bench driver can compare both on one recording;
the drawn-pose history both paths keep makes the switch seamless for
motion. Reload and world unload drop the GPU meshes with the #126 cache;
the pack generation guard catches a reload too. Counters in `stats`:
instanced_models, instanced_quads, instance_bytes, gpu_mesh_builds.

Driver support for the #147 bench: `stats raw` reports every recorded
frame/CPU/GPU time; HORIZON_MOD_FUEL_PROFILE=1 reports the guests' observed
fuel per callback and average wall time per call in `stats`.

Tests: mod_models::tests (group choice and tie-break, GPU mesh faces,
shader math vs the CPU matrix, static zero velocity, the #126 parity test
unchanged), gfx attribute-layout and WGSL validation tests.

Co-Authored-By: Kimi Code <noreply@moonshot.ai>
2026-11-21 11:08:42 +03:00
..