perf: reduce inline object memory churn in 3D warp mode#121
Merged
Conversation
Stop per-frame inline entity rebuilds during warp animation, reuse cached Kitty plane assets, drop duplicate RGBA after upload, and clean up superseded RGP mesh handles when extrusion depth changes. Fixes orhun#120
There was a problem hiding this comment.
Pull request overview
This PR reduces memory churn and asset growth in 3D presentation when warp is active by avoiding per-frame inline entity rebuilds and by reusing cached GPU assets for inline Kitty and RGP objects.
Changes:
- Stop forcing
sync_inline_objectsevery frame during warp; instead animate Kitty plane vertices in place via a newanimate_inline_kitty_planessystem. - Cache Kitty plane mesh/material handles (and move Kitty RGBA bytes into the Bevy
Imageon first upload). - Reuse depth-keyed STL extruded mesh handles and remove superseded OBJ/STL mesh assets when extrusion depth changes.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/systems.rs | Removes per-frame warp sync for inline objects, adds Kitty plane asset caching + in-place vertex animation, and cleans up superseded OBJ/STL mesh assets on depth changes. |
| src/plugin.rs | Wires the new animate_inline_kitty_planes system into the update schedule after sync_inline_objects. |
| src/kitty.rs | Initializes the new Kitty plane cache field when rasterizing decoded Kitty images. |
| src/inline.rs | Introduces InlineKittyPlaneLayout + KittyPlaneCache and extends inline object structs to store cached Kitty plane and STL extruded mesh handles. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+809
to
+815
| if !matches!( | ||
| presentation.mode, | ||
| TerminalPresentationMode::Plane3d | TerminalPresentationMode::Mobius3d | ||
| ) || warp.amount <= 0.0 | ||
| { | ||
| return; | ||
| } |
Comment on lines
558
to
565
| pub struct KittyInlineObject { | ||
| /// Raster image payload. | ||
| pub raster: RasterObject, | ||
| /// Indicates placeholder-driven placement. | ||
| pub uses_placeholders: bool, | ||
| /// Cached plane mesh and material for 3D presentation. | ||
| pub(crate) plane: Option<KittyPlaneCache>, | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #120
Summary
animate_terminal_plane_warpfor the terminal surface)Imageon upload instead of keeping a duplicate copy in the inline registryProblem
In 3D presentation with warp active,
sync_inline_objectsran every frame viaforce_warp_sync, despawned all inline entities, and respawned meshes/materials without cleaning up Bevy asset stores. Kitty images also kept a full RGBA copy after GPU upload.Approach
force_warp_sync; inline sync now runs only whenTerminalInlineObjects::needs_sync()is trueanimate_inline_kitty_planesto update Kitty plane vertex positions in place during warp animationKittyInlineObjectand drop registry-side RGBA after first uploadBenchmarks
Measured locally on Windows, release build.
Idle 2D (~30s): no meaningful change (~833 MB working set before and after)
3D + warp + inline RGP object (~3 min, sampled every 15s):
Test plan
cargo checkcargo clippy --all-targets --all-features -- -D warningscargo fmt --all -- --check