Files
metal2vulkan/crates
Anees Iqbal 0c7fe68d25 RUNTIME_VERSION 2076: an image a storage form swapped out leaves the recycler's book before it is destroyed
The branch before this commit fixes a host process abort on MoltenVK. texture/recycle.rs keeps a
book of live images keyed by their VkImage handle, so a released image can be parked under its
making and handed to a later texture of the same descriptor. A texture's first image, which its
storage form swaps out, was destroyed with the swapped-out ImageObjects when the switch's command
buffer completed, but it never left the book. MoltenVK's handle is the image object's address, so
a later image often got the same handle. When that image was one the book doesn't hold (a Shared
or Managed texture's host-copy image, or a shadow), its release found the stale entry and parked
it under the old making. The next texture of that making took an image of another format and
size: a BGRA8Unorm render target over an RGBA16Float image. Copies and views between the two then
failed (vkCmdCopyImage between incompatible formats) and Metal's view validation aborted the
process. Now ImageObjects::drop takes the VkImage out of the book before destroying it, which
covers every image destroyed there: a storage form's first image, a storage form image that
never swapped in, and the detach swaps. Every other image in the book leaves it at
Image::release, parked or forgotten.
WorkCounts::object_churn.swapped_out_images_forgotten counts the images ImageObjects::drop takes
out of the book, the entries that went stale before the fix. It is a new field, so object_churn
recordings gain a key wherever a case takes a storage form (re-blessed on development).

Verified:
- The consumer's Dock-restart boots on the M3 (cold 26.6.2 arm64 guests under HVF, MoltenVK
  1.4.2, its tree at pin 41): with the fix (566d8170c7), 0 of 5 died (m3-max-18407); at base
  269d7066c4, 3 of 3 died (m3-max-18370) with the same assertion (RGBA16F base, RGBA8Unorm or
  BGRA8Unorm view). Earlier rates at pin 39: 2/2, 2/3, 2/4, 2/3.
- Before the fix on the M3 (m3-max-18359, 911eacfa3c), the storage-form recycle test FAILED with
  the whole chain: storage forms 1, the first image left the book false, its handle given again
  true, parked images the next target took 1; MoltenVK gave the handle to a Shared RGBA16F 64x64
  host-copy image, which parked under the BGRA8 target's making, and the next target's pass
  failed at commit with EncoderAbandoned.
- After it, lavapipe with the Khronos validation layer (m3-max-18441): 61 tests passed (the new
  swapped_out_book and texture_holds tests, recycle, first_move, staging, blit_holds,
  encoder_holds, self_read_storage); validation errors 0; swapped_out_book: the image left the
  book, counted 1, the next target took 0.
- texture_holds (a texture released while its committed command buffer is pending) found no
  VUID-vkDestroyImage-image-01000 under the layer.
- Lint: clippy -D warnings on the runtime plain (m3-max-18426), --cfg m2v_gpu (18429) and
  --cfg m2v_cpu_icd (18436); rustdoc -D warnings (18437); signatures.py --check.
Not yet run: the post-fix M3 runs of the new tests (18430, and under the layer 18433), and the
negative control (the forget removed, swapped_out_book expected to fail, 18451).
2026-11-11 19:22:38 -08:00
..