Files
metal2vulkan/docs
Anees Iqbal 90a02e250d identity domains: a checked access's domain is its buffer, not its bind window
Metal's domain for a buffer argument is the buffer: an access before the bind offset reads the
buffer's bytes there. The containment check measured the offset from the bind offset against
the bytes from there to the buffer's end, so a checked access before the bind offset read zero
and a store there did nothing, where Metal reads and writes the buffer.

- PushField::SlotRemaining (u32) becomes PushField::SlotBounds (uvec2): the buffer's bytes
  before the bind offset (the bind offset), then its length; a set*Bytes copy 0 and its length;
  nil 0 and 0. The check is psb::in_buffer: (len >= n) && (m + before <= len - n) in u32, m the
  offset from the bind offset read as signed. Before the buffer's start the sum wraps to at least
  2^31, past every length (no buffer is longer than 2 GiB). One add more per checked access and
  one more pushed u32 per checked slot.
- Offsets are signed on every identity form: the word-below form (psb::prepare_at, also the
  pulled fetch's) now sign-extends the offset instead of reading it from the slot's window start,
  as the direct form already did through its 2^31 bias.
- The new runtime's encoders push the bounds (encoder::bounds, Tables::bounds); the old runtime's
  binder writes them from the bound buffer and still refuses ZeroAddress.
- The old runtime's lowering is unchanged; SEMANTICS_VERSION 2195.

Tests: engine_identity_domain (new, interpreter): on both identity forms a run-time -4 at bind
offset 16 reads the word at 12 and at bind offset 0 reads zero, a constant -4 at bind offset 16
reads the word at 12, and the default domains read the word at 12 as docs/API.md says.
engine_identity_contain adds an access before the bind offset (inside the buffer: read and
written) and one before the buffer's start (outside). The identity tests push the bounds.

Docs: API.md sections 1 and 5 and the new runtime's README state the domain and the cost.
2026-11-19 17:24:00 -08:00
..