Files
metal2vulkan/crates
Anees Iqbal c5da2920fd Fix the M3 lanes' MoltenVK findings: cache hits, expected notices, CPU-write rows
The Mac triage work packet: what MoltenVK on the M3 Max reports, counted and expected as it is.

Count a pipeline found in its cache where every stage says so, as MoltenVK reports it:
The shader cache's driver_pipeline_hits counted a making as found in its cache only where the whole
pipeline's VkPipelineCreationFeedback said APPLICATION_PIPELINE_CACHE_HIT. MoltenVK 1.4.1 never sets
that bit for the whole pipeline: it sets it on a stage's feedback alone, where it found the stage's
converted Metal function in the pipeline cache (MVKPipelineCache::getShaderLibraryImpl), and leaves
the whole pipeline's feedback VALID (MVKGraphicsPipeline, MVKComputePipeline; read in MoltenVK
v1.4.1's MVKPipeline.mm and MVKShaderModule.mm). The runtime chained no stage feedback, so on
MoltenVK every making from a record counted as a miss, and the statistics' doc ("On every driver,
MoltenVK's included") was false there. The specification allows either form: the bit "specifies
that a readily usable pipeline or pipeline stage was found in the pipelineCache", and "when an
implementation sets this bit for the entire pipeline, it may leave it unset for any stage".

A making now chains each stage's feedback too (a graphics pipeline's where it has at most five
stages, VUID-...-06594; a compute pipeline's one, VUID-...-06566), and shader_cache::found_in_cache
counts a hit where the whole pipeline's feedback is valid and says the hit, or where every stage's
is valid and says it; a miss where the whole pipeline's is valid otherwise; nothing where it is not
valid. A driver that sets the bit for the whole pipeline counts as before. No MoltenVK check: only
what the feedback structures say. The ShaderCacheStatistics docs state the rule.

RUNTIME_VERSION 1190 (a making chains more feedback; the statistic changes on MoltenVK).

Verified on the M3 Max (macOS 27.0.1, MoltenVK 1.4.1), release --cfg m2v_gpu:
- shader_cache::found_in_cache's unit test (whole hit; whole valid and every stage a hit; mixed;
  no stages; not valid) passes, with the runtime's other shader_cache tests (18 of 18).
- runtime_lane::pipeline_records, at the round's first composed tree plus this branch: all three tests that
  failed at 61a2efc7d3 and fd22785008 ("the driver reported (0, 1), not (1, 0)") pass; the second
  device now counts pipeline_hits=1 pipeline_misses=0 at creation and 2/0 after its draw, from
  MoltenVK's stage feedback. The module's other tests pass.
- the_runtime_sources_are_the_committed_ones passes with the new pin.
- By source, the count is unchanged where drivers set the whole pipeline's bit: RADV sets it on the
  whole pipeline alone (radv_pipeline_graphics.c, radv_pipeline_compute.c), Mesa's common
  vk_pipeline.c (ANV and others) sets it exactly when every stage hit, lavapipe on neither. Not run
  here on NVIDIA, RADV or ANV.

Expect a MoltenVK device's kept-cache message in the creation sink lane:
degrade_notices::a_creation_s_notices_and_messages_reach_the_sink_on_the_asking_thread failed on the
M3 Max (MoltenVK 1.4.1) at 61a2efc7d3 and at fd22785008 alike: as a device is made on a driver
that keeps its internal pipeline cache and that cache is Metal's own (device/create.rs,
kept_cache_is_metals), the runtime sends the informational message
metal2vulkan-driver-pipeline-cache-kept, which creation_heard_checked did not expect (it expected
metal2vulkan-unmeasured-driver alone).

creation_heard_checked now expects that message, after the unmeasured-driver one, exactly where the
lane reads from the driver that it keeps its cache (driver_keeps_pipeline_cache: no
VK_KHR_pipeline_binary, no VK_KHR_maintenance5, or no internal cache control) and the cache is
Metal's (the runtime's own predicate, kept_cache_is_metals, which creation_kinds now shares). The
message must name the device and end in its id name. Test only.

Verified on the M3 Max (macOS 27.0.1, MoltenVK 1.4.1), release --cfg m2v_gpu:
- the test fails at 61a2efc7d3 and passes at the round's first composed tree plus this branch, with every
  other degrade_notices test that passed before (passes_degrade_once_per_kind still fails on macOS
  27's missing 8-sample textures, as before).

Expect the GPU-time reads' notice in the mesh object lane:
mesh_draws::object_draws_store_metals_words failed on the M3 Max at 61a2efc7d3 and fd22785008 alike:
each pass the lane runs reads its command buffer's GPU times for its timing line, and on MoltenVK
1.4.1 (DriverFact::TimestampsWaitForEveryQueue) that read announces gpu-times-from-host, which the
lane's exact list of kinds left out. It now adds gpu_times::read_kinds, as first_use does for its
own reads. Test only.

Verified on the M3 Max (macOS 27.0.1, MoltenVK 1.4.1), release --cfg m2v_gpu:
- the test fails at 61a2efc7d3 and passes at the round's first composed tree plus this branch, with the
  module's other tests.

Let the layer's clear message about a Metal-texture image pass as its known gap:
window_surfaces::programmable_blends_over_host_pages failed on the M3 Max at 61a2efc7d3 and
fd22785008 alike on VUID-vkCmdClearColorImage-image-00003: the pass clears a color its first
instance leaves out before the pass (render.rs, Clears), and that color's image is an imported
Metal texture, which Vulkan treats as bound but Vulkan-ValidationLayers 1.4.357 does not model (the
gap metal_import_gap.rs already lets pass for barriers, views, framebuffers, descriptors and copy
sources). The clear's message joins the list, with its text in the shape tests; still only for an
image the runtime named as a Metal texture, and only on the layer release read. Test only.

Verified on the M3 Max (macOS 27.0.1, MoltenVK 1.4.1, layer 1.4.357), release --cfg m2v_gpu:
- the test fails at 61a2efc7d3 and passes at the round's first composed tree plus this branch, with the
  module's other tests; metal_import_gap's four shape tests pass with the new message.

Write the CPU-write lanes' rows where no tile a draw reaches holds them:
linear_attachments::a_cpu_write_at_an_undrawn_pixel_survives_{a_loaded_pass,a_pass_apart} failed on
the M3 Max at 61a2efc7d3 and fd22785008 alike, always "4142 of 16384 bytes kept". The lanes wrote
the last 8 rows while the pass ran and took Metal to keep them. Metal does so only by timing: it
stores each tile a draw reaches whole, those rows too. Measured through Metal alone on the M3 Max,
macOS 27.0.1 (26A434), with the lane's pass (512x256 BGRA8Unorm over a no-copy buffer, Load and
Store, the zwd_panel blend, the scissor, the shared event) at 6000 panels: with 8 rows left out, a
write late in the pass kept 5163, 11282, 13322 and 11282 of 16384 bytes (and 5163, 11281 beside a
stencil attachment); with 64 rows left out, every byte at each of 11 delays across the pass (7
beside the stencil). Metal stores no tile no draw reaches. The runtime's pass on MoltenVK is that
Metal pass (a MoltenVK call trace shows nothing else touching the image meanwhile), slower per draw,
so its write landed inside the bottom tiles' window.

The lanes now leave out the last 64 rows, which no tile a draw reaches holds, where Metal's answer
does not depend on timing; a copy back of the area by the merge would still be caught. Test only.

Verified on the M3 Max (macOS 27.0.1, MoltenVK 1.4.1), release --cfg m2v_gpu:
- both tests fail at 61a2efc7d3 and pass at the round's first composed tree plus this branch, with every
  other linear_attachments test. The Metal readings: a probe program of the lane's pass in Swift
  over Metal alone, its CPU write at delays from 0 to 11 ms.

Versions: RUNTIME_VERSION 1199 -> 1200. RUNTIME_VERSION moves: how a pipeline found in its cache is
counted on MoltenVK changes. crates/metal2vulkan-validation/runtime-sources.sha256 holds
d495df50a3dff8090fad17ec55742a34374aa6c32544cacd63fd9c497e64d0b1, the hash of this tree's runtime
inputs (runtime-pin.py, which reproduces build.rs's). Version numbers quoted above are the values
the work's branch built with. Each part's Verified lines name the tree it ran at.
2026-10-14 20:17:37 +03:00
..