Files
metal2vulkan/docs
Anees Iqbal 31b19fa7f0 In-place check: the writer sweeps the bytes beside the texels until the step ends, and a draw round
On the Iris Xe the verdict for render targets over pages imported by their pointer flipped from
run to run. Devices without validation layers Failed 7 of 7 checks; devices under validation
Passed 3 of 3 (m3-max-6011, 6068).

A probe ran each step alone over the check's pattern, 100 rounds a step (m3-max-6080). One step
changed a byte beside the texels: a render pass that clears and stores the image. It did so in
77 of 100 rounds of a 100x50 BGRA8Unorm image with rows 512 bytes apart, and 51 of 100 of a
33x17 RGBA16Float image at that pitch. The changed bytes were the ones after a row's last texels
in their 64-byte line (columns 400-409 of a 400-byte row, 284-314 of a 264-byte row). Each read
back the pattern where the CPU had written its complement during the step: the device wrote the
line back as it had read it before the CPU's write. Nothing changed in 100 rounds each of the
first move, the feedback loop moves, a pass that loads and stores, or a pass that clears and does
not store. Rows that end on a line never changed (RGBA32Float 20x9 at 320 bytes, BGRA8Unorm 64x16
at 256), and neither did a 3840x2160 surface with tight rows (25 rounds).

The old writer wrote each byte once, as the step began, so it caught the write-back only where
one of its writes fell between the device's read of the line and its write. A step that begins
later, as under validation layers, finds every write already made. The writer now sweeps the
bytes beside the texels, in the stride's order, until the step ends. Each sweep writes the
pattern changed by a value of its own (mark), reading each byte first, which must still hold the
previous sweep's value. The compare then wants each byte's last sweep's value.

A draw round: after the clear-and-store pass, each render round draws zero through a scissor of
the image's last column in a pass that loads and stores the image. The draw is the crate's own:
bind::check_draw_modules provides the planes merge's triangle and a fragment stage that writes a
vec4 of zeros; the runtime's check_draw.rs keeps a render pass and pipeline per color format for
the class's rounds. A device whose draws write back the line that holds a row's last texels now
fails the check whatever its clears do, and the Iris Xe's draws do.

ROUNDS stays 3, sized from the measured rate (its doc comment): four shapes' rows end inside a
line, so there are twelve chances. CHECK_VERSION 5, so records of the old check are not read.
FAST-PATHS: the in-place row says what the render rounds run and how the writer writes. Known
gaps gains the finer class this leaves open: on the Iris, rows that end on a 64-byte line read
0/100 and could take the image in place there.

Verified on the Iris Xe (ANV, Mesa 26.2.6), m3-max-6226, at the probe branch's 39a5dd1ccd (this
code, with CHECK_VERSION 4, plus a probe test):
- Per step, 200 rounds each, the old writer against the new one:
  - clear and store: 96 and 14/200 against 169 and 192/200;
  - draw alone: 188 and 183/200 against 200 and 200/200;
  - the whole render round: 160 and 1/200 against 198 and 200/200;
  - load and store, and the first move: 0/200 each under both writers.
- The whole check on 20 fresh caches without validation: Pointer and Fresh renders Failed 20/20,
  writes Failed 20/20, reads Passed 20/20, 156-342 ms a check.
- runtime_lane::in_place_textures::a_failed_check_keeps_the_shadow_and_no_record 20 times, a
  fresh check under validation each: renders Failed 20/20, passed 20/20.
- Correct devices stay in place with the new writer and the draw round, the whole check on 5
  fresh caches each: M3 Max, MoltenVK 1.4.2 (m3-max-6160, at 733cb8a13b, this check before the
  rebase), all nine verdicts Passed 5/5; RX 7900 XTX, RADV, Mesa 26.2.6 (m3-max-6523, this commit
  plus the probe test, steelbrain/selfread-tipprobe c3b241244e), all nine Passed 5/5, 626-642 ms a
  check.

(cherry picked from commit 0cff30259ed6a7cba9bfcabb02643650204c1e79)
2026-11-07 19:55:50 -08:00
..