Files
metal2vulkan/docs
Anees Iqbal bb4f53d209 Read a surface's own pixels through a snapshot at any area, where its image takes feedback loop usage
A draw that reads the texture its pass renders, at its own pixels after a barrier, takes a
snapshot drawn in its subpass, or splits the pass instance and reads a copy; both are exact. The
snapshot was open only to a texture of its own image, so a texture over a buffer's bytes always
split, and each split copies the bytes into the shadow before every instance after a barrier.
The consumer's guest renders its 1080p framebuffer, an IOSurface over host pages, this way.

Now:
- Device::storage_over_buffer tries the linear image that aliases a buffer's bytes with
  ATTACHMENT_FEEDBACK_LOOP_EXT usage first (it costs a linear image nothing; its memory is the
  buffer's), then makes it without where the driver refuses, and counts each image made with the
  usage in the new WorkCounts::feedback_loop_alias_images.
- Texture::snapshot_color reads such an aliasing image through a snapshot, as an image of its
  own, and a reader of a texture over bytes takes the snapshot at any area. The area rule for a
  texture of its own image is unchanged.
- Where the image lacks the usage (NVIDIA's drivers make it without), the surface's readers
  split, exactly as before.
- A pass with a depth or stencil attachment keeps every attachment reader on the split: the
  binder makes no snapshot variant for it, and a snapshot draw would write depth or stencil before
  the drawing draw. render/snapshot.rs's docs say so, and a lane case holds the behaviour.
- The attachment-read row of docs/FAST-PATHS.md states the crossover and the feedback loop
  condition.

Why: in the guest's frames the split's copies dominated (66 splits, 68.2 own-pixel reads and
16.6M texels of bounded copies a frame), while the readers' fragments touch about 1.5% of the
texels a split copies.

Verified, as the commits state:
- On the Iris Xe (release, the new ignored lane attachment_read_costs::snapshot_crossover, a 1080p
  surface over host pages, snapshot and split forced and alternated): the snapshot's GPU time per
  pass is 0.56x to 1.2x the split's; its worst case is a small scissor covered half or more,
  about 10 us a reader, and it is cheapest for sparse readers in big scissors, where the guest's
  readers sit.
- runtime_lane::snapshot_reads: readers over a surface take the snapshot where the image took
  the usage and the split elsewhere, with Metal's bytes either way. RTX 3090 and RTX 5080
  (aliased, no feedback usage) split and pass; the Iris Xe (aliased, feedback usage) takes the
  snapshot and passes; the other snapshot_reads tests pass on all three.
- The depth/stencil case (Less depth with and without writes, a stencil test that blends each
  pixel once): every reader splits and leaves Metal's texels on the Iris Xe, the RTX 3090 and
  the RTX 5080; all 7 snapshot_reads tests pass on the RTX 5080.
- clippy plain, m2v_gpu and m2v_cpu_icd.
2026-10-19 00:16:00 +03:00
..