Files
metal2vulkan/docs
Anees Iqbal 325e88c276 Runtime: an indirect offset off 4 is Metal's documented refusal; arguments past the end are ours
Refusal::IndirectOffset covered two cases under one `ours` basis. Metal's headers document
the first: "indirectBufferOffset must be a multiple of 4" (MTLComputeCommandEncoder.h for
dispatchThreadgroupsWithIndirectBuffer:indirectBufferOffset:threadsPerThreadgroup:,
MTLRenderCommandEncoder.h for the indirect drawPrimitives and drawIndexedPrimitives; Apple's
page for the indirect drawPatches sends its offset to the feature set tables, whose minimum
constant buffer offset alignment is 4 bytes). The headers state no rule for the second,
arguments that run past the buffer's end, which is the runtime's own check because Vulkan's
indirect commands read inside the buffer (VUID-vkCmdDispatchIndirect-offset-00407,
VUID-vkCmdDrawIndirect-drawCount-00487, VUID-vkCmdDrawIndexedIndirect-drawCount-00539).

- IndirectOffset { offset, length } is now the offset-off-4 case alone, Basis:
  metal-documented.
- New IndirectArgumentsPastEnd { offset, length, needed }, Basis: ours, for arguments at a
  multiple of 4 with fewer than `needed` bytes (12 dispatch, 16 draw, 20 indexed draw) after
  the offset, or an end that overflows.
- Both raise sites (the indirect dispatch, and the indirect draws' shared check) test the
  alignment first, then the length.
- Regenerated docs/REFUSALS.md and error/basis.rs (refusal_surface.py), and
  api_signatures.tsv (one variant added). The runtime README's indirect-draw paragraph
  names both refusals.

Tests: every_device_refuses_an_indirect_dispatch_off_4_or_past_the_buffer_s_end (compute)
and every_device_refuses_an_indirect_draw_off_4_or_past_the_buffer_s_end (draw) assert each
variant and its basis(): off 4 at 2 and at an offset that is also past the end (alignment
first), past the end at a multiple of 4 and at an overflowing offset, an indexed draw's 20
bytes where a plain draw's 16 fit; then the arguments in each buffer's last bytes dispatch or
draw and their results are read back. The compute refusal test's two IndirectOffset asserts
moved into the dispatch test.

Checked here: refusal_surface.py --check and signatures.py --check pass (source only).
2026-11-21 15:33:10 -08:00
..