Translator: GPU-encoded indexed triangle draws into indirect command buffers under the identity domains

What: the first cut of Metal indirect command buffers, the translator's half.

- pipeline::IndirectDrawLayout (public): the record contract the runtime and the lowering share.
  A 24-byte header (capacity, vertex and fragment slot counts and stride as u32, then the reset
  index address as u64 at 16), then command i at 24 + i * stride, stride = 8 (Nv + Nf) + 40:
  the slot words (the buffer's address less 2^31, the word an execution pushes as the slot's
  SlotGuestBase), the index token's data, the sequence index and VkDrawIndexedIndirectCommand.
- lower/access/icb.rs: under the identity domains, a function's render_command
  set_vertex_buffer, set_fragment_buffer, draw_indexed_primitives of triangles and reset write
  the records through the gpuResourceID an argument buffer's command_buffer member holds, each
  only where the command's index is below the capacity (and a slot below its stage's count).
  Every other indirect-command operation stays Unsupported{GpuEncodedIndirectCommands,
  NotImplemented}; a vertex or fragment function without its stage's store feature and a device
  without device addresses refuse by name.
- LoweringInputs::indirect_range with PushField::IndirectRange, PushField::IndirectSequence and
  PushField::IndirectBase: a vertex function of a state made with supportIndirectCommandBuffers
  reads the execution's range and its command (the sequence index plus its part's first command)
  in its first block and draws nothing for a command outside the range, so an execution over a
  range a buffer holds runs at full capacity (one SEQUENCE_INDEX token), in parts. Such a state's
  vertex function pulls every attribute it reads.
- Fixture engine/icb_indexed_extras (MSL we wrote, regenerated by scripts/regen-air-fixtures):
  a reset kernel, a vertex function that reads before its buffer's address, and one of fourteen
  vertex buffers (a state of more tokens than lavapipe's 16). Inventory rows added by hand (the
  fourteen-buffer vertex function's thirteen constant buffers pass the runtime floor's twelve);
  the golden hash rows, the air_input printout and the old render descriptor key come with
  development's bless.
- SEMANTICS_VERSION 2252 and ARTIFACT_FORMAT_VERSION 586 are placeholders one above
  development's (2251 and 585); the lowering's emission and the encoded lowering inputs change.
- docs/API.md states the forms; docs/REFUSALS.md regenerated; api_surface and api_signatures
  carry IndirectDrawLayout.

Why: the cutover's guests encode indexed draws into indirect command buffers from kernels, which
the identity domains refused.

Verified: see the lane's report (compile gate and test jobs, the states-only play).
This commit is contained in:
Anees Iqbal committed 2026-11-21 01:50:00 -08:00
1 parent 7fc969bc16
commit d9ba8d0e72
30 files changed
+1651 -24

No files matched your search

+12
View File
@@ -242,6 +242,18 @@ compile does. `DevicePolicy::default()` is `DevicePolicy::UNTRUSTED`:
An argument buffer's texture reads the element at its ID's index masked to its low 16 bits,
so a bad ID reads an element of the arrays ([RESOURCE-ID.md](RESOURCE-ID.md)); the change that
first lowers an argument buffer's sampler masks its index the same way.
A function writes an indirect command buffer's render commands, under the identity domains
alone, through the `gpuResourceID` an argument buffer's `command_buffer` member holds: the
device address of the buffer's records, laid out as `pipeline::IndirectDrawLayout` states. A
command's `set_vertex_buffer` and `set_fragment_buffer`, its `draw_indexed_primitives` of
triangles and its `reset` write them, each only where the command's index is below the
buffer's capacity; any other indirect-command operation is
`Unsupported{GpuEncodedIndirectCommands}`. A render pipeline state made with
`support_indirect_command_buffers` compiles its vertex function under
`LoweringInputs::indirect_range`: it reads the execution's range at `PushField::IndirectRange`
and its command, `PushField::IndirectSequence` (a part's sequence index) plus
`PushField::IndirectBase` (the part's first command), a command outside the range draws nothing,
and the function pulls every vertex attribute it reads.
Loops run as written: no execution bound is translated in.