Repository navigation
fix(image): free empty shelf page buffers in ImageAtlas::end_frame when higher pages remain active - #2115
Merged
Conversation
…en higher pages remain active
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.
Refs #2103
Root cause
ImageAtlas::end_frame(crates/rune-image/src/pixels.rs), a page left with zero slots only clearedpage.data = Vec::new()whenpage.width > IMAGE_ATLAS_SIZE || page.height > IMAGE_ATLAS_SIZE.<= 1024x1024shelf page sat below a higher-indexed active page,self.pages.truncate(keep)could not remove it, leaving up to 4 MiB of CPUVec<u8>allocated and keeping its 4 MiB GPUwgpu::Texturealive inRenderer::upload_images(crates/rune/src/render/upload.rs) untilrest().Change
page.data = Vec::new()inImageAtlas::end_framefor every page left with zero slots (regardless of dimensions).ImageAtlas::allocatealready re-initialises empty pages on demand viaImagePage::new(w, h), andRenderer::upload_imagesdrops the GPU texture wheneverpage.data.is_empty().ImageAtlas::invalidatesodirtyis not leftSomeon a pageupload_imagesskips.Before / after (3 pages: 4x512 on p0, 4x512 on p1, 1x64 on p2; next frame draws only p2)
pages.len()upload_imagesSome(1024x1024)(4 MiB)None(0 B)Verification
empty_middle_shelf_page_frees_buffer_and_reuses_cleanly(crates/rune-image/src/pixels_tests.rs, failed without fix holding 4,194,304 B, passes with fix) andgpu_empty_middle_shelf_page_drops_texture_on_upload(crates/rune/src/render/image_tests.rs).cargo test -p rune-image(85 passed, 9 doctests passed),cargo test -p rune -p rune-mermaid -p rune-kit --features rune-kit/markdown,rune-kit/mermaid render::image_tests(12 passed), macOScargo test -p rune-image pixelsandcargo clippy -p rune-image -p rune --lib --bins --tests, Linuxcargo check -p rune -p rune-kit --tests, andscripts/file-size.sh.