RUNTIME 2268: record consecutive compute encoders of a command buffer into one VkCommandBuffer

A command buffer of N one-dispatch compute encoders went to the queue as
2N - 1 command buffers (each encoder's primary and a kept barrier command
buffer before it). A compute encoder now records on in the tail of the
compute encoder before it where nothing needs a boundary: same dispatch
type and logging, same batch (no event wait or signal, no host step), the
earlier encoder one plain part (no segment, no fence update, nothing
failing or faulting), no command predication, encoder trail off,
protection options 0.

The barrier between the two is recorded per command by the tracker's own
rule between two encoders of a batch (encoder_fold::FoldOrder), joined with
the encoder's own serial barrier into one vkCmdPipelineBarrier. The folded
encoder's uses and fence waits join the group's first part's summary, so
the batch's plan orders the group as a whole; its own part keeps its fence
updates alone. A rebind encodes a group again whole or not at all; a
failure that fails one encoder of a group fails the group (docs/API.md
section 10, "A command buffer committed as failed"). Counted:
WorkCounts::encoders_folded. FAST-PATHS: the ANV command-buffer row notes
folded encoders begin none.

Also: the dispatch_chain example (gbkern, dchain): a chain of dependent
dispatches by how a command buffer holds them (encoders, serial, raw
barrier, raw split), with each shape's first command buffer's counts.

RUNTIME_VERSION 2268: compute encoders fold into one VkCommandBuffer.

Verified (dchain, at d7e4a9ce51, the same diff before its rebase):
- lavapipe (m2v_cpu_icd): 40 tests incl. 8 new tests::encoder_fold (dependent
  chain, independent encoders take no barrier, dispatch-type change, fence
  update ends a group, commit_failed inside/at a boundary, rebind re-encodes
  a group whole).
- RTX 5080 (m2v_gpu, b5080): 190 touched-family tests; FOLD-CHAIN folded 23,
  begun 1, barriers 17, 0 wrong words.
- 5080 dispatch_chain, encoders shape, GPU us a dispatch: 1000: 8.41 -> 2.92,
  2300: 7.43 -> 2.92 (raw barrier 2.92); vkQueueSubmit per command buffer at
  2300: 1007 -> 44.6 us; command buffers submitted 2N -> 2.
Owed after landing: the negative control (fold barrier removed reads wrong
words), clippy x3, rustdoc, the full lavapipe runtime suite at the rebased tip
(m3-max-28507), the 780M and XTX before/after.

Squashed from steelbrain/dchain f51ba34c37..2f2000cfbc.
This commit is contained in:
Anees Iqbal committed 2026-11-14 00:57:33 -08:00
1 parent 6fa87a4c0c
commit dd286c7304
20 files changed
+2361 -183

No files matched your search

+16
View File
@@ -5349,6 +5349,22 @@ each item named states the rule in full.
rasterization-order access) or on a device without the interlock, such as the Radeon RX 550
(the runtime's `render/snapshot.rs`, `texture/attached_reads.rs`).
**A command buffer committed as failed** (`CommandBuffer::commit_failed`)
- **A failure inside a group of compute encoders recorded into one `VkCommandBuffer` fails the
whole group.** The runtime records a compute encoder into the `VkCommandBuffer` of the compute
encoder before it where nothing needs a boundary between them: the same dispatch type, the same
batch (no event wait or signal between them), no fence update or work left for later in the
earlier one, no command predication, the encoder trail off (`DeviceOptions::encoder_trail`) and
protection options 0 (`WorkCounts::encoders_folded` counts each). That `VkCommandBuffer` runs
whole or not at all. So a `FailedEncoders::From(n)` whose `n` lies inside such a group, and a
`FailedEncoders::Set` that names an encoder of one, run none of that group, where Metal runs the
group's encoders before `n` and those the set leaves out. A failure from an encoder on that the
runtime makes itself (a fault, a recording failure) is widened alike. A `From(n)` at a group's
boundary fails what it failed before: an `n` that names an encoder that is not a compute
encoder, one made under protection options, or the first compute encoder after another kind of
encoder, a change of dispatch type, an event wait or signal, or a fence update.
**GPU hangs and faults** (a draw of private primitive type 9, `DrawPrimitiveType::Nine`)
- **A hang reads `Scheduled` 5.06 ms after its commit and completes no sooner than 27.5 ms after