Add opt-in hardware cache for Animate bitmaps - #56
Open
Tutez64 wants to merge 2 commits into
Open
Conversation
Contributor
Author
|
Follow-up: fixed a case where the same bitmap was referenced by both a hardware-compatible shape and a software/scale9 shape. Cache preparation now classifies all bitmap-fill references before instantiation, so shared assets remain CPU-readable regardless of creation order. Hardware-only assets are still disposed as before. |
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.
Summary
This adds an opt-in
swf_hardware_bitmap_cachedefine that allows Animate bitmap assets and compatible bitmap-filled shapes to discard their CPU-side image data after upload to the GPU.The implementation:
BitmapDatafor direct bitmap symbols;disposeImage()only for hardware-compatible assets;The feature is opt-in because discarding the CPU-side image prevents later pixel access and makes context restoration impossible without reloading the asset. It should therefore only be enabled when these bitmaps are immutable GPU resources and a graphics-context loss can be handled externally.
Benchmark
SWFAnimateHardwareBitmapCacheRepro.zip
It loads 64 distinct 1024×1024 bitmap assets, creates four instances of each, and retains a large stable object graph to measure full-GC pauses.
Five alternating runs produced the following results:
The optimization consistently saves about 256 MiB, matching the discarded pixel buffers. It does not produce a measurable reduction in full-GC pause times in this benchmark, since raw bitmap data contributes to the heap size but does not contain object references that the marker needs to traverse.
Real-world validation
These values should be considered indicative rather than a controlled benchmark.
This confirms a substantial reduction in retained memory without an observed GC regression. It does not demonstrate a direct improvement in GC pause times, so the primary purpose of this change is reducing memory retention and system memory pressure.
No visual regressions were observed with the final hardware/software cache classification.
Testing
The Animate tests run both with and without
swf_hardware_bitmap_cache.Validated with:
Note: until 159db83 from #55 is merged, the Haxe 3 CI jobs may still fail earlier in AnimateTimeline.hx, independently of this PR.