perf(image): release static texture staging after upload (#114) #136
No reviewers
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Catcrafts/Crafter.Graphics!136
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "claude/issue-114"
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?
Problem
ImageVulkanallocated a dedicated imageVkDeviceMemoryplus a persistent HOST_VISIBLE stagingbuffer(sizedw*h), kept mapped for the image's whole lifetime — andDestroy()never freed it. Static textures (e.g. Sponza albedo, uploaded once) pinned host-visible / small-BAR memory forever.Fix
Updatenow releases the staging buffer viaVulkanBuffer::DeferredClear()right after recording the buffer→image copy — routed through the same fence-keyed deletion queue (#101/#102) the compressedMeshpath already uses, so the allocation outlives the upload submit and is freed once that frame clears.A new
streamedflag (set byFontAtlas) keeps the persistent map for images re-uploaded from a CPU-side staging buffer every frame; those uploads go throughUpdateRegion, which never releases.Destroy()now also frees any staging the image still owns, gated on a live handle so a released static texture can't double-free.Both the plain and compressed (GPU + CPU-fallback) upload paths share one
ReleaseStaging()helper.Tests
Adds
tests/ImageStagingRelease, driving the real upload + image→buffer readback on a headless device. Asserts:Updatereleases the staging (no handle pinned) and enqueues exactly one allocation tagged with the current frame;framesInFlightframes;streamedimage keeps its staging acrossUpdate/UpdateRegionand frees it validation-clean onDestroy().Full suite: 21 passed (
ImageStagingRelease: 17/17 assertions, zero validation errors).Resolves #114
🤖 Generated with Claude Code