feat(metal4): add offline model cache baking tool #472
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/holdmysocks--SixNG!472
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-472"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@maple-quartz18 on GitHub · 2026-11-27 07:07 UTC · original
maple-quartz18:p2-offline-model-cache-bake→master· +524 −0 · 4 files · 2 commits · merged 2026-11-27 17:33 UTCWhat
Adds a
--bake-model-cacheCLI subcommand that scans.glbfiles under the work folder and pre-generatesSXMTLIO2caches, enabling batch pre-baking for large asset sets.build_vertex_index_bytes()and the P1 cache writers (model_identity/write_model_cache_entry), so cached bytes are byte-identical to what runtime upload expects — no second byte-layout source of truth..bufis re-read in 64 KiB chunks and its vertex/index payload CRCs are checked against the header, catching bit-rot from a partial write. Memory stays bounded regardless of model size.metal_io_models_v2,gui_cache_v4,cache) so generated artifacts are never fed back as inputs.found / baked / skipped / failed / verifiedcounts; per-file failures are logged and skipped, never aborting the batch.Why
Model upload previously only cached on first render (per launch). For very large asset sets it is useful to pre-generate the GPU-ready buffers ahead of time. This is the third and final step of the model-cache plan (P0 refactor → P1 runtime cache → P2 offline baking).
Design note
The tool is added as a CLI subcommand in
main.rs(gatedmacOS + metal4-poc, alongside the renderer), not as a standalone#[path]bin.glb.rs/render3d.rsreference manycrate::*modules (atmo,GUI_CACHE, …); a standalone bin would have to re-import the whole module closure and is easy to get wrong. The subcommand reusesmain.rs's already-complete module graph, needs nopub(crate)visibility changes, and touches noCargo.toml.Verification
model_bake_tests) covering header round-trip, idempotent write, identity change / bad magic / bad version rejection, vertex+index payload corruption detection, cache-dir skipping, and buf-only verification — all passing.cargo checked there).rustfmtparse check clean. Real macOS GPU smoke test of the cache-hit path remains tracked from P1.Cache writes remain best-effort; a failed or corrupt cache never blocks rendering.
@copilot-pull-request-reviewer[bot] on GitHub · 2026-11-27 07:07 UTC · original · reviewed
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.
@maple-quartz18 on GitHub · 2026-11-27 16:03 UTC · original
where are you from?