Files
metal2vulkan/docs
Anees Iqbal efcb6851ce The encoder trail: name the encoder a stalled GPU stopped in, and the last one that completed
A GPU hang (a CTX SWITCH TIMEOUT on an RTX 3090) left the runtime with no way to say which
encoder never completed: encoders share batches and grouped submissions, and neither
METAL2VULKAN_LOG_PASSES nor METAL2VULKAN_QUEUE_TIMES logs anything at a stall.

METAL2VULKAN_ENCODER_TRAIL (env_vars.rs), or DeviceOptions::encoder_trail for one device, is a
default-off diagnostic (encoder_trail.rs):

- Each encoder, and each part of one a host step splits off, ends its batch (Batches::alone),
  and no batch waits in a group, so each goes in a vkQueueSubmit of its own that signals its
  queue's timeline. When work goes to the driver changes; what it computes does not.
- Each encoder notes what it was: its kind, its command buffer's object ID, its place, a
  render pass's area, samples, attachments' formats and sizes, instances and rate map, its
  indirect command executions, and the label hash of each state it bound (the first 8 bytes
  of a SHA-256 of the state's label and its functions' names; no name, no shader text). A host
  step adds the states its indirect commands named, as the GPU and the CPU left the records.
- Once no work of the device advanced for 2 s with some pending, completion.rs's stall path
  logs one Info line (id name metal2vulkan-encoder-trail) for each VkQueue whose oldest batch
  is pending: that batch's encoders and the last batch the queue completed, with how long
  before; once a stall.
- A submission a host step makes and waits for itself (a rasterization-rate map's fan-out
  probe, a predicated loop's check run again) signals no timeline; once it ran 2 s, one line
  names it, the encoder whose step made it and the states its commands named.

Off, a device reads the switch once and notes nothing.

Verified on msi (lavapipe, --cfg m2v_cpu_icd), at the branch tip this commit's tree equals:
- tests::stall::the_encoder_trail_names_the_stuck_encoder_and_the_last_one_completed: a cb
  stuck on an event wait before two blit fills; the line names the stuck cb's encoder 0 (not
  its encoder 1) and the earlier completed cb's encoder 0:
  "VkQueue 0's oldest pending batch: Blit encoder 0 of command buffer 3, states []; the last
  batch it completed: Blit encoder 0 of command buffer 2, states [] (2.106823047s before)".
- tests::rate_mapped_fan_out::the_encoder_trail_fans_out_the_same_pixels: with the trail on,
  probes/flagged/fanned [1, 1, 6] as without, no texel differs from the encoder's own draws.
- The host-step families (rate_mapped_fan_out, rate_mapped_pieces,
  indirect_command_buffer_device, host_step_neutrals, ycbcr_in_place_loop) with
  METAL2VULKAN_ENCODER_TRAIL=1: 11 passed.
- encoder_trail's unit test (one state's hash pinned: a reader of the pipeline creation log
  computes it again); the runtime suite 1504 passed; api_ tests 16 passed; clippy all features
  and the runtime under m2v_gpu and m2v_cpu_icd; rustdoc of the runtime and metal2vulkan.

The runtime-sources pin moves (not re-pinned here).
2026-11-12 20:33:17 -08:00
..