[perf][MEDIUM] Full 1 MiB font atlas re-upload on any single new glyph #51
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Catcrafts/Crafter.Graphics#51
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
Subsystem: Font / FontAtlas
Location:
implementations/Crafter.Graphics-FontAtlas.cpp:127-141Impact: MEDIUM · Effort: Medium
Problem
Updateuploads the entire 1024x1024 R8 atlas (1,048,576 bytes) wheneverdirtyis set — anddirtyflips the moment one glyph is rasterized. Vulkan does a full-extentvkCmdCopyBufferToImage+ host-write barrier + two whole-image transitions; WebGPU writes the full atlas. During warm-up/language-switch/size-churn this is ~one full-atlas copy per frame that adds a codepoint.Proposed fix
Accumulate a dirty bounding rect in
ShelfPlace/Ensure; copy only that sub-rect. The staging buffer is already laid out at full atlas row stride, so setbufferOffset = minY*kAtlasSize+minX,bufferRowLength = kAtlasSize,imageOffset/imageExtentto the rect. Reset the rect after upload. WebGPU'swgpuWriteAtlasRegionalready takes x,y,w,h.Correctness caveat
Layout transitions/barrier can stay whole-image (cheap); only the copy extent is load-bearing. Honor
optimalBufferCopyOffsetAlignment(typically 1 for R8) — round the rect origin down if a driver reports coarser.