perf(renderer): reuse instance and cull buffers #935

Merged
SakulFlee merged 2 commits from perf/renderer-instance-reuse into main 2026-10-26 01:37:44 +00:00
Collaborator

Summary

Stacked on #933 (phase 1a). Removes the per-frame model rebuild and cull allocation path.

  • Model now owns its instance buffer, a CPU copy of the instance data and world-space bounds for each instance.
  • Transform-only changes update the existing buffer in place via Model::update_instances; the model is only rebuilt when the mesh/material hash changes.
  • sys_frustum_cull consumes the cached model data instead of re-encoding every transform and allocating per-model byte vectors.
  • CullResources is persistent: buffer, per-model lists and scratch data are reused and only reallocated when capacity is exceeded.
  • This is the animation path: changing transforms updates one buffer per model and re-culls from cached bounds.

Verification

  • cargo fmt --all -- --check
  • cargo clippy -p orbital_model -p orbital_cull -p orbital_renderer -p orbital_app -- -D warnings
  • cargo test -p orbital_model -p orbital_cull -p orbital_renderer -p orbital_app --no-fail-fast
  • GUI examples were not launched in this environment (no display/GPU).

Refs #781.

## Summary Stacked on #933 (phase 1a). Removes the per-frame model rebuild and cull allocation path. - `Model` now owns its instance buffer, a CPU copy of the instance data and world-space bounds for each instance. - Transform-only changes update the existing buffer in place via `Model::update_instances`; the model is only rebuilt when the mesh/material hash changes. - `sys_frustum_cull` consumes the cached model data instead of re-encoding every transform and allocating per-model byte vectors. - `CullResources` is persistent: buffer, per-model lists and scratch data are reused and only reallocated when capacity is exceeded. - This is the animation path: changing transforms updates one buffer per model and re-culls from cached bounds. ## Verification - `cargo fmt --all -- --check` - `cargo clippy -p orbital_model -p orbital_cull -p orbital_renderer -p orbital_app -- -D warnings` - `cargo test -p orbital_model -p orbital_cull -p orbital_renderer -p orbital_app --no-fail-fast` - GUI examples were not launched in this environment (no display/GPU). Refs #781.
perf(renderer): reuse instance and cull buffers
Some checks failed
Lint / lint (pull_request) Failing after 2s
PR / test (pull_request) Failing after 3s
Templates / templates (pull_request) Failing after 2s
de4431c747
Models now keep their instance buffer and a CPU copy of instance data and world-space bounds. Transform-only changes update the buffer in place instead of rebuilding the Model, and the cull system consumes the cached data instead of re-encoding every transform each frame.

CullResources is now persistent: its GPU buffer, per-model lists and scratch data are reused and only reallocated when capacity is exceeded.
OpenCode force-pushed perf/renderer-instance-reuse from de4431c747
Some checks failed
Lint / lint (pull_request) Failing after 2s
PR / test (pull_request) Failing after 3s
Templates / templates (pull_request) Failing after 2s
to 758e9ee2aa
All checks were successful
Lint / lint (pull_request) Successful in 2m3s
Templates / templates (pull_request) Successful in 2m34s
PR / test (pull_request) Successful in 8m14s
2026-10-25 18:23:04 +00:00
Compare

Smart test results

Result: PASS

Scope: full workspace

Reason: workspace-level change: Cargo.lock

Elapsed: 5m 49s

Workflow run

Overall: 425 tests, 415 passed, 0 failed, 10 skipped

Nextest: 414 tests, 414 passed, 0 failed, 0 skipped
Doctests: 11 tests, 1 passed, 0 failed, 10 skipped

Outcome charts are split between nextest and doctests. The timing chart covers nextest only.

Crate Nextest Passed Failed Skipped Doctests Time
orbital 1 1 0 0 - 2.69s
orbital_2d 29 29 0 0 0/1 0.43s
orbital_app 10 10 0 0 0/1 0.14s
orbital_camera 4 4 0 0 - 0.04s
orbital_core 2 2 0 0 - 0.03s
orbital_debug_render 0 0 0 0 0/1 0.00s
orbital_debug_ui 45 45 0 0 0/1 0.63s
orbital_ecs 114 114 0 0 0/2 1.45s
orbital_ecs_bridge 39 39 0 0 - 0.49s
orbital_file_manager 5 5 0 0 - 4.82s
orbital_iced 25 25 0 0 - 0.24s
orbital_importer_gltf 13 13 0 0 - 7.09s
orbital_input 11 11 0 0 - 0.06s
orbital_light 6 6 0 0 - 0.03s
orbital_macros 0 0 0 0 0/1 0.00s
orbital_math 4 4 0 0 - 0.03s
orbital_procgeo 2 2 0 0 - 0.01s
orbital_renderer 2 2 0 0 - 0.01s
orbital_resources 18 18 0 0 - 1.57s
orbital_shader_core 0 0 0 0 1/1 0.00s
orbital_shader_preprocessor 12 12 0 0 - 0.26s
orbital_shadow 3 3 0 0 - 0.06s
orbital_text 14 14 0 0 0/1 1.12s
orbital_texture 9 9 0 0 - 0.15s
orbital_touch_ui 1 1 0 0 0/1 0.02s
orbital_ui 32 32 0 0 0/1 0.79s
orbital_world_environment 13 13 0 0 - 0.27s
pie showData
    title Nextest outcomes
    "Passed" : 414
pie showData
    title Doctest outcomes
    "Passed" : 1
    "Skipped" : 10
xychart-beta
    title "Slowest crates (nextest seconds)"
    x-axis ["orbital_importer_gltf", "orbital_file_manager", "orbital", "orbital_resources", "orbital_ecs", "orbital_text", "orbital_ui", "orbital_debug_ui"]
    y-axis "Seconds" 0 --> 7.1
    bar [7.09, 4.82, 2.69, 1.57, 1.45, 1.12, 0.79, 0.63]
<!-- orbital-ci-test-results --> ## Smart test results **Result:** PASS **Scope:** full workspace **Reason:** workspace-level change: Cargo.lock **Elapsed:** 5m 49s [Workflow run](https://forgejo.sakul-flee.de/SakulFlee/Orbital/actions/runs/628) **Overall:** 425 tests, 415 passed, 0 failed, 10 skipped **Nextest:** 414 tests, 414 passed, 0 failed, 0 skipped **Doctests:** 11 tests, 1 passed, 0 failed, 10 skipped _Outcome charts are split between nextest and doctests. The timing chart covers nextest only._ | Crate | Nextest | Passed | Failed | Skipped | Doctests | Time | | --- | ---: | ---: | ---: | ---: | ---: | ---: | | orbital | 1 | 1 | 0 | 0 | - | 2.69s | | orbital_2d | 29 | 29 | 0 | 0 | 0/1 | 0.43s | | orbital_app | 10 | 10 | 0 | 0 | 0/1 | 0.14s | | orbital_camera | 4 | 4 | 0 | 0 | - | 0.04s | | orbital_core | 2 | 2 | 0 | 0 | - | 0.03s | | orbital_debug_render | 0 | 0 | 0 | 0 | 0/1 | 0.00s | | orbital_debug_ui | 45 | 45 | 0 | 0 | 0/1 | 0.63s | | orbital_ecs | 114 | 114 | 0 | 0 | 0/2 | 1.45s | | orbital_ecs_bridge | 39 | 39 | 0 | 0 | - | 0.49s | | orbital_file_manager | 5 | 5 | 0 | 0 | - | 4.82s | | orbital_iced | 25 | 25 | 0 | 0 | - | 0.24s | | orbital_importer_gltf | 13 | 13 | 0 | 0 | - | 7.09s | | orbital_input | 11 | 11 | 0 | 0 | - | 0.06s | | orbital_light | 6 | 6 | 0 | 0 | - | 0.03s | | orbital_macros | 0 | 0 | 0 | 0 | 0/1 | 0.00s | | orbital_math | 4 | 4 | 0 | 0 | - | 0.03s | | orbital_procgeo | 2 | 2 | 0 | 0 | - | 0.01s | | orbital_renderer | 2 | 2 | 0 | 0 | - | 0.01s | | orbital_resources | 18 | 18 | 0 | 0 | - | 1.57s | | orbital_shader_core | 0 | 0 | 0 | 0 | 1/1 | 0.00s | | orbital_shader_preprocessor | 12 | 12 | 0 | 0 | - | 0.26s | | orbital_shadow | 3 | 3 | 0 | 0 | - | 0.06s | | orbital_text | 14 | 14 | 0 | 0 | 0/1 | 1.12s | | orbital_texture | 9 | 9 | 0 | 0 | - | 0.15s | | orbital_touch_ui | 1 | 1 | 0 | 0 | 0/1 | 0.02s | | orbital_ui | 32 | 32 | 0 | 0 | 0/1 | 0.79s | | orbital_world_environment | 13 | 13 | 0 | 0 | - | 0.27s | ```mermaid pie showData title Nextest outcomes "Passed" : 414 ``` ```mermaid pie showData title Doctest outcomes "Passed" : 1 "Skipped" : 10 ``` ```mermaid xychart-beta title "Slowest crates (nextest seconds)" x-axis ["orbital_importer_gltf", "orbital_file_manager", "orbital", "orbital_resources", "orbital_ecs", "orbital_text", "orbital_ui", "orbital_debug_ui"] y-axis "Seconds" 0 --> 7.1 bar [7.09, 4.82, 2.69, 1.57, 1.45, 1.12, 0.79, 0.63] ```
SakulFlee changed target branch from refactor/renderer-phase-1 to main 2026-10-26 01:22:09 +00:00
Merge branch 'main' into perf/renderer-instance-reuse
All checks were successful
Lint / lint (pull_request) Successful in 1m22s
PR / test (pull_request) Successful in 7m6s
Templates / templates (pull_request) Successful in 5m8s
38da08a958
SakulFlee deleted branch perf/renderer-instance-reuse 2026-10-26 01:37:45 +00:00
Sign in to join this conversation.
No description provided.