perf(billboard): share one SDF atlas across text labels #1098

Merged
SakulFlee merged 2 commits from sakulflee/shared-label-atlas into main 2026-11-11 01:09:47 +00:00 AGit
Owner

Every world-space text billboard built and uploaded its own 1024x1024
SDF atlas, even when labels used the same font and repeated glyphs.

Add SharedTextAtlas, which builds one atlas from the union of a label
group's characters, and let Text reuse it for rebuilds. Materials are
cached per text style inside the shared atlas, so labels with identical
styling share one realized texture as well.

The all-in-one example now builds a single atlas for all eight room
labels instead of one atlas per label (twice: once at spawn and once in
the first-frame text rebuild).

Every world-space text billboard built and uploaded its own 1024x1024 SDF atlas, even when labels used the same font and repeated glyphs. Add SharedTextAtlas, which builds one atlas from the union of a label group's characters, and let Text reuse it for rebuilds. Materials are cached per text style inside the shared atlas, so labels with identical styling share one realized texture as well. The all-in-one example now builds a single atlas for all eight room labels instead of one atlas per label (twice: once at spawn and once in the first-frame text rebuild).
build_atlas called FontData::get_glyph first, which generated and cached
an SDF that the function then discarded, and it rasterized and converted
the same character again for packing. Repeated characters also paid for
that work once per occurrence.

Pack only unique characters and convert each bitmap to SDF data once.
perf(billboard): share one SDF atlas across text labels
Some checks failed
Lint / lint (pull_request) Successful in 1m15s
PR / test (pull_request) Has been cancelled
Templates / templates (pull_request) Has been cancelled
ba77daf3d3
Every world-space text billboard built and uploaded its own 1024x1024
SDF atlas, even when labels used the same font and repeated glyphs.

Add SharedTextAtlas, which builds one atlas from the union of a label
group's characters, and let Text reuse it for rebuilds. Materials are
cached per text style inside the shared atlas, so labels with identical
styling share one realized texture as well.

The all-in-one example now builds a single atlas for all eight room
labels instead of one atlas per label (twice: once at spawn and once in
the first-frame text rebuild).
SakulFlee force-pushed sakulflee/shared-label-atlas from ba77daf3d3
Some checks failed
Lint / lint (pull_request) Successful in 1m15s
PR / test (pull_request) Has been cancelled
Templates / templates (pull_request) Has been cancelled
to 06a45bc021
Some checks failed
Lint / lint (pull_request) Successful in 1m11s
PR / test (pull_request) Has been cancelled
Templates / templates (pull_request) Has been cancelled
2026-11-11 00:36:22 +00:00
Compare
SakulFlee force-pushed sakulflee/shared-label-atlas from 06a45bc021
Some checks failed
Lint / lint (pull_request) Successful in 1m11s
PR / test (pull_request) Has been cancelled
Templates / templates (pull_request) Has been cancelled
to 00ff36898c
All checks were successful
Lint / lint (pull_request) Successful in 1m11s
PR / test (pull_request) Successful in 3m59s
Templates / templates (pull_request) Successful in 3m32s
2026-11-11 00:38:43 +00:00
Compare

Smart test results

Result: PASS

Scope: orbital_billboard, orbital_text

Reason: directly changed crates

Elapsed: 3m 38s

Workflow run

Overall: 27 tests, 26 passed, 0 failed, 1 skipped

Nextest: 26 tests, 26 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_billboard 11 11 0 0 - 4.06s
orbital_text 15 15 0 0 0/1 0.80s
pie showData
    title Nextest outcomes
    "Passed" : 26
pie showData
    title Doctest outcomes
    "Skipped" : 1
xychart-beta
    title "Slowest crates (nextest seconds)"
    x-axis ["orbital_billboard", "orbital_text"]
    y-axis "Seconds" 0 --> 4.1
    bar [4.06, 0.80]
<!-- orbital-ci-test-results --> ## Smart test results **Result:** PASS **Scope:** orbital_billboard, orbital_text **Reason:** directly changed crates **Elapsed:** 3m 38s [Workflow run](https://forgejo.sakul-flee.de/SakulFlee/Orbital/actions/runs/1227) **Overall:** 27 tests, 26 passed, 0 failed, 1 skipped **Nextest:** 26 tests, 26 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_billboard | 11 | 11 | 0 | 0 | - | 4.06s | | orbital_text | 15 | 15 | 0 | 0 | 0/1 | 0.80s | ```mermaid pie showData title Nextest outcomes "Passed" : 26 ``` ```mermaid pie showData title Doctest outcomes "Skipped" : 1 ``` ```mermaid xychart-beta title "Slowest crates (nextest seconds)" x-axis ["orbital_billboard", "orbital_text"] y-axis "Seconds" 0 --> 4.1 bar [4.06, 0.80] ```
Sign in to join this conversation.
No description provided.