perf(iced): make idle panels cost near zero #1103

Merged
SakulFlee merged 2 commits from sakulflee/iced-idle-submit into main 2026-11-11 20:55:47 +00:00 AGit
Owner

Closes #1079.

Summary

  • Merge the iced command buffer into the scene submission instead of issuing a second queue.submit every frame. The iced fork exposes Renderer::draw plus finish/recall, so the runtime records the layer and appends it to the main submission. A new OverlaySubmission::MainSubmit mode covers layers that record their own command buffer but share the scene submit.
  • Cache the iced layer in an offscreen texture. The interface is drawn only when the widget tree, input or size changes; unchanged frames composite the cached premultiplied-alpha texture with one fullscreen blend in the same submission.

Measurements

Ran template_all_in_one at 1280x720 with the debug panels forced visible on a Radeon RX 9060 XT / RADV / Vulkan, 25 s capture:

  • One queue.submit per frame; iced_submit now measures command recording/composite, while the queue submit is folded into scene_submit.
  • Steady idle windows: iced_draw ~0.03 ms, iced_submit ~0.01 ms, overlay_layers ~0.07 ms.
  • The first-frame spike (~30 ms) is pipeline/text preparation, not steady state.
  • A hidden debug UI reports 0 ms for all iced stages.

Verification

  • cargo fmt --all -- --check
  • cargo clippy -- -D warnings
  • cargo test --no-fail-fast
  • cargo run -p template_all_in_one with the debug panels visible; no wgpu validation errors or panics.

The panels still render, update and accept input; only unchanged frames reuse the cached texture.

Closes #1079. ## Summary - Merge the iced command buffer into the scene submission instead of issuing a second `queue.submit` every frame. The iced fork exposes `Renderer::draw` plus `finish`/`recall`, so the runtime records the layer and appends it to the main submission. A new `OverlaySubmission::MainSubmit` mode covers layers that record their own command buffer but share the scene submit. - Cache the iced layer in an offscreen texture. The interface is drawn only when the widget tree, input or size changes; unchanged frames composite the cached premultiplied-alpha texture with one fullscreen blend in the same submission. ## Measurements Ran `template_all_in_one` at 1280x720 with the debug panels forced visible on a Radeon RX 9060 XT / RADV / Vulkan, 25 s capture: - One `queue.submit` per frame; `iced_submit` now measures command recording/composite, while the queue submit is folded into `scene_submit`. - Steady idle windows: `iced_draw` ~0.03 ms, `iced_submit` ~0.01 ms, `overlay_layers` ~0.07 ms. - The first-frame spike (~30 ms) is pipeline/text preparation, not steady state. - A hidden debug UI reports 0 ms for all iced stages. ## Verification - `cargo fmt --all -- --check` - `cargo clippy -- -D warnings` - `cargo test --no-fail-fast` - `cargo run -p template_all_in_one` with the debug panels visible; no wgpu validation errors or panics. The panels still render, update and accept input; only unchanged frames reuse the cached texture.
The iced fork exposes Renderer::draw together with finish/recall, so the runtime can record the panel command buffer and append it to the scene submission. This removes the second queue.submit that ran after the scene every frame.

Add OverlaySubmission::MainSubmit for layers that record their own command buffer but share the scene submission, and keep OverlaySubmission::Owned for layers that still submit separately.
perf(iced): composite a cached UI frame while the layer is idle
All checks were successful
Lint / lint (pull_request) Successful in 1m16s
PR / test (pull_request) Successful in 3m57s
212c553092
Rebuilding the widget tree is already throttled, but every visible frame still prepared, recorded and submitted the whole iced layer. Draw the interface into an offscreen texture only when the tree, input or size changed, then composite that texture over the scene on unchanged frames.

Idle panels now cost one fullscreen alpha blend instead of an iced prepare/render/submit cycle. The command buffer is still merged into the scene submission, and a transparent clear keeps the cached layer compositable over the scene.

Smart test results

Result: PASS

Scope: orbital_app, orbital_iced, orbital_renderer

Reason: directly changed crates

Elapsed: 3m 39s

Workflow run

Overall: 74 tests, 73 passed, 0 failed, 1 skipped

Nextest: 73 tests, 73 passed, 0 failed, 0 skipped
Doctests: 1 tests, 0 passed, 0 failed, 1 skipped

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

Crate Nextest Passed Failed Skipped Doctests Time
orbital_app 25 25 0 0 0/1 0.14s
orbital_iced 26 26 0 0 - 0.13s
orbital_renderer 22 22 0 0 - 0.21s
pie showData
    title Nextest outcomes
    "Passed" : 73
pie showData
    title Doctest outcomes
    "Skipped" : 1
xychart-beta
    title "Slowest crates (nextest seconds)"
    x-axis ["orbital_renderer", "orbital_app", "orbital_iced"]
    y-axis "Seconds" 0 --> 1
    bar [0.21, 0.14, 0.13]
<!-- orbital-ci-test-results --> ## Smart test results **Result:** PASS **Scope:** orbital_app, orbital_iced, orbital_renderer **Reason:** directly changed crates **Elapsed:** 3m 39s [Workflow run](https://forgejo.sakul-flee.de/SakulFlee/Orbital/actions/runs/1258) **Overall:** 74 tests, 73 passed, 0 failed, 1 skipped **Nextest:** 73 tests, 73 passed, 0 failed, 0 skipped **Doctests:** 1 tests, 0 passed, 0 failed, 1 skipped _Outcome charts are split between nextest and doctests. The timing chart covers nextest only._ | Crate | Nextest | Passed | Failed | Skipped | Doctests | Time | | --- | ---: | ---: | ---: | ---: | ---: | ---: | | orbital_app | 25 | 25 | 0 | 0 | 0/1 | 0.14s | | orbital_iced | 26 | 26 | 0 | 0 | - | 0.13s | | orbital_renderer | 22 | 22 | 0 | 0 | - | 0.21s | ```mermaid pie showData title Nextest outcomes "Passed" : 73 ``` ```mermaid pie showData title Doctest outcomes "Skipped" : 1 ``` ```mermaid xychart-beta title "Slowest crates (nextest seconds)" x-axis ["orbital_renderer", "orbital_app", "orbital_iced"] y-axis "Seconds" 0 --> 1 bar [0.21, 0.14, 0.13] ```
Author
Owner

Closes #1079

Closes #1079
Sign in to join this conversation.
No description provided.