Runtime, translator docs and validation: the bound form's contract, its README floor entry, and the suites' pins

docs/API.md: section 1's bound kernel buffers (the query's features and every limit set 0's
layout reaches, the four kinds of slot that keep their address by structure), section 5's
SlotBindOffset view, and the accepted difference of a bound buffer's out-of-bounds reach: up to
15 bytes before a buffer off 16 and up to 3 past a length off 4 where
robustStorageBufferAccessSizeAlignment is 4 (none on NVIDIA), reads and writes landing in the
same process's memory, its own or shared with it by name, and past a buffer the consumer placed
by heap_buffer_size_and_align the block's padding (zero or the same device's earlier bytes,
never another device's). The runtime README: the extension row, the Bound kernel buffers floor
entry with its feature table (pool_reach's runs: Iris Xe, 780M, XTX and RTX 3090 bound, jobs
m3-max-75037..75040; the 780M under AMDVLK, which lists no VK_EXT_pipeline_robustness at the
runtime's Vulkan 1.3, in the address form, m3-max-75041/75042), the counters, and the check's
known gap. The placement comments at encoder::view and HEAP_BUFFER_ALIGNMENT.

Suite pins (m3-max-75036): the stage helper's version 3 for its robust compute chain; the
validation runtime-sources pin (RUNTIME_VERSION is already bumped in this change); the profile
subset rules for robust_buffer_access2, robust_buffer_access_update_after_bind (implications)
and robust_storage_buffer_access_size_alignment (a minimum); the enable test's device with room
for set 0's 31 storage buffers; the README floor test's pipeline-robustness feature table.
This commit is contained in:
Anees Iqbal committed 2026-11-26 05:04:54 -08:00
1 parent 50fb0b45c9
commit b443508375
10 files changed
+178 -19

No files matched your search

+71 -3
View File
@@ -231,7 +231,11 @@ states' main pipelines their `finish_pipeline` calls made, with their time, and
make failed (`finished_pipelines`, `finished_pipeline_nanos`, `failed_finishes`, Compute pipeline
states below); the compiled contents a state's make dropped because an equal one landed in the
device's map first (`kernel_makes_dropped`); the copies of resolve images into the buffers their
textures lie over (`resolve_copies` and `resolve_copy_bytes`, Render encoders below);
textures lie over (`resolve_copies` and `resolve_copy_bytes`, Render encoders below); the
dispatches by the form their kernel reaches its buffers in, through storage buffers of set 0
(`bound_dispatches`) or at their device addresses (`address_dispatches`), with the sets written
for the bound ones and those that kept the set written last (`buffer_sets_written`,
`buffer_sets_held`, Bound kernel buffers below);
`gauges()` are live counts per kind of resource, every one zero after teardown, and
`handles_out`, 1 while a handle of the device is out (Teardown). They are relaxed atomics, always
on. What an encoder's commands count arrives when the encoder ends.
@@ -2661,7 +2665,14 @@ while the driver's exit handler waited on a lock, with every runtime thread alre
where nothing maps there that is a fault, which loses the device on NVIDIA's driver and on RADV
(above). An access through a pointer loaded from memory or made from an integer is not checked
either: no binding bounds it. The check's measured cost, in GPU time and in cold pipeline
makes, is in docs/API.md, section 5 (`PushField::SlotBounds`).
makes, is in docs/API.md, section 5 (`PushField::SlotBounds`). A kernel on a device that binds
its buffers (Bound kernel buffers) carries no such check on its views, which its pipeline's
robust buffer access 2 contains; the check stays, by structure and not by device, on four kinds
of its slots, which keep their addresses: one a wide pointer may reach, one a typed atomic
reaches, one the stage-in fetch reads, and one the dispatch binds at a multiple of 4 below its
argument's alignment, and on its views' atomics. Every render stage pays it, and so does every
kernel on a device without the form: lavapipe, MoltenVK, the UHD 630's Windows driver and the
780M under AMDVLK 2025.Q2.1 among the lab's.
- A dispatch's threadgroup memory, the kernel's own and the lengths set, each rounded up to 16
bytes, is at most the device's `maxComputeSharedMemorySize` (`Limit::ThreadgroupMemory`), where
Metal's is its `maxThreadgroupMemoryLength`, which `Device::max_threadgroup_memory_length`
@@ -5351,6 +5362,7 @@ Presenting runs on the runtime's own device; nothing is exported or imported.
| `VK_EXT_image_drm_format_modifier` | device, where listed | a dma-buf surface's planes in place, as `DRM_FORMAT_MOD_LINEAR` images (`Device::new_exported_surface`) |
| `VK_NV_linear_color_attachment` | device, where listed | an opaque handle's surface planes in place whose `LINEAR` tiling renders as a linear colour attachment alone, through the linear-attachment feature below |
| `VK_EXT_device_fault` | device, where listed | a lost device's fault report, read once at its first loss (`DeviceLoss::fault`), through the fault-report feature below |
| `VK_EXT_pipeline_robustness` | device, where listed | a kernel's buffers bound as storage buffers of set 0, contained by its pipeline's robust buffer access 2, through the pipeline-robustness feature below (Bound kernel buffers) |
| `VK_KHR_maintenance8` | device, where listed | a sample at a texel offset the shader computes, with the offset as the sample's own `Offset` operand, through the optional feature `maintenance8` below |
| `VK_EXT_custom_border_color` | device, where reported from the image | Vulkan requires it of a device that enables the border swizzle below; none of its features is enabled |
| `VK_EXT_border_color_swizzle` | device, where reported from the image | an opaque-black border sampled through a view whose component mapping is not the identity, defined and read through that mapping (Border swizzle, below) |
@@ -5646,7 +5658,9 @@ Six features choose between two forms by the device's answer: 16-bit floats, sto
without a format, 64-bit atomics, 64-bit floats, SIMD groups and run-time texel offsets. Beside
them, a device without the
attachment feedback loop reads attachments through a copy, the one form left there, which is a
known gap (Known gaps of render encoders). `floor::Capabilities` holds each answer the floor
known gap (Known gaps of render encoders), and a kernel reaches its buffers through storage
buffers of set 0 where the device answers that form's query and at their addresses elsewhere
(Bound kernel buffers below). `floor::Capabilities` holds each answer the floor
reads, and the features and extensions to enable: the floor's, and each optional one the device
has.
@@ -5692,6 +5706,60 @@ is expected to take the loop, not verified in the lab (public reports of it list
|---|---|---|
| `attachmentFeedbackLoopLayout` | `VkPhysicalDeviceAttachmentFeedbackLoopLayoutFeaturesEXT` | the feedback layout and usage |
### Bound kernel buffers
Where the device lists `VK_EXT_pipeline_robustness`, reports the feature below, and its
`maxPerStageUpdateAfterBindResources` holds set 1's arrays of the compute stage with set 0's 31
storage buffers (`floor::kernel_buffers_fit`), device creation enables the feature, and none of
it otherwise. The translator's profile then answers its query from the rest
(`DeviceProfile::binds_kernel_buffers`, docs/API.md section 1): `robustBufferAccess2` and
`robustBufferAccessUpdateAfterBind` supported (`robustBufferAccess2` is not enabled), the
storage-buffer limits of set 0 at 31 or more, and `maxStorageBufferRange` at least
`MAX_BUFFER_LENGTH` plus the buffer base alignment less 1. Where it answers yes:
- every pipeline layout of the device has set 0 of 31 storage buffers, for the compute stage
(`arrays::buffer_bindings`), which render pipelines share and read none of;
- a kernel reaches each buffer argument through its binding there, but the four kinds of slot that
keep their address by structure (docs/API.md section 1: a slot a wide pointer, a typed atomic
or the stage-in fetch reaches, and one bound at a multiple of 4 below its argument's
alignment). Its compute pipeline is made with `VkPipelineRobustnessCreateInfo` naming robust
buffer access 2 for storage buffers, under which a load outside a descriptor's range reads
zero and a store does nothing, so its accesses carry no check in the shader but an atomic's;
- a dispatch describes each bound slot's buffer by its block's `VkBuffer`, from the buffer's
first byte rounded down to the buffer base alignment through its last (no `VkBuffer` of its
own, and no copy), and pushes the slot's bytes from there to its bind address
(`PushField::SlotBindOffset`). A dispatch whose slots' descriptors begin those of the set its
command buffer wrote last writes none and binds that set only where the Vulkan command buffer
does not hold it, so a changed bind offset alone is a push word; any other takes the next set
of its command buffer's pools, writes it and binds it. A command buffer takes its sets in order
from pools the device lends it, 256 sets a pool allocated as the pool is made, and gives them
back as it retires or drops uncommitted; the device keeps at most 16 pools free and destroys
the rest, and counts every pool alive (the `buffer_set_pools` gauge). A set is written only
while no pending work names it.
The dispatches by form, and the sets written and held, are counted (Counters). The containment
differs from the address form's by bytes the queries state: before a buffer whose first byte is
not a multiple of 16 (a no-copy buffer), up to 15; past a length that is not a multiple of 4, up
to 3 where `robustStorageBufferAccessSizeAlignment` is 4 (RADV, ANV, AMDVLK, KosmicKrisp), none
where it is 1 (NVIDIA). A read there reads those bytes and a write lands in them: the same
process's memory, its own or shared with it by name; past a buffer the consumer placed in a block
as `Device::heap_buffer_size_and_align` answers, the block's padding before the next buffer, zero
or the same device's earlier bytes, never another device's (docs/API.md section 10). The test
`pool_reach` reads and writes before and past a buffer between two neighbours of one block, past
those bytes, and finds zero and no write on the Iris Xe (ANV), the Radeon 780M and RX 7900 XTX
(RADV) and the RTX 3090 (NVIDIA 620.70.06) in this form (jobs m3-max-75037, 75038, 75039, 75040),
and on the 780M under AMDVLK in the address form (m3-max-75041).
The Radeon 780M under AMDVLK 2025.Q2.1 reports Vulkan 1.4, where the feature is core, and lists
no `VK_EXT_pipeline_robustness`; the runtime's instance asks Vulkan 1.3, so the device keeps
addresses there (m3-max-75042). lavapipe (`maxStorageBufferRange` 128 MiB), MoltenVK (no
`robustBufferAccess2`) and the UHD 630's Windows driver (no `pipelineRobustness`) keep
addresses too.
| Pipeline-robustness feature | Structure | Used for |
|---|---|---|
| `pipelineRobustness` | `VkPhysicalDevicePipelineRobustnessFeaturesEXT` | a compute pipeline's robust buffer access 2 for its storage buffers, whatever the device enables |
### Border swizzle
Where the device lists `VK_EXT_border_color_swizzle` and reports `borderColorSwizzleFromImage`,
@@ -35,6 +35,10 @@ pub const MAX_BUFFER_LENGTH: u64 = 1 << 31;
/// `minUniformBufferOffsetAlignment`, `minStorageBufferOffsetAlignment` and
/// `minTexelBufferOffsetAlignment` at 256. So it is a constant, not a device query: an answer
/// that moved with the host would buy nothing. A placement rule added later changes it here.
/// A kernel's bound buffer is described from its first byte rounded down to the device's buffer
/// base alignment (`DeviceProfile::buffer_base_alignment`, at most 256), so a buffer placed at a
/// multiple of 256 is bound from its own first byte, and its descriptor reaches no byte before
/// it (`encoder::view`).
const HEAP_BUFFER_ALIGNMENT: u64 = 256;
/// [`Device::heap_buffer_size_and_align`]'s answer for `length` bytes.
+11 -1
View File
@@ -1944,7 +1944,17 @@ struct Parameters {
/// may be any byte of a buffer over memory the consumer brought; every `VkBuffer` of the device
/// starts at a multiple of 16 in the Metal address space (its memory requirements' alignment
/// on every lab driver: 16, 64 or 256), so the descriptor's bytes are congruent to their Metal
/// addresses modulo 16, as a view's `uvec4` and `uvec2` units take them;
/// addresses modulo 16, as a view's `uvec4` and `uvec2` units take them. Every other placement
/// keeps the start on `align` by construction, so the descriptor's first byte is the buffer's
/// own: a buffer placed as `Device::heap_buffer_size_and_align` answers starts at a multiple of
/// 256 of its block (`HEAP_BUFFER_ALIGNMENT`, no less than any device's `align`), and a block at
/// a multiple of 64 KiB of its allocation (`Device::take_block`). Only a buffer at another byte
/// of memory the consumer brought (a no-copy buffer) has bytes before it in its descriptor, up
/// to `align - 1`, that memory's own. Past its end the device's
/// `robustStorageBufferAccessSizeAlignment` rounds the range up (up to 3 bytes past a length
/// off 4 where it is 4): the block's bytes past the buffer, padding before the next buffer at a
/// multiple of 256 that no zeroing of the buffer reaches, which hold zero or the same device's
/// earlier bytes (a device's blocks are ranges of its own allocations), never another device's;
/// - a `set_bytes` copy: its bytes, from its own first byte, at a multiple of `align` in the
/// ring's buffer (`crate::ring`), with 0;
/// - nothing bound, or a buffer or a copy of no bytes: a null descriptor, with 0.
+1 -1
View File
@@ -97,7 +97,7 @@ const ENABLES: u32 = 3;
/// version is a miss and removed, so a fix of ours to a helper that ended asks the helper again.
/// Bump it with every change to that code that changes what the helper does; a driver's fix needs
/// none, as the stage key holds the driver's header.
pub(crate) const HELPER_VERSION: u32 = 2;
pub(crate) const HELPER_VERSION: u32 = 3;
/// No Metal counterpart: what ended a helper's compile of a kernel past the stage bound, kept as
/// the pipeline's entry ([`Device::record_stage_breach`], [`Device::fill_stage`]) so its makes are
@@ -13,6 +13,7 @@ use crate::floor::{
use ash::vk;
use metal2vulkan::device::{
Device, DeviceDescription, DevicePolicy, DeviceProfile, EnableSet, VkExtension, VkFeature,
KERNEL_BUFFER_BINDINGS,
};
use serde_json::Value;
use std::collections::{BTreeMap, BTreeSet};
@@ -133,8 +134,9 @@ fn every_feature_creation_enables_reaches_the_translator() {
/// The enable set is what the translator's description states as enabled on a device that
/// reports every feature of creation's tables, lists every extension creation may enable and has
/// the descriptor room of the attachment reads: it holds nothing creation never enables, and
/// leaves out nothing creation enables that the translator names.
/// the descriptor room of the attachment reads and of set 0's kernel storage buffers: it holds
/// nothing creation never enables, and leaves out nothing creation enables that the translator
/// names.
#[test]
fn the_enable_set_is_what_creation_enables_on_a_device_with_everything() {
let mut device = at_the_floor();
@@ -147,8 +149,9 @@ fn the_enable_set_is_what_creation_enables_on_a_device_with_everything() {
descriptors.max_descriptor_set_update_after_bind_sampled_images = 3 * TEXTURES;
// The sampled array with its second elements, and the storage array with its level elements.
let images = 3 * TEXTURES + 2 * TEXTURES + LEVEL_ELEMENTS;
// The fragment stage's attachments, or the compute stage's kernel storage buffers.
descriptors.max_per_stage_update_after_bind_resources =
images + device.limits.max_color_attachments;
images + (device.limits.max_color_attachments).max(KERNEL_BUFFER_BINDINGS);
descriptors.max_update_after_bind_descriptors_in_all_pools =
images + SAMPLER_ARRAYS * SAMPLER_ELEMENTS;
let capabilities = decide(&device).unwrap_or_else(|below| panic!("{below}"));
@@ -10,8 +10,9 @@ use crate::floor::{
BARYCENTRICS, BARYCENTRIC_EXTENSIONS, BORDER_SWIZZLE, BORDER_SWIZZLE_EXTENSIONS,
DEVICE_EXTENSIONS, FAULT_REPORTS, FILL_MODES, INDIRECT_COMMANDS, INSTANCE_EXTENSIONS,
LINEAR_ATTACHMENTS, MEMORY_FLAG_NAMES, MIN_LOD_CLAMPS, OPTIONAL, OPTIONAL_EXTENSIONS,
OPTIONAL_INSTANCE_EXTENSIONS, PIXEL_INTERLOCK, PORTABILITY, PRIVATE_MEMORY, QUAD_CONTROL,
REQUIRED, RING_MEMORY, SHARED_MEMORY, STEP_RATES, TIMESTAMP_BITS, TIME_DOMAINS, VERSION,
OPTIONAL_INSTANCE_EXTENSIONS, PIPELINE_ROBUSTNESS, PIXEL_INTERLOCK, PORTABILITY,
PRIVATE_MEMORY, QUAD_CONTROL, REQUIRED, RING_MEMORY, SHARED_MEMORY, STEP_RATES, TIMESTAMP_BITS,
TIME_DOMAINS, VERSION,
};
use ash::vk;
use std::collections::BTreeSet;
@@ -2125,6 +2126,10 @@ fn the_readme_states_the_floor() {
["Fault-report feature", "Structure", "Used for"],
FAULT_REPORTS,
),
(
["Pipeline-robustness feature", "Structure", "Used for"],
PIPELINE_ROBUSTNESS,
),
] {
let stated: BTreeSet<(String, String)> = table(&section, &header)
.into_iter()
@@ -235,8 +235,8 @@ fn a_memory_breach_holds_to_its_ceiling_and_is_a_miss_above_it() {
/// [`an_ended_breach_holds_to_its_helper_version_and_is_a_miss_below_it`] until
/// `HELPER_VERSION` is bumped and the pair here is the new one.
const HELPER_CODE: (u32, &str) = (
2,
"c7b4dec49daac1c9ea57722a79cdaa3de152c44fa78ee72093dcc01757ef2de6",
3,
"a510eba2c4f2385af064cdb9f35f90e0906845fa1452164d78002ac72402b8a2",
);
/// The helper's own code as stage.rs holds it: `serve_stage` through `compile`, and
@@ -1 +1 @@
35e965ba245697eed526debdfda2aa033a36dd54fccdfc121843625148c8633d
bb55dc9a0f65688f61985f031993121a833361c461beead97d4d892dfd03af36
@@ -973,9 +973,10 @@ fn bound(path: &[String]) -> Option<Bound> {
})
}
/// A limit's [`Bound`], from Vulkan's naming: `max*` limits are maxima, `min*Alignment` limits and
/// the negative minimum offsets are minima, sample counts and resolve modes are flags, and the
/// boolean properties are implications.
/// A limit's [`Bound`], from Vulkan's naming: `max*` limits are maxima, `min*Alignment` limits,
/// the negative minimum offsets and the robust storage buffer access granule are minima, sample
/// counts and resolve modes are flags, and the boolean properties (the robust buffer access 2
/// features the profile reads as limits among them) are implications.
fn limit_bound(name: &str) -> Option<Bound> {
Some(match name {
"min_interpolation_offset_bits" => Bound::FloatAtLeast,
@@ -986,9 +987,14 @@ fn limit_bound(name: &str) -> Option<Bound> {
| "early_fragment_multisample_coverage_after_sample_counting"
| "sub_pixel_precision_bits" => Bound::Execution,
"min_texel_offset" | "min_texel_gather_offset" => Bound::AtLeast,
"supports_non_zero_first_instance" | "independent_resolve_none" | "independent_resolve" => {
Bound::Implies
}
"supports_non_zero_first_instance"
| "independent_resolve_none"
| "independent_resolve"
| "robust_buffer_access2"
| "robust_buffer_access_update_after_bind" => Bound::Implies,
// The granule robust buffer access rounds a storage buffer's range up to: like an
// alignment, a minimum.
"robust_storage_buffer_access_size_alignment" => Bound::AtLeast,
"framebuffer_color_sample_counts"
| "framebuffer_depth_sample_counts"
| "framebuffer_integer_color_sample_counts"
+63
View File
@@ -300,6 +300,35 @@ and so do the command line, the compile worker and every validation tool. It hol
into the parameter block `pipeline::ExecutionCounts` lays out, where each part's
`sequenceCountAddress` reads it. Its interface is a compiled function's: the one push range,
holding the block's device address at offset 0, and no descriptor.
- **A kernel's bound buffers** (`DeviceProfile::binds_kernel_buffers`). Under the identity
domains, on a device that answers this query, a kernel reaches each buffer argument through a
storage buffer of set 0 bound over that buffer, not at its address. The descriptor covers the
buffer's own bytes in the `VkBuffer` that holds them, from its first byte rounded down to the
device's buffer base alignment (`DeviceProfile::buffer_base_alignment`,
`max(minStorageBufferOffsetAlignment, 16)`) to its last, and the slot's bytes from there to its
bind address are pushed (`PushField::SlotBindOffset`, section 5). The pipeline is made with
`VkPipelineRobustnessCreateInfo` naming robust buffer access 2 for its storage buffers
(`RuntimeFact::RobustStorageBuffers`): a load outside the descriptor's range reads zero and a
store there does nothing, so no access is checked in the shader (no `PushField::SlotBounds`, no
`PushField::ZeroAddress`) but an atomic, which keeps its check against the view's length and
answers 0 outside it (Vulkan states an atomic outside the checked range a write with an
undefined answer). The function requires `VkFeature::PipelineRobustness`, and states each
slot's `RuntimeFact::AddressAlignment` as an address slot does. The query is Vulkan's alone:
the features `pipelineRobustness` (enabled), `robustBufferAccess2` (supported, and not enabled)
and `robustBufferAccessUpdateAfterBind`; then the limits set 0's layout reaches:
`maxPerStageDescriptorStorageBuffers`, `maxPerStageDescriptorUpdateAfterBindStorageBuffers`,
`maxDescriptorSetStorageBuffers`, `maxDescriptorSetUpdateAfterBindStorageBuffers` and
`maxPerStageResources`, each at least its 31 bindings (`KERNEL_BUFFER_BINDINGS`), and
`maxStorageBufferRange` at least `IDENTITY_BUFFER_BYTES` (2^31) plus the base alignment less
1. The last limit that layout reaches, `maxPerStageUpdateAfterBindResources`, counts the set 1
a runtime makes beside it, which the runtime checks before it enables `pipelineRobustness`.
Four kinds of slot keep their device address by structure, on every device: a slot a wide
pointer may reach (a pointer the function stores, converts to an integer, or merges with one
loaded from memory or made from an integer), a slot a typed atomic reaches, a slot the
stage-in fetch reads, and a slot the dispatch binds at a multiple of 4 below its argument's
alignment (`LoweringInputs::word_bound_buffers`), as a view's `uvec4` and `uvec2` units take
the bind offset to be a multiple of that alignment. Every render stage keeps addresses. Of the
committed profiles, lavapipe's (a `maxStorageBufferRange` of 128 MiB) answers no.
- **The resident-table domains** (`DevicePolicy::RESIDENT_TABLES`: `PointerDomain::ResidentTable`
with `HandleDomain::Table`) exist for the validation executor alone, which builds the resident
root and the handle table itself. Besides it, only the translator's own tests of that lowering
@@ -1119,6 +1148,16 @@ for dependency in &pipeline.dependencies {
device-replay variant (`VariantKey::replay_bindings`, section 6) reads each buffer slot's
address from its replayed command's root entry, at `PushField::RootTableAddress`, which the
identity domains do not read: it is refused, `Unsupported{IdentityDomains}` naming that field.
- A kernel's bound buffer slot (section 1, `DeviceProfile::binds_kernel_buffers`) is one
storage buffer of set 0, its binding the slot's place among the kernel's bound slots in slot
order, and pushes `PushField::SlotBindOffset`, a `u32`: the bytes from the descriptor's first
byte to the slot's bind address (the buffer's first byte's distance past the descriptor's start,
below the base alignment, plus the bind offset), or 0 for a `setBytes` copy, whose descriptor
starts at its first byte, and for nothing bound, a null descriptor. An access through the slot
reads its view at that word plus its 32-bit byte offset, read as signed. Its descriptor's bytes
are congruent to their Metal addresses modulo 16, as the view's `uvec4` and `uvec2` units take
them. A consumer writes a descriptor only where a slot's buffer changes: a changed bind offset
alone is a new push word.
- Under the identity domains, a buffer slot that an access may reach at a
byte offset that is not a translation-time constant (an index the memory plan does not prove
one value, a looping `memcpy` or `memset`, a pulled fetch) also reads
@@ -2770,6 +2809,30 @@ named states the rule in full.
variant of the kernel that reaches them there (section 1, `LoweringInputs::word_bound_buffers`),
though Metal's API validation refuses that bind offset too. Such a buffer that a 64-bit atomic
may reach off a multiple of 8, a draw's, and a consumer-compiled kernel's are still refused.
- **A bound kernel buffer's out-of-bounds reach is its descriptor's, a few bytes wider than the
buffer** on a device that binds a kernel's buffers (section 1,
`DeviceProfile::binds_kernel_buffers`). Out-of-bounds accesses of a buffer are undefined in
Metal; the runtime's contract elsewhere is zero for a read and nothing for a write outside the
buffer. Under robust buffer access 2 that holds outside the descriptor's range, which is wider
than the buffer on two sides, from the queries:
- before the buffer: its first byte rounded down to the buffer base alignment, up to that
alignment less 1 bytes (15 at 16, the alignment on every lab device). Only a buffer whose
first byte is not a multiple of 16 has such bytes, which only a buffer over memory the
consumer brought can be (Metal's no-copy buffer, which Apple's page asks for at a page-aligned
pointer): a buffer the consumer places as `Device::heap_buffer_size_and_align` answers starts
at a multiple of 256 of its block, and every block at a multiple of 64 KiB of its allocation;
- past the buffer: its length rounded up to the device's `robustStorageBufferAccessSizeAlignment`,
up to 3 bytes past a length that is not a multiple of 4 where that alignment is 4 (RADV, ANV,
KosmicKrisp), and none where it is 1 (NVIDIA's driver). Apple's page asks a no-copy buffer
for a length that ends on a page.
A read of those bytes reads them and a write there lands in them. They are the same process's
memory, its own or shared with it by name: memory the consumer brought lies on the pages it
maps or was given; past a buffer the consumer placed in one of its blocks they are that block's,
the padding before the next buffer at a multiple of 256, which no zeroing of the buffer
reaches, so they read zero or the same device's earlier bytes there, never another device's (a
device's blocks are ranges of its own allocations). A kernel on a device that does not bind
its buffers, a render stage, and every slot that keeps its address (section 1) read zero and
write nothing outside the buffer exactly.
- **A recursive call past the call stack yields zero**: the stack holds what Metal's byte model
holds for the pipeline's `max_call_stack_depth`; a call that finds it full returns zero, where
Metal's answer is corrupt.