mirror of
https://github.com/storytold/photocraft.git
synced 2026-10-27 03:17:05 -06:00
A duplicate shares its source's tiles (Arc), but its resident texture was new, so the compositor converted and uploaded every tile again: duplicating a 20 MP photo layer uploaded 330 tiles. When a new resident's surface shares tiles with another resident of the same role, region, texel kind, format and default pixel, its texture now starts as a copy of that one (Stats.tiles_shared counts the tiles taken) and the usual per-tile pass fixes up whatever differs. Layer textures gain COPY_SRC. The copy is recorded in the frame's encoder, after whatever brought the donor up to date this frame. Queued writes land before the encoder runs, so both textures are marked `ordered` and their writes go through the encoder from then on; otherwise a write to either in the same refresh would be overwritten by the copy or leak into it. A resident whose region only moved still keeps its own texels (keep_overlap) first. Duplicating a 20 MP photo layer in perf_scenarios: 25.1 -> 6.3 ms, 330 tile uploads -> 0 (RTX 3090, Vulkan). Paste is unchanged: the pasted layer has new tiles. Test: duplicates_copy_their_source_texture covers a plain duplicate (no uploads), a duplicate and its source each painted with one tile in the same refresh, and a duplicate missing a tile, all against the CPU composite. Without the `ordered` routing the second case is off by 167.6/255.