Files
metal2vulkan/crates
Anees Iqbal dd986f0aae Drop a carried shadow's image when another shadow over its bytes writes them back
What: ShadowSync::copy_back, which records a copy back or a merge of one shadowed texture's
writes into its truth, now also drops from the encoder's carry (ShadowCarry) every carried image
of another texture that shares that truth. The dropped texture copies in again at its next use.
The doc of copy_back and ShadowCarry's list of what ends a carry say so.

Why: copy_back already left every other texture over the bytes that the encoder had met no
longer current (or stale inside the written rectangle). An image the command buffer carried from
an earlier encoder, for a texture this encoder never met, stayed carried: the shadow copies are
recorded through EncoderCore::shadow_command, which never reaches ShadowSync::wrote. So the next
pass over that texture rendered over texels the bytes no longer held, and wrote the result back.
This breaks the module's copy-in rule, under which a texture copies in again after another
shadowed texture over its bytes wrote them. The fix is structural: whatever writes a truth
through one shadow ends the carry of every other shadow over that truth, whether merged back or
copied back.

Verified on the M3 Max (MoltenVK 1.4.2), --cfg m2v_gpu, under maclock and memcap:
- tests::shadow_twins: both cases pass. They failed on the commit before, which is the negative
  control (3,927 and 5,318 bytes differed). With the fix, every pass after a pass over the other
  texture copies in again: 76,800 texels copied in, none taken from the carry.
- The unit case in a_carried_surface_is_dropped_by_anything_that_lets_another_writer_in passes;
  before the fix it fails.
- The runtime's shadow, merge_scratch, linear_runs, dirty_pages, blit_cover, cpu_copy_layouts,
  fresh_pages, copied_log, in_place and linear_plan tests: 123 of 123 passed.
- Validation runtime_lane shadow, padded and linear: 91 of 91 passed.
clippy --all-targets --all-features -D warnings passed plain and with --cfg m2v_gpu, and cargo
fmt was run. RUNTIME_VERSION and the runtime-sources pin are unchanged.

(cherry picked from commit 73b62e05fd00b75b5ef1ff74952307fc68020197)
(cherry picked from commit 5d3ee8792e7a7f65985cf806de1e829e11b6e8c5)
2026-11-03 15:58:54 -08:00
..