SEMANTICS 2123 / RUNTIME 2349: Texture buffers past maxTexelBufferElements bound through views of their parts

Metal makes texture buffers of up to 2^28 texels on every Mac; one texel
buffer view holds at most the device's maxTexelBufferElements (2^27 on ANV
and lavapipe, 2^26 on MoltenVK), and the binding of a wider one was refused
(BindError::TexelBufferTooLarge).

The consumer now states with a texture buffer's binding the views its texels
take (BoundTexture::Buffer::parts, bind::texel_buffer_parts: 1 within the
limit), which its shape carries. A slot whose function only reads, writes,
updates by an atomic or asks the width of the texture buffer, on a device that
indexes texel buffer arrays NonUniform, states RuntimeFact::TexelBufferParts;
where the shape binds more than one part there, the plan asks for the parts
variant (VariantKey::texel_buffer_parts). Under it the slot is an array of
the parts' texel buffers: texel i is texel i - k*P of part
k = min(i / P, parts - 1), P the device's limit rounded down to its texel
buffer offset alignment (bind::part_texels), and the width (parts - 1) * P
plus the last part's. texel_ranges writes one range per part at its array
element (DescriptorRange::element), and the runtime views each.

Each part is the device's own view in the format one view takes, so a read
converts its texel as the one view does: no precision note. A texture buffer
one view holds keeps one view, no variant and its key. The families row
TextureBufferWidth is exact where the parts reach 2^28.

Still refused (TexelBufferTooLarge): a slot read through a sampler or used beyond read/write/atomic/width; a device
without NonUniform indexing of that kind of texel buffer array; formats with several texels a block. Argument-buffer
texture buffers past the limit stay the heap neutral (unnamed-texture-unviewable). New: WorkCounts::texel_buffer_parts_bound,
RuntimeFact::TexelBufferParts (appended), bind::part_texels / texel_buffer_parts, BoundTexture::Buffer.parts,
TextureShape::Buffer.parts (serde default 1), VariantKey/LoweringInputs.texel_buffer_parts (hashed only when non-empty),
DescriptorRange.element. SEMANTICS_VERSION bumped: input once refused now translates.

Evidence (lane jobs, msi): m3-max-32343 at 628264de17: clippy --workspace --all-features --all-targets -D warnings 0;
41 metal2vulkan tests incl. golden_hashes_match_the_table (every fixture's SPIR-V unchanged on every profile: one part is
byte-identical), the binder test (an under-limit slot: no parts entry, empty variant, layout counts 1), the interpreter
parts test (robust and unrobust), api_surface / api_signatures / refusal_surface; families::states_follow_their_sources;
lavapipe texture_buffer_width_device (R32Uint limit+64 texels: both sides of the limit and the last texel read and written,
past the end reads 0 and writes dropped, texel_buffer_parts_bound +3) and buffer_tail_device. Without the fix the device
test fails at bind: TexelBufferTooLarge{elements 134217792, limit 134217728} (m3-max-32140). ANV (2^27) is down; the XTX
(2^29) never parts.

Lane commits: 9fbf7d3c14, 7f7f3ad95e, 9a745ffb3c, 740e9e43dd, 628264de17.
This commit is contained in:
Anees Iqbal committed 2026-11-15 07:10:59 -08:00
1 parent c9abbafd2f
commit f851c07e52
46 files changed
+1225 -62

No files matched your search

+24
View File
@@ -1491,6 +1491,30 @@ for dependency in &pipeline.dependencies {
conversion as an image's do, so the reads and writes are the image route's, bit for bit (the
runtime's `texel_rows_device` tests compare every `RGBA8Unorm` and `RGBA16Float` code), and no
precision note is recorded. Any other slot, and any texture without the fact, binds the image.
- A texture buffer of more texels than the device's `maxTexelBufferElements` (Metal makes them up
to 2^28 texels on every Mac; one texel buffer view holds 2^27 on ANV and lavapipe and 2^26 on
MoltenVK) is bound through views of its parts. State with its binding the views its texels take
(`BoundTexture::Buffer::parts`, `bind::texel_buffer_parts(limits, texels)`: 1 within the limit,
which binds one view as before and keeps the pipeline and its key). Each part but the last holds
`bind::part_texels(limits)` texels, the limit rounded down to a multiple of
`minTexelBufferOffsetAlignment`, so every part starts on that alignment where the texture buffer
does; the last holds the rest. A slot whose function only reads (not through a sampler), writes,
updates by an atomic or asks the width of the texture buffer, on a device that indexes an array
of the slot's kind of texel buffer by a `NonUniform` value (`RuntimeFact::TexelBufferParts`),
takes the pipeline's parts variant (`VariantKey::texel_buffer_parts`) where the shape binds more
than one part there: the slot is an array of the parts' texel buffers, one `WriteSource::TexelBuffer`
per array element, each element's view the bytes of the instance's `DescriptorRange` at that
`element`. The function reads texel `i` as texel `i - k · P` of part `k = min(⌊i / P⌋, parts - 1)`;
a texel past the last lies past the last part's end, so its read is Metal's out-of-bounds texel
and its write is dropped, as through one view, and the width is `(parts - 1) · P` plus the last
part's. Each part is the device's own view in the format one view takes, so a read converts its
texel as that view does, and no precision note is recorded. Still refused with
`BindError::TexelBufferTooLarge`: a slot that reads the texture buffer through a sampler, a device
without `shaderUniformTexelBufferArrayNonUniformIndexing` (or
`shaderStorageTexelBufferArrayNonUniformIndexing` for a slot that writes), and a format whose
block holds several texels; parts past a stage's sampled or storage image descriptors are the
link's descriptor-count refusal. A texture buffer past the limit in an argument buffer is the
heap class's neutral (`metal2vulkan-degrade-unnamed-texture-unviewable`).
- `interface.reaches_command_buffers` and `interface.texture_writing_stages` say, provably, which
pipelines may touch an indirect command buffer and which stages may write a texture.
`interface.command_writes` (`CommandWrites`) says what its functions may write into the