Commit Graph
430 Commits
Author SHA1 Message Date
Anees Iqbal 82abe62334 Fix forward: the API signature table and REFUSALS.md at the dead-variant batch's landing over the orphans
The dead-variant batch (cutxlate-dw) and the translator orphans (cutcheck) deleted items on both
sides: the orphans removed CompensatedViewport, is_permanent_for and the ViewportCompensation
path; the batch removed the offset-0 class (ZERO_OFFSET_CLASS, ZERO_OFFSET_TOLD,
storage_view_buffers), Needs::DriverDefect and the dead DriverWorkaround variants. The landing's
rebase kept both deletions, so the generated tables are regenerated from the merged sources:
scripts/api-signatures/signatures.py --bless and scripts/refusal-surface/refusal_surface.py.

Verified: both scripts ran on the merged tree; the table holds no ZERO_OFFSET row.
2026-11-20 11:59:14 -08:00
Anees Iqbal 8252854871 SEMANTICS 2208 for the dead driver variants; the runtime pin, REFUSALS.md and api_signatures follow
SEMANTICS_VERSION 2208: the batch changes what a module holds on devices that took the deleted
variants (the clipping notes and the denormals note on every device, one serializer form, a
constant slot's storage view, the half rounding bound) and no longer defers discards or guards
helper branches anywhere.

runtime-sources.sha256 moves without a RUNTIME_VERSION bump: the binder's edits in the batch drop
forms no plan reaches (the uniform texel view's class, the offset-0 class no consumer set, the
mesh limit's always-zero staged bytes), so it binds every plan it can be handed as before.

REFUSALS.md and api_signatures.tsv are regenerated (signatures.py --bless, refusal_surface.py).

Verified: nothing yet; the gate follows.
2026-11-20 11:58:40 -08:00
Anees Iqbal 912bf785ce Simdgroups: the vertex grouping note goes, with its fact's reader
The planner's ruling: no VertexSimdgroupGrouping. lower/simd recorded it for a vertex function's
simdgroup or quad operation where the stage takes no required subgroup size and the profile
carried DriverWorkaround::VertexGroupingNotApples (ANV's 8-vertex interleaved subgroups); no
profile carries that variant since the fact tables went, so it was recorded nowhere. The note,
its reader (regroups_vertices), its codec tag, its conformance degradation and code, its
validation allowance, deferral and bound text, API.md's catalogue entry and the engine_simd and
c3 tests that named it go.

The public surface moves with this commit and the batch's earlier ones: the api_signatures table
(regenerated by signatures.py) drops PrecisionNote::VertexSimdgroupGrouping (the translator's
and the runtime's re-export), Feature::PixelCoverage and Feature::CentroidVarying (link's split
refusal), and DescriptorView::UniformTexel (the views' rung 1); REFUSALS.md (regenerated) drops
the two features, and the reach table their rows.
2026-11-20 11:56:55 -08:00
Anees Iqbal 4bc57a20e3 WIP orphans: ResidentPart, the harness's simdgroups assert, and the docs that named deleted items 2026-11-20 11:54:24 -08:00
Anees Iqbal 92ce7950fc Docs: "the runtime", not "the new runtime"
There is one runtime, so the prose of the harness, validation, devtools,
the translator's lockstep module, .config/nextest.toml and the refusal
surface and conformance coverage generators says "the runtime"
(scratch newrt.py: a word replacement, identifiers such as new_runtime
and NewRuntime untouched). docs/REFUSALS.md and
docs/CONFORMANCE-COVERAGE.md are regenerated from the edited scripts.

Four harness passages said the runtime makes no heap and no texture
over a buffer, and has no Managed mode. The runtime has all three
(Device::new_heap_buffer and heap textures, Buffer::new_texture,
Device::new_managed_buffer); the harness's own backend refuses the two
texture sources. They now say the harness makes neither on the runtime,
and the Managed note names Device::new_managed_buffer. The refusal
strings keep the words the harness's described test matches ("makes no
heap", "makes no texture over a buffer").

Left: three fixture comments (.metal under validation's public
fixtures, whose text keys the golden tables and the committed AIR) and
scripts/matrix, whose keys (harness-new) carry the same naming.

Verified locally: the refusal surface, Metal coverage, conformance
coverage and API signature checks pass.
2026-11-20 11:52:56 -08:00
Anees Iqbal c48ad2340c rt: a copy within one subresource of one image: regions apart in GENERAL, the same region none
A guest's Mac walk (58383, then m3-max-59593) met Gap::TextureCopy 1,904 times, two RGBA8Unorm
256x256 2D textures, 29x1x1 texels at level 0 and slice 0. On KosmicKrisp every RGBA8Unorm
texture is R8G8B8A8_UNORM (its optimal tiling has every feature form() asks), so the format
condition cannot fire there; the one left is one subresource of one image: a texture view shares
its parent's image and id, so a copy between a texture and its view, or two views of one
texture, at one level and slice was refused, as a texture into itself was.

- blit: within one level and slice of one image, regions apart copy with one vkCmdCopyImage, the
  subresource in GENERAL (VUID-vkCmdCopyImage-srcImage-09460, -pRegions-00124): one barrier
  moves it there and one home, three barriers as any copy. The same region copies nothing and
  records no command, every texel already its own. Overlapping regions, which Metal leaves
  undefined (Apple's copy(from:sourceSlice:...) page: "Copying data to overlapping regions
  within the same texture may result in unexpected behavior."), stay Gap::TextureCopy.
- texture: a copy's barrier home from GENERAL makes its writes available.
- Gap::TextureCopy's doc and basis, docs/REFUSALS.md, the runtime README and the
  copy_from_texture doc say so.
- tests (blit): the rules (two slices, regions apart along each axis, the same region, three
  overlaps); on every device, a texture's region into another of its level and slice, from its
  view and from itself, lands exactly, everything around kept, one submission and three
  barriers; the same region records nothing and keeps every byte; overlapping regions are the
  gap.
2026-11-20 11:13:47 -08:00
Anees Iqbal e15d067fe0 rt: a texture view the image's own Vulkan format holds is made without PixelFormatView usage
A guest's Mac walk (58383) met Refusal::TextureViewFormat once: an A8Unorm view of an R8Unorm
texture made without PixelFormatView usage. Metal's validation layer stops such a view ("texture
usage (0x01) doesn't specify MTLTextureUsagePixelFormatView (0x10)"), and plain Metal makes it,
a blit out of it reading the texture's bytes (probe texture_view_rules.m, an Apple M3 Max under
macOS 27.0.1, jobs m3-max-43677 and m3-max-59523: R32Uint, RGBA8Uint, BGRA8Unorm and
BGRA8Unorm_sRGB of RGBA8Unorm; A8Unorm, R8Snorm and R8Uint of R8Unorm; R16Unorm of RG8Unorm).

- texture: without PixelFormatView usage, a view of a format Metal views the texture as with
  that usage (views_with_usage) is made where the view's Vulkan format is the image's own and only
  its component mapping differs, as plain Metal makes it: A8Unorm over R8Unorm is R8_UNORM with
  red read as alpha on every device (rt never exposes A8_UNORM). A view that needs another Vulkan
  format stays Refusal::TextureViewFormat: making every image mutable for it would cost every
  texture (rule 3).
- error: TextureViewFormat's doc and basis say so, with the probe's pairs; docs/REFUSALS.md
  regenerated. The runtime README records the divergence from Metal's validation in one sentence,
  of the form of the scissor and tessellation-factor-offset precedents.
- tests (view): on every device, an A8Unorm view of an R8Unorm texture of ShaderRead usage
  alone is made, and a draw sampling it (sampled_fragment into RGBA8Unorm) reads each texel's red
  byte as alpha, (0, 0, 0, r), exactly; an R8Uint view of it, another Vulkan format, is still
  refused, as is the R32Uint view of RGBA8Unorm without the flag. draw's CONSTEXPR is shared.
2026-11-20 11:12:35 -08:00
Anees Iqbal b975f6ddf7 rt: draws of points, through a point-class pipeline, with largePoints on the floor
A draw of points was Gap::Draw (DrawKind::Points) on every device; a guest's Mac walk met it
324 times. It now draws.

- render: a content keeps a point-class VkPipeline beside its line-class one, made with the
  state where the descriptor names the point class (inputPrimitiveTopology), else at the first
  draw of points, a first-use wait (Metrics::first_use_point_waits, FirstUse::Points). The
  vertex module writes PointSize (the function's [[point_size]], at most Metal's 511, or 1.0).
- render_encoder: Metal rasterizes a point of a function without [[point_size]] only under the
  point class; under another it rasterizes nothing and runs the vertex function, so such a draw
  records an empty scissor and the next draw the encoder's again. Points take no depth bias, as
  lines do not.
- floor: largePoints is required, so a written size draws (without it a device draws only 1.0).
  rt's floor is Vulkan 1.3; Vulkan 1.4 lists largePoints among the features it requires
  (vkspec 1.4.366, 55.1 Feature Requirements) and the committed roadmap-2022 profile holds it.
  Every card we run reports it, from vulkaninfo today (device, job, pointSizeRange):
  KosmicKrisp 26.3.1 on the M3 Max m3-max-59492 [1, 511]; RX 550 RADV POLARIS12 59525 [0, 8191.88];
  780M RADV PHOENIX 59525, 59527, 59528 [0, 8191.88]; RX 7900 XTX RADV NAVI31 59527 [0, 8191.88];
  RTX 2080 NVIDIA 620.70.06 59527 [1, 2047.94]; RTX 3090 NVIDIA 620.70.06 59528, 59526
  [1, 2047.94]; Iris Xe RPL-P ANV 59526 [0.125, 255.875]; RTX 5080 Laptop NVIDIA 615.71.09 59529
  [1, 2047.94]; UHD 630 Intel's Windows driver 59532 [0.125, 255.875]; lavapipe 59525..59529
  [0, 256]. The README's floor list says so.
- DrawKind::Points is deleted; docs/REFUSALS.md and the API signature table regenerated.
- tests: on every device, points of [[point_size]] 4 cover their 4 by 4 pixels, the point
  pipeline made once at the first draw of points; a point-class state makes it with the state
  and draws a function without a size 1 pixel wide; under no class such points rasterize
  nothing and a triangle after them draws; a vertex function that stores runs for a draw of
  points as for triangles; floor: largePoints missing is named. The replay player's draw of
  points plays.
2026-11-20 11:12:35 -08:00
Anees Iqbal be2c5d567e Fragment: the multisampled in-shader depth test is one typed gap on every device, Feature::MultisampledShaderDepthTest
The planner's ruling. A fragment function that runs its draw's depth test itself at more than one
sample, without returning its depth, needs each sample's depth. The two forms that gave it were
keyed on measured facts (VkProperty::SampleFragCoordDepth on RADV, CenterFragCoordDepth on
MoltenVK) that no query produces, so development already refused it on every device, as
Unsupported(FramebufferFetch, NotImplemented) at the depth attachment, which a play cannot count
apart from framebuffer fetch's own refusals. It is now its own kind.

- error/mod.rs: Feature::MultisampledShaderDepthTest.
- lower/fragment/depth_test.rs: depth_test_form refuses with it; the module docs say why.
- docs/REFUSALS.md regenerated with its reach row (--check passes); api_signatures.tsv blessed
  (it also takes the extrapolation commit's removal of DriverWorkaround::PerspectiveReadsExtrapolated).
- Tests: engine_fragment's per-sample depth and stencil-before-depth refusals, and
  engine_fragment_imageblock's multisampled tested write, assert the new kind at the depth
  attachment.

The forms keyed on the two never-produced properties, and the window-depth varying that feeds the
computed one, go with the other never-produced vocabulary.
2026-11-20 10:36:12 -08:00
Anees Iqbal 56d93ffbc7 Validation: a texture buffer an argument buffer holds stops only the candidate (texture_buffer_member)
The authoring-capability census counted six rows under texture_buffer_literal, a requirement in
the authoring set, so it stopped the Metal oracle as well as the candidate. The schema does
express these texture buffers: an argument-buffer texture or a texture-array element takes
`texture_type: buffer`, and the oracle makes one through make_texture (a
MTLTextureTypeTextureBuffer view of its bytes) and binds it with setTexture:atIndex:. The oracle
stop was stale tooling.

The candidate's stop is the product's limit. The binder's planned heap makes no texture buffer a
member, so a handle naming one misses, and the runtime makes no texture buffer at all
(Gap::TextureBuffer).

What changes:
- The requirement is renamed texture_buffer_member and stops engine_candidate only.
- It qualifies on Metal, as mesh_render_pipeline does: the checker admits its cases with Metal
  alone, and the candidate refuses them, typed.
- The analyzer version is now structural-triage-v84, because classification output changes.
- The runtime's TextureBuffer basis, and the README's mesh known gap, now say that no replay stream
  or live session has used either, and that harvested guest functions declare them. REFUSALS.md
  is regenerated.

Both families stay unresolved in the census. The candidate cannot run them, and each is a tooling
gap (Limit::Tooling).

Verified: the build, clippy and the tests run in the jobs the landing note names.
2026-11-20 10:33:28 -08:00
Anees Iqbal f3b9e0253a Pull-model interpolation: a sample or offset read where the quad may have left is one typed gap on every device
The planner's ruling. interpolant_reads refused a read at a sample or an offset outside the
fragment function's first block, or after a discard in it, only on a driver with
DriverWorkaround::InterpolationNeedsTheWholeQuad, which nothing sets since the driver-fact tables
went: development lowered the shape on every device, RADV included, whose InterpolateAtSample and
InterpolateAtOffset read garbage where the quad's other invocations have left.

- lower/stage_io/plan.rs: the structural test stays as it was (Sample or Offset, past the first
  block or after a discard in it) and refuses on every device, as its own kind:
  Unsupported::not_implemented(Feature::DivergentInterpolation), so a play counts it apart from
  PullModelInterpolation's select, phi and store refusals.
- error/mod.rs: Feature::DivergentInterpolation; PullModelInterpolation's doc points at it.
- device/profile.rs: DriverWorkaround::InterpolationNeedsTheWholeQuad deleted.
- The coverage loop's rung-1 form, beside it: lower/fragment/coverage.rs read the fact nothing
  set, so development read a looping function's sample-qualified varyings inside the loop on
  every device, where the helper invocations of a partly covered quad have left. The entry now
  reads each such varying at every sample a pipeline of the device may have before the loop, on
  every device (samples_before_loop, stage_io::read_at_every_sample).
- SEMANTICS_VERSION 2205.
- docs/REFUSALS.md regenerated (scripts/refusal-surface, with the new reach row); --check passes.
- Tests:
  - rt's every_device_refuses_interpolation_where_the_quad_may_have_left (lavapipe): a sample
    read in a branch, an offset read in a branch and reads after a discard in the first block
    are refused, Unsupported(DivergentInterpolation), NotImplemented; the same reads in the first
    block, and before a later discard, are made and draw the colour.
  - engine_pull_model: pm_offset_after_discard (reads past the first block) is refused on every
    committed profile at 1 and 4 samples, before what its reads need is asked.
  - engine_coverage_loop: a looping function's sample-qualified varying is read at every sample
    by constant index from 0, a power of two of them and at least the pipeline's samples, and at
    no computed sample.
2026-11-20 09:53:17 -08:00
Anees Iqbal 9a1c8fe6dc metal2vulkan-rt takes the runtime's name: metal2vulkan-runtime, published
The cutover's last mechanical step. The old runtime is deleted, so its name is free: the crate
moves to crates/metal2vulkan-runtime, its package is metal2vulkan-runtime and its library
metal2vulkan_runtime, and every reference in the tree follows (sources, tests, scripts, CI,
generated tables and docs).

It is now a published crate, as AGENTS.md said it would be once it took the name: version 0.2.0
with the other two, the translator pinned exactly (=0.2.0, as the translator pins the AIR front
end), documentation, keywords and categories, and copies of the repository's four license files,
which the published-crates test now holds equal to the root's for three crates. CI packages it
with the others. Prose that said it was unpublished, or counted two published crates, says three.

AGENTS.md: facts only. The crate table row, the published-crates and version sentences, and the
paragraph on the old runtime, whose name the runtime now carries (listed for the owner).

Made by one script run on this tip. Verified by the job
named in the landing note.
2026-11-20 09:10:02 -08:00
Anees Iqbal 97b5c1b65b Translator cutover: SEMANTICS_VERSION 2202; the API signature table and REFUSALS.md regenerated
The profile and the lowering of every device made through the removed constructor change, and
the removed switches' outputs go: the version bump misses every cached artifact. The signature
table drops the removed public items (blessed by scripts/api-signatures/signatures.py, source
only); REFUSALS.md loses the stage bound's defect site and the absent read's device refusal.
2026-11-20 09:08:21 -08:00
Anees Iqbal 98895eb6d2 rt: Gap::KernelInput names what the kernel reads, a KernelInputKind
A guest boot (arm64 macOS 15) met one Gap::KernelInput refusal at
newComputePipelineStateWithDescriptor:options:reflection:error:. The refusal said no more than
"the kernel reads an input the compute encoder does not supply yet", so it could not be ranked
by its cause.

Gap::KernelInput is now KernelInput { kind: KernelInputKind }. Its text ends with the kind, and
the kind is decided at the site that finds it:
- interface()'s six checks of the translator's pipeline: PointerTranslation,
  HandleTranslation, CommandBuffers, StageIn, DescriptorSet (a set that is not the device's),
  StageFlags (flags other than full or varying subgroups);
- its later checks: RuntimeFact (a fact the encoder does not name), Slot, PushField,
  ConstexprSampler, ArgumentBlock, PushBytes, Specialization, Workgroup;
- Kernel::new's entry point with a NUL byte: EntryPoint.
A variant that samples a constexpr sampler its module does not, and a constexpr use whose
sampler the translator cannot state, are ConstexprSampler.

interface() returns the kind itself, and Kernel::new returns an Unmade (the kind, or
vkCreateShaderModule's result). So a variant's lowering keeps the kind in
Lowered::Unsupplied(kind), and nothing has to tell a module's failure from a refusal by a
wildcard. Each variant's doc comment names its Metal counterpart.

docs/REFUSALS.md is regenerated and api_signatures.tsv is blessed. Its one changed line is
Gap::KernelInput, now a struct variant: a breaking change to rt's public surface, which is
meant.
2026-11-20 08:47:42 -08:00
Anees Iqbal b50bf56b3e rt and the translator's prose name no deleted crate; REFUSALS regenerated
- rt's error.rs: three Basis citations named the deleted runtime's view plan, mipmap plan and
  RenderPassProblem; each keeps its Metal evidence without them. docs/REFUSALS.md regenerated.
- rt's submit.rs: the group bounds' docs drop "the old runtime's bound".
- rt's alpha-test module doc cites its 413 probed rows without the deleted lane's test name.
- rt's Cargo.toml comment and README line 3: unpublished until it takes the name
  metal2vulkan-runtime.
- The translator: repro.rs and the cli test say a runtime writes repro bundles through
  `metal2vulkan::repro`; build.rs names a runtime's shader cache; api_surface.rs says
  `api_signatures` pins metal2vulkan-air and metal2vulkan-rt (its table is unchanged: no public
  item moved).

Verified: the compile job is named in the hand-off.
2026-11-20 07:58:57 -08:00
Anees Iqbal 5d725aeec7 Delete metal2vulkan-runtime, with every test and script that read it
The cutover deletes the old runtime: crates/metal2vulkan-runtime and its workspace member go.
Nothing in the workspace depends on it any more: the harness and conformance lost their old arms,
and validation dropped its dependency in its own commit.

Adapted in this commit, so no gate reads the deleted tree:
- CI and scripts/linux-gate-ci: the crate's per-feature clippy group, its `-p` in the Windows
  clippy and the test step, and its private-doc-links row go. Packaging needs no edit: the
  workspace's published crates are now metal2vulkan and metal2vulkan-air.
- The published-crates test lists those two; devtools' carried trees and the five nextest groups
  of the old crate's tests go.
- scripts/api-signatures: the crate leaves CRATES, FLOORS and the header, its self-test trees name
  rt (read by the same rules), and the table is re-blessed (the old crate's 4555 rows go);
  api_signatures.rs pins the three crates left.
- scripts/refusal-surface: the old crate's tree and its sections go (RuntimeGap, AppleOnly,
  Problem and the problem enums it forwards to), with their 87 reach rows, the `--delegations`
  verb and the test that counted the old Problem's delegations; docs/REFUSALS.md is regenerated.
  The basis check now holds rt's refusal enums alone, which it already required.
- scripts/api-cost-coverage goes: it measured only the old crate's surface.
- feature_vocabulary.rs: the old crate's two enable tables go; the Khronos and validation tables
  stay held to the vocabulary.
- The conformance coverage generator's by-hand roots read rt instead of the old crate, and
  docs/CONFORMANCE-COVERAGE.md is regenerated (MTLResourceOptions' row, which only the old crate
  modelled, gives way to rt's MTLCommandBufferError).
- scripts/matrix: the harness times the new runtime alone (`--runtime new`), so the rules that
  judged it against the old one go: the new-over-old budget with its floors (floors.tsv,
  gpu-floors.tsv), ceilings, card variance and status table (status.tsv), the frozen arm, the
  base spread and the timing once more it set off, the re-timed pairs, the five creation rounds
  and the old runtime's parked tests and records. A harness row's time is judged as a cross-GPU
  outlier, with its alone runs as before, and the frame and burst rows by their stored
  instruction counts; the creation rows run once, in their own process. docs/VALIDATION.md's
  matrix section says these rules.

Checked locally (python, no build): signatures.py --check and --selftest, refusal_surface.py
--check, --selftest and --missing-basis, coverage.py --check and --selftest, and scripts/matrix's
49 tests pass. The compile gate (fmt, clippy plain, --cfg m2v_gpu and --cfg m2v_cpu_icd, Windows
clippy for gnullvm and msvc, workspace Rustdoc, packaging, the touched crates' suites on the host
and on lavapipe) runs on this sha as potluck jobs that the landing note names.
2026-11-20 07:01:01 -08:00
Anees Iqbal 779eb522b4 Re-derive the generated documents at the landing tip
They are generated from the whole case set, and the set grew on `development`
while this branch was in flight, so the copy committed here counted a smaller
one.

Verified: regenerating at this tip leaves no change beyond the `Generated at`
stamp.
2026-11-20 06:59:54 -08:00
Anees Iqbal 6833eba8e2 identity domains: a 2D bicubic sample reads its slot's format treatment from a pushed word
Under the identity domains (Device::from_queries, the new runtime's translator device) every
kernel that sampled a texture through a bicubic constexpr sampler was refused as
Unsupported{IdentityDomains} ("a bicubic filter"), because the filter's treatment of the bound
format (its inner taps, its clamp and its border texels) was a SpecKey::BicubicTexels
specialization the old binder sets from the bound texture. One compute pipeline of every macOS
guest boot met that refusal; the old runtime builds it.

The treatment is now one u32 field per bicubic slot, PushField::BicubicTexels(SlotRef), placed
and filled as TextureIntegerChannels is. The 2D routine already took the bits as a run-time value
(Bits::Value), so a sample reads the field instead of the constant; no per-format pipeline, no
new descriptor. metal::format::bicubic_texels_word(pf, swizzle) gives the word the binder
specializes the constant to (BICUBIC_TEXELS_UNBOUND for a slot bound to nothing), and None for a
format of no measured family or of 8-bit sRGB codes. rt fills the field from the bound texture
when the slot's texture changes, and refuses a dispatch whose bicubic slot holds a texture with no
word as Gap::BicubicTexels, naming the slot and the pixel format. The static precision note
BicubicFilterArithmetic stays.

Still refused under the identity domains, each the refusal it was: a bicubic sample of a 1D
texture or at pixel coordinates (and the in-place two-plane routine), an argument buffer's
texture, an array of samplers. The default domains (Device::new, the frozen old runtime's path)
are unchanged: they still specialize SpecKey::BicubicTexels and state RuntimeFact::BicubicTexels,
and the binders refuse the new field.

SEMANTICS_VERSION 2199 -> 2200, ARTIFACT_FORMAT_VERSION 554 -> 555 (a new push field tag).
docs/REFUSALS.md regenerated; api_signatures table blessed; docs/API.md and the rt README's known
gaps say what is lowered and what is refused.

Tests:
- engine_identity::a_bicubic_kernel_reads_each_slots_format_treatment_from_its_pushed_field
  (replaces the refusal test; fails without the change): bcu_formats on lavapipe and moltenvk-m3
  profiles under the default domains keeps its 10 facts and 10 spec keys and no push field; under
  the identity domains it compiles, passes L3, pushes the 10 slots' fields, declares no spec key
  and no fact, and keeps the precision note; bcu_forms (1D) and bcu_address (pixel) still compile
  on the default domains and are refused under the identity domains.
- rt tests::bicubic (device cfg): each format bound at every slot of bcu_formats pushes its word,
  its arm asserted per format (R32Float linear; RGBA8Unorm, RGBA16Unorm, R8Unorm the [0, 1] clamp;
  RGBA8Snorm the [-1, 1] clamp; RGBA16Float no clamp), an unbound slot the unbound word, and an
  RGBA8Unorm_sRGB texture at slot 3 is Gap::BicubicTexels naming slot 3 and the format.
2026-11-20 02:55:02 -08:00
Anees Iqbal b506518794 rt: prepare_dispatch's tests, README and surface; the player's read-ahead encoder a struct
Tests: the pre-pass grid against each call's own (a saturated dispatchThreadgroups axis, a
dispatchThreads grid of u32::MAX on a size that does not divide it, indirect), GPU-free; on a
device, prepare-then-dispatch of an observing kernel for each kind, each call making exactly one
pipeline (and the ragged grid its one lowering) and the dispatch then waiting for nothing; a
second call making nothing; what the dispatch records nothing for or refuses making nothing; the
emulated-SIMD-group variant prepared; a square-form grid eight deep prepared; and the same
counts recorded and submitted with the calls and without, on two devices.

README: the hook in the compute pipeline states section, and the translation bound the caller's
width multiplies. api_signatures blessed; REFUSALS.md regenerated (the refusal sites moved into
the shared helpers, no new refusal).

Verified: the check job that follows this commit.
2026-11-20 02:44:56 -08:00
Anees Iqbal e4de7cc44e rt: undo the per-slot refill and the changed-words push; a draw and a dispatch refill every slot again
What. Reverts the refill series (68740984ba, 5b164777bd, 71ef1ba14b and its tests b97d37c104,
c076e8d17b, cd134b0995) on development, keeping everything landed since. A render or compute bind
marks the encoder changed again, and the next draw or dispatch finds and fills every slot's facts
and fields and writes every spilled block into the ring, as at f44fb795ae. A draw or a dispatch
whose push bytes the command buffer already holds pushes nothing; any other pushes the whole
window. Rebound, the per-slot facts, Pushed's span and mark, Metrics::push_bytes and
tests/refill.rs go; the push and push-window tests of f44fb795ae come back. rtover's over check
stays as it landed: the texture setters keep their over count (Tables::set_texture, the compute
encoder's `copied`), and the draw keeps Overs' reached form. docs/REFUSALS.md re-derived: the
refusal sites move back from `refilled` and `find` to `dispatch`.

Why. The planner's bar for the series, as amended: instructions a draw and a bind at or below
f44fb795ae's for the refill's own share. If the bar fails, the bookkeeping is undone, and the
push of changed words stays only if it alone meets the bar. Neither does. Harness, own user
instructions, 780M (um870, one round, m3-max-57484; the exclusive rounds m3-max-57397 on gem10
and m3-max-57398 on the 3090 read the same):

  arm                                      a draw   a bind
  f44fb795ae (the bar)                        842      739
  92b9cbb232 (the series alone on it)         963      874
  7096fa7de3 (development)                    958      887
  3cc134e439 (the series' fix)                943      835
  24dd31af87 (this undo, on 3cc134e439)       836      751
  05cca3d165 (the undo + changed words)       887      770

The series alone adds 14.3% a draw and 18.3% a bind. Its fix still left 11.9% and 13.0%. The
push of changed words on its own adds 5.3% a draw: comparing the window word by word costs more
than the whole-window compare it replaces. The undo is 0.7% under the bar a draw and 1.6% over it
a bind; the commits besides the series account for the +12 a bind (rtover's over count in
set_texture; bind_2000 sets a fragment texture before every draw). At the fix, bind_2000 was
18.7% slower on the 780M and 15.6% slower on the 3090. The gain the form was ordered for did not
come: on the video stream (vaapi-780m, lavapipe, m3-max-57454 and m3-max-57460), fields filled a
bind fell from 1.42 to 1.22, but the bind redo (fill_push, Facts::find and the held block) rose
from 901 to 1,079 instructions a draw.

Verified: the table above (m3-max-57484: each arm one harness process on a fresh cache, release).
24dd31af87 is this commit's rt, translator and validation tree but for dfb00c74c6's import test.
cargo fmt; the refusal surface regenerated with scripts/refusal-surface/refusal_surface.py.
2026-11-20 01:13:26 -08:00
Anees Iqbal f631d9081d Re-derive the generated documents at the landing tip
They are generated from the whole case set, and the set grew on `development`
while this branch was in flight, so the copy committed here counted a smaller
one.

Verified: regenerating at this tip leaves no change beyond the `Generated at`
stamp.
2026-11-20 00:05:53 -08:00
Anees Iqbal bda9935e09 rt: VK_NV_linear_color_attachment where listed; a plane renders through its bit only as a LINEAR image, marked, in a pass of such planes alone
The RTX 3090 and the RTX 5080 Laptop GPU (NVIDIA 620.70.06) give every plane format's linear
tiling, and its DRM_FORMAT_MOD_LINEAR modifier where listed,
VK_FORMAT_FEATURE_2_LINEAR_COLOR_ATTACHMENT_BIT_NV in place of the colour attachment feature.
Query::plane asked the image format query alone, which offers the colour attachment usage there,
so rt rendered NVIDIA's in-place planes through that bit with the extension off.

- Floor: VK_NV_linear_color_attachment joins OPTIONAL_EXTENSIONS (enabled where listed), and its
  linearColorAttachment feature (LINEAR_ATTACHMENTS) is enabled where the device lists the
  extension and reports it, which Vulkan requires of a device that lists it. Vulkan 1.3 needs no
  other extension for it (its dependency is VK_KHR_get_physical_device_properties2 or 1.1). The
  translator is told of neither. Core::linear_attachments carries the enabled feature.
- The plane test (surface::held_usage): a usage is offered where the image format query offers it
  AND the plane's own tiling's format features (LINEAR's for an opaque handle, the
  DRM_FORMAT_MOD_LINEAR modifier's for a dma-buf, read through VkDrmFormatModifierPropertiesList2EXT)
  hold what the optimal image has for that usage (texture::kept_features, the test a texture over a
  buffer takes), and for rendering the colour attachment feature itself
  (VUID-VkImageViewCreateInfo-usage-08931). The NV bit stands for the colour attachment feature only
  where linearColorAttachment is enabled AND the image is VK_IMAGE_TILING_LINEAR: Vulkan sets it
  "for renderable color formats in the linearTilingFeatures" alone. So NVIDIA's opaque fd planes stay
  in place on the enabled path and its dma-buf planes take the copy form (SurfaceCopy::Tiling).
- The condition, held by rt: a plane accepted through the NV bit is marked at its make
  (surface::linear_alone, SurfaceImage and Image linear_attachment, Attachment::linear). A pass's
  begin (Pass::check, pass::linear_shape, one mark read an attachment) refuses with the new
  Gap::LinearPlanePass { kind: LinearPlanePassKind }: OtherColor, a colour attachment that is not a
  marked plane (the extension's rule: "as long as all the color attachments in the render pass
  instance have VK_IMAGE_TILING_LINEAR tiling"); DepthStencil, a depth or stencil attachment (not
  Vulkan's rule: an RTX 3090 lost the device on that shape, and rt recovers from no loss, so by the
  ladder's third rung it is not used; the words name the driver); Resolve, a multisample
  attachment resolving into a marked plane. Every colour attachment marked (both planes of a
  picture in one pass among them) with nothing else set renders.
- Unchanged: a texture over a Shared buffer keeps its plain-bit test and its counted copy; the old
  runtime is not touched.

The rt README: the surface test and the marking (Exported surfaces), NVIDIA's dma-buf planes as a
copy-form known gap, the refusal among the render encoders' known gaps, the extension row and a
Linear attachments feature table (Floor); the clear-reach slip "inside the Metal's render area"
fixed. docs/REFUSALS.md regenerated; api_signatures.tsv blessed: the new variant and enum,
floor::Features::linear_attachment, OPTIONAL_EXTENSIONS' value.

Tests: tests::floor (the extension and feature enabled where listed and reported, the README
table); tests::surface::verdicts (NVIDIA's linear word: held and marked only as LINEAR with the
feature, the copy form without it and under the modifier either way, the plain bit unmarked,
blend and filter held to the optimal image); tests::pass (linear_shape: one and two marked planes
render, the three shapes refused); tests::linear_planes on device (a draw into one plane and both
planes in one pass rendered and compared on every device; the three shapes refused where the
plane is marked and rendered, compared, where it is not).
2026-11-19 22:13:45 -08:00
Anees Iqbal b676eda182 rt: a colour render target takes an index, and a draw reads it as an attachment as it reads a shader-read one
Metal fetches any render target, and its header gives every texture a handle with no tie to
usage (MTLTexture.h: gpuResourceID, "Handle of the GPU resource suitable for storing in an
Argument Buffer"). rt took an index only for shader-read or shader-write usage, so a colour
target made for rendering alone had no second element and every fetch from it was
Gap::Draw(FetchedAttachment): guest 26's 4,792 refusals, all of that shape.

- The index rule: shaders reach a texture made for shader reads or writes, or a colour render
  target (render-target usage of a pixel format with no depth or stencil), which takes an index
  exactly where it does (Refusal::TextureIndex), at every maker: new_texture and the heap, buffer
  and Managed makers, views, drawables and surface planes. A depth or stencil target made for
  neither is unchanged.
- A colour render target not read takes what a shader-read one takes for attachment reads: the
  sampled usage, and the feedback usage where the image format query offers both beside its
  usage; the shadow on a device without the loop; neither where the query refuses them, and its
  draws that read it stay Gap::Draw. Its home stays the attachment layout, so a pass that does
  not read it records no move of it, and a fetching pass moves it home, feedback, home with the
  existing move code.
- Only its second element is written: its sampled-texture element stays the null one, so a slot
  that binds it reads nil as before. place_texture takes the view its second element names in
  place of a flag.
- A linear image in place over a buffer takes no sampled usage for a target shaders do not read.
- The in-tree consumers take the rule: the replay player's texture class, the harness's and the
  conformance suite's rt side. rt's own tests make their unindexed colour targets with
  new_texture_for_views, and give indices where a test needs new_texture's path.
- docs/RESOURCE-ID.md, the runtime README and Refusal::TextureIndex's doc say the rule; docs/REFUSALS.md is regenerated.

Also rides along, from the planner, in the README's known gaps of memory blocks: a block freed
before a submission used it waits on the block-maker thread for its bind, and a ring take that
needs a new ring block can wait behind it.

Verified: see the check job named in the landing.
2026-11-19 21:40:56 -08:00
Anees Iqbal 7934b405d8 fetch (draft): surfaces read through the loop where their query offers it; loop reads counted; tests and docs
A surface plane whose texture is a shader-read render target takes the feedback
usage where the handle's image format query offers it with the export features
alike (Query::plane; a D3D11 import's query the same), and the in-place make
retries without it where the images with it do not hold the layout; a plane
without it reads through its shadow, the counted copy. The fetch and the texture
read choose the loop or the shadow by the image, not the device.
Metrics::attachment_loop_reads counts every draw that reads an attachment of its
own pass through the loop. Device tests (tests/fetch.rs): N fetching draws exact,
N-1 barriers or copies more than one; a surface plane of each fetched format.
RenderPipelineKind::FramebufferFetch removed. SEMANTICS_VERSION 2193,
ARTIFACT_FORMAT_VERSION 550 (PushField::FetchedColor). REFUSALS.md and
api_signatures regenerated; README and API.md.

Draft: the old render key re-pin follows the compile check.
2026-11-19 17:22:28 -08:00
Anees Iqbal 6eac85e79c rt: the resolve tables after the resolves metric and the resolve-format basis
m3-max-55101's REGEN and BLESS at 4153392249.

Verified: see the check job named in the landing.
2026-11-19 16:56:17 -08:00
Anees Iqbal 4dd8d707d1 rt: the resolve tables, the resolve-format basis the old runtime's records, and the resolve test's target usage
docs/REFUSALS.md and the API signature table regenerated for the resolve
items (m3-max-54897's REGEN and BLESS). Refusal::ResolveFormat's basis named a
device the cluster has no record of; it now cites what metal2vulkan-runtime's
RenderPassProblem::ResolveFormat records: Metal's validation assert for an
integer resolve target. The color resolve test's target took SHADER_READ,
which a texture made without an index refuses (lavapipe, m3-max-54897); a
resolve target needs RENDER_TARGET alone.

Verified: see the check job named in the landing.
2026-11-19 16:56:16 -08:00
Anees Iqbal 3fc316d576 identity domains: a render pipeline's functions spill past their shares of the floor's push range
Under the identity domains a vertex or fragment function whose push fields passed its share of
the floor's one 256-byte range was refused (Unsupported{IdentityDomains} needing
maxPushConstantsSize). Once containment added each checked slot's length (SlotRemaining) and the
zero range's address (ZeroAddress), pairs reached 272 bytes and were refused: 3 render states of
windrag-780m-b2 (223 draws) and 4 of syncview (259 draws), and the guest's GL-layer pipelines on
reims's walks. A render function now spills as a kernel does: it pushes its parameter block's
address first (PushField::ArgumentTableAddress) and reads every field past its window from the
block, each loaded once, in the function's first block (EmitCx::load_push_fields). The refusal and
its REFUSALS.md row are gone.

- Order: the check's fields are last in the derived Ord of PushField, after
  TessellationFactorAddress (ZeroAddress, then each SlotRemaining), so what every access reads is
  placed ahead of what only a checked access reads, and the check's fields are the first to move
  to the block. The codec's list is unchanged.
- The vertex function's floor window is [0, 248) (push::VERTEX_FLOOR_END). A vertex function is
  lowered without knowing its fragment function, and a fragment function that spills pushes its
  block's address (8 bytes, 8-aligned) from the vertex function's end, so the vertex function
  leaves that room. Cost: only a vertex function whose own fields pass 248 bytes spills where it
  used to fill the last 8.
- metal2vulkan-rt: Draws holds each field's place (the push range or its function's block) and
  each function's block (length, the push offset of its address). A draw that fills its pushed
  values anew writes each block into the parameter ring and its address into the range;
  ring_writes counts it. A block longer than a ring chunk stays Gap::RenderPipeline(DrawInput).
- SEMANTICS_VERSION 2194 (placement changed).

Tests: push.rs's edges (a vertex function ending at 248 with a spilling fragment function, whose
address goes at 248; a fragment base of 244, whose address is still at 248; a vertex function
whose fields would reach 252, which spills); engine_identity_spill: a vertex function of 25 slots
pushes its block's address first and every slot's address, spills only the check's fields, passes
L3, and loads each spilled field once in its first block; the pair with a fragment function from
248 compiles and validates on every identity profile; on the interpreter its sums are Metal's, and
lengths pushed one word short, in the window and in the block alike, read zero.

Docs: push.rs's module text, docs/API.md (section 1) and the rt README state the shares, the 248
and its reason, and the spill.
2026-11-19 15:59:29 -08:00
Anees Iqbal a69cb43486 translator: threadgroup memory reads zero until the program writes it, on Device::from_queries
On the new runtime's profile every Workgroup variable that holds a
function's threadgroup memory has a null initializer: the threadgroup
arena (declared threadgroup variables, [[threadgroup(n)]] regions and the
imageblock, memory::arena) and the typed threadgroup objects
(lower::access::local). One form on every device: the Vulkan 1.3 floor
requires shaderZeroInitializeWorkgroupMemory; a profile without it
refuses such a function, Unsupported{ZeroedThreadgroupMemory}.
Device::new's profile is unchanged (ProfileFacts::ROWS keeps
ThreadgroupStart::Unwritten), so the old runtime's SPIR-V is too.

The translator's own Workgroup words get none, as it writes each before
any read: the emulated SIMD-group scratch and vote word, the object
stage's mesh grid, the mesh wrapper's count and staged indices, the
emulated payload and the binder's scan and merge kernels.

The builder refused a null of an array whose length is a specialization
operation (spirv/ir/constant.rs, ConstRule::NullType); an arena with
regions, and the emulated scratch, have such lengths. spirv-val's
IsTypeNullable reads an array's element type alone, so the builder now
takes it. That refusal is what made rt report a probe's emulated variant
as missing (Gap::PartialSimdgroups after Later::lower's Refused).

The profile verifier also refuses a Workgroup initializer other than a
null (VUID-StandaloneSpirv-OpVariable-04734).

docs/API.md states the form with Metal's words on threadgroup memory;
SEMANTICS_VERSION 2192; REFUSALS.md and api_signatures regenerated.

Tests: engine_zeroed_threadgroup (null initializers through from_queries
on four profiles, zeros on the interpreter in both orders and two
threadgroups, the emulated variant's arena zeroed and scratch not,
Device::new uninitialized, the vk12 floor refused),
a_specialization_sized_array_has_a_null, a_workgroup_initializer_is_only_a_null,
the profile facts' fingerprint.
2026-11-19 13:52:35 -08:00
Anees Iqbal d65374348e rt: a Managed buffer's copy-in is a GPU copy from the consumer's block, and the capture ring goes
Metal's contract for a Managed buffer (MTLBuffer.h, didModifyRange:): a CPU write makes the range
undefined for the GPU until a didModifyRange: and a commit of the command buffer that reads it,
and it does not reach a command buffer committed before. The capture ring met that by copying
the bytes on the committing thread into 64 MiB of Shared staging, and the commit then waited for
the GPU whenever the ring was full. One recording on an RTX 3090 waited 258 times for 6.7 s
(m3-max-53409). The ring also kept a Managed buffer over an imported dma-buf, a block the runtime
does not map, refused (Refusal::ManagedBlockNotShared). On the XTX that refusal bound nil 2,804
times, and 28.8 million draws were then refused.

The planner ruled one form. The commit records the copy-in into a command buffer of its own:
vkCmdCopyBuffer of each named range from the consumer's block into the device copy, ahead of the
command buffer's commands in its submission, after the copies back owed to textures over the
ranges and before the copies into them. Vulkan's host write ordering guarantee makes the
consumer's writes made before the submission visible to the copies. The copy reads the bytes as
it runs, so a write after the commit may reach it, which Metal leaves undefined. The copy-in
holds each consumer's block and device copy until the command buffer retires.

What goes with the ring:
- capture.rs keeps the named ranges and the copy-in, and loses the ring, Chunk, Overflowed and
  the staging blocks of its own;
- submit.rs loses the commits' turn (capture now records under the work lock), the streams of
  ring-fulls, the waits and the ring's spans;
- the counters lose capture_waits, capture_streams, capture_overflows, capture_overflow_bytes,
  capture_copy_nanos, capture_wait_nanos, Gauges::capture_bytes and the capture ring's site, and
  managed_bytes_captured counts the bytes the copies take;
- the player's report and the API table lose the same fields.

A Managed buffer's bytes may be in any Shared block, mapped or not: contents is None over an
import. A Private block is refused as Refusal::ManagedBlockPrivate, since a Managed buffer has a
CPU-side copy ("the data pointer of this buffer's shared copy", MTLBuffer.h) and a Private block
has no pages the consumer can write. docs/REFUSALS.md is regenerated. The rt README's memory
contract says when the copy runs, and its known gap of the ring's waits goes.

Tests:
- the snapshot tests now hold the header's contract: write, didModifyRange:, commit, and that
  command buffer reads the bytes, here also behind an event wait with the consumer's handles
  gone before it runs. Nothing is asserted of a write under a pending command buffer;
- the ring's tests go;
- a range of three 16 MiB units arrives whole at one commit, with no staging and no allocation;
- a Managed buffer over an imported, unmapped dma-buf (Shared, contents None) reads what the
  consumer wrote through its own mapping, on a two-copy card and on a unified one;
- a Managed buffer over a Private block is refused;
- the first named range allocates nothing at any site;
- the commit's lock-wait test marks the start of its count with a test-only flag, where it read
  the turn.

Verified: see the check job named in the landing.
2026-11-19 13:47:06 -08:00
Anees Iqbal 7834c2afe6 rt: import a picture's Direct3D 11 textures as a surface, in place, with no make-time submission
Device::import_d3d11_surface was a typed refusal (Gap::D3d11Surface). It now imports each plane's
NT handle (VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D11_TEXTURE_BIT) into a dedicated allocation bound to
an optimal image of the Direct3D 11 texture's own format, mutable and listing the descriptor's
format where the two differ (two formats a plane: R16Uint under RG8Unorm), into the first
device-local type the handle's properties and the image's requirements share. Usage is each of
sampled, rendered, copied and storage the import query offers and the view format's features
hold. Each import counts in Gauges::surface_imports, now on every host.

No submission and no wait at the make: Vulkan 1.4 section 12.5.2 says such images "can be
assumed to be in that layout when they are accessed in Vulkan after external access", and its
table gives the D3D11 texture handle VK_IMAGE_LAYOUT_GENERAL. The plane textures start homed in
the general layout; external_writes_done acquires from VK_QUEUE_FAMILY_EXTERNAL in GENERAL
(VUID-VkImageMemoryBarrier-srcQueueFamilyIndex-12332) and release_surface_to_external releases to
it in GENERAL (dstQueueFamilyIndex-12331). No keyed mutex. The consumer's precondition (Direct3D
11 wrote the plane before rt's first use, and external_writes_done follows that work) is stated
in the call's doc and the rt README.

Surface gains an imported kind: Surface::handle is Option<ExportHandle> (None for the import),
and Surface::buffer is Gap::D3d11SurfaceBuffer, its planes lying in memories of their own.
ImportHandle::D3d11Texture names the handle in Limit::NoImport and Limit::ImportType.
Refusal::SurfacePlanes covers no plane or more than four. REFUSALS.md and the signature table
are regenerated.

The tests: on every device, the import's typed refusals (no plane, five planes, a one-byte image
format under a two-byte view). Under m2v_gpu on Windows, two shared Direct3D 11 textures (R8_UNORM
64x32, R16_UINT 32x16 viewed as RG8Unorm) on the DXGI adapter of the device's LUID, bound by hand
from the SDK headers' vtables: the import submits nothing; Direct3D 11 writes picture 1 and rt
reads it exactly; Direct3D 11 writes picture 2, unlike picture 1 at every byte, and rt reads it
exactly and unlike picture 1 at every byte (the negative control); rt writes picture 3 and
releases it, and Direct3D 11 reads it exactly through staging copies.
2026-11-19 13:36:21 -08:00
Anees Iqbal 7a064aca1b Re-derive the generated documents at the landing tip
They are generated from the whole case set, and the set grew on `development`
while this branch was in flight, so the copy committed here counted a smaller
one.

Verified: regenerating at this tip leaves no change beyond the `Generated at`
stamp.
2026-11-19 12:53:25 -08:00
Anees Iqbal 5a31141d47 rt texture views: Metal's casts of a cube, a cube array and a 2D texture over the same image
The replay streams' gap substitutes were all one view: newTextureViewWithPixelFormat:
textureType:levels:slices:swizzle:resourceIndex: as a 2D array of a cube's six faces, which rt
answered Gap::TextureView (TextureType) and the old runtime makes. Vulkan views a cube-compatible
image, as a cube's and a cube array's are, as a 2D, 2D array, cube or cube array of its layers, and
any image as a 2D array of one layer, with no query, so each is one form on every device.

Texture::new_texture_view now builds those of Metal's casts (Apple's makeTextureView page): a cube
or a cube array to a 2D texture, a 2D array, a cube or a cube array, a cube array's whole cubes as
a cube array, and a 2D texture to a 2D array of its one slice, beside the 2D array to 2D it built.
A cube or cube array view of a 2D array needs a cube-compatible image the 2D array is not made as,
and stays a gap that says so (TextureViewKind::CubeOfArray). A slice count the view's type does not
take (one for 2D, six for a cube, a multiple of six for a cube array) is Metal's validation's stop,
now Refusal::TextureViewSlices where it was a gap. The descriptor answers Metal's: the type, the
extent of the first level, the levels, and the array length in cubes for a cube type.

The device test every_device_views_a_cube_s_faces_as_metal_casts_them makes seven such views and
reads each one's first level and slice by a blit against the parent's bytes under them; the old
expectations move with the rule. REFUSALS.md, the API signature table and rt's README follow.

Verified: built and tested in the jobs the landing message names.
2026-11-19 12:51:50 -08:00
Anees Iqbal 54d43118a9 Re-derive the generated documents at the landing tip
They are generated from the whole case set, and the set grew on `development`
while this branch was in flight, so the copy committed here counted a smaller
one.

Verified: regenerating at this tip leaves no change beyond the `Generated at`
stamp.
2026-11-19 12:25:05 -08:00
Anees Iqbal de3acd5e61 rt import: the several-dma-buf import's tests, docs and tables
A device test reads and writes a block over three dma-bufs of one memfd (one, two and one
granule) across both chunk boundaries: add reads across the first and writes across the second
through the GPU addresses, then a blit reads across the second and writes across the first through
the buffer; every byte of the memfd is checked after. Refusals (no dma-buf, a length off the
granule) import nothing; a device with no granule refuses typed. A second device test times
vkQueueSubmit2 beside 40 live dma-bufs of one block and beside 40 one-dma-buf blocks against none.
A unit test holds the granule rule.

README (imported blocks, the extension table, sparseBinding beside the optional features, the
known gaps with the Iris's dma-buf type), REFUSALS.md, api_signatures, and the player's
sparse_binds counter.
2026-11-19 12:24:12 -08:00
Anees Iqbal 60eff8b12a Re-derive the generated documents at the landing tip
They are generated from the whole case set, and the set grew on `development`
while this branch was in flight, so the copy committed here counted a smaller
one.

Verified: regenerating at this tip leaves no change beyond the `Generated at`
stamp.
2026-11-19 12:22:14 -08:00
Anees Iqbal 42993be0bc rt surface: Device::import_d3d11_surface's signature, refused typed until the import is built
The Windows surface import's public shape, so a consumer can build against it now:
#[cfg(windows)] Device::import_d3d11_surface(&self, planes: &[D3d11Plane<'_>]) ->
Result<Surface, Error>, with D3d11Plane { handle: BorrowedHandle, image_format, descriptor,
index } per plane: the Direct3D 11 texture's shared handle and own format, and the texture rt
makes over it. Until the import is built every call answers the new Gap::D3d11Surface (basis
ours), whose Metal counterpart is a texture over an IOSurface's plane.

A Windows device test holds the refusal for no plane and for one. REFUSALS.md and
api_signatures regenerated; the rt README's surfaces section names the call.
2026-11-19 11:48:29 -08:00
Anees Iqbal ac678d7d1e rt surface: Surface::buffer, a buffer over an exported surface's own memory
What: Surface::buffer() answers a Buffer over the surface's memory, of the export's size, at the
layout the SurfaceExport states. In place it is made at the first call, never at the surface's
make: of an opaque handle, a buffer bound at the first byte of the one allocation the planes are
bound in (memory::surface_view; the allocation now takes device addresses, which the buffer's
binding needs); of a dma-buf, a buffer on one more import of the dma-buf (import::surface_import)
into the memory type the planes' imports took, through a duplicate of an fd the surface keeps,
attempted only where the device's buffers import a dma-buf and the fd's query and the buffer's
requirements list that type. The copy form answers its block's buffer. The first call records
the buffer's acquire from the other API's queue family; external_writes_done acquires it with
the planes and release_surface_to_external releases it with them, writing back the copies of
textures over it first.

The surface, its planes and their views, and its buffer are one unit in the hazard sets: the
planes take a HeapId::unit at the make and the buffer takes the same one, so a kernel's write
through the buffer orders the next kernel's read through a plane as a heap's resources do.

Counted in the new Gauges::surface_buffers (a dma-buf's also in surface_imports); refused with
Limit::ExportType, Limit::NoImport and the new Error::Fd (no duplicate of the fd). The doc comment
quotes Vulkan 12.11 Memory Aliasing and the fd import's multiple-import sentence, and names the
same-instance reading the dma-buf form takes.

Test: every_device_carries_each_form_of_surface gains the buffer round (two pictures the second
device wrote read through the buffer, one at its make and one after external_writes_done, with a
one-byte-off negative control; a picture blitted into the buffer read through the planes and the
handle) and, on 1080p with llvm-as, the compute round (a kernel writes through the buffer, the
next reads plane 0 through a view; texels exact, and in place one barrier more than a control
whose first kernel writes a buffer of its own). Each device prints whether its buffers import a
dma-buf. Not yet run.

docs/REFUSALS.md and api_signatures.tsv regenerated; the rt guide states the contract.
2026-11-19 10:50:42 -08:00
Anees Iqbal 0126e3adbc rt: a texture for views placed in a heap, by the heap texture's rule
Device::new_heap_texture_for_views(descriptor, heap, offset) is MTLHeap's
newTextureWithDescriptor:offset: for a texture reached through its views alone. It is the texture
Device::new_texture_for_views makes, with its image bound at offset in a Private heap range of a
block the consumer holds. Nothing is allocated, and the bytes are the ones the heap's memory holds
there, so nothing is zeroed. Its uses and its views' uses take the heap's id in the hazard sets,
and the texture holds the block. What differs from Metal is what differs for
new_texture_for_views: it has no index of its own.

Why: the consumer's cache shape images are textures for views. Until now they took rt's own
texture block or an allocation of their own, sometimes on the consumer's ring thread; one measured
24.6 ms for 34.5 MiB. With this call they come from the consumer's Private pieces, which it makes
ahead, so the consumer's pool stays the one place memory is made ahead.

How: one rule, not a second path. Device::heap_source is the heap check new_heap_texture made
inline: the block is the consumer's, and it is Private and not exported (Gap::HeapTexture
otherwise). Both new_heap_texture (Reach::Index) and the new call (Reach::Views) take their
Source::Heap from it into Device::texture, which binds it through Bind::Heap and heap_fit as
before. The README's texture-for-views entry, HeapRange's doc, and the docs of Gap::HeapTexture and
Refusal::HeapTexturePlace name the call. The signature table is re-blessed (one method added).
REFUSALS.md regenerates with heap_source as the refusal's site.

Test: tests::heap::every_device_places_a_texture_for_views_in_a_heap (device cfgs). In a heap
range of a Private block, the make moves neither Metrics::texture_allocations nor
texture_block_allocations, adds no block and no texture block, and the texture answers index 0.
A view's replace_region is read back by the texture's get_bytes, and the texture's write is read
back by the view's. A placement off the image's alignment is Refusal::HeapTexturePlace, and a
Shared block's heap is Gap::HeapTexture.

Verified: cargo fmt, signatures.py --check. The clippy, lavapipe and GPU runs follow in potluck
jobs.
2026-11-19 10:08:35 -08:00
Anees Iqbal 37adfb0756 rt surface docs: the guide's exported surfaces, the dma-buf copy-form gap, the refusals and the API table
The README says in one place what each handle needs for in place, the layout
rule, the copy form's reasons and the one consumer contract. REFUSALS.md and
api_signatures.tsv regenerated by their scripts.
2026-11-19 08:09:12 -08:00
Anees Iqbal 407b5a1078 rt: a fence orders encoders across queues; Gap::FenceOtherQueue goes
A fence used on a second queue was refused (Gap::FenceOtherQueue): 18 refusals in a
live boot on a 780M, every one a fence update on a second queue. The rule was ours,
from a replay census in which no fence crossed queues, not Metal's contract: the headers
say a fence update and wait are each "evaluated at kernel submission to maintain global
order and prevent deadlock", and MTLFence.h says nothing about queues.

What Metal does, measured (probe cross_queue_fence_held_update.m, M3 Max, macOS 27.0.1,
jobs m3-max-52186, m3-max-52188, m3-max-52194, plain and under the validation layer):
a wait on queue B waits for an update on queue A submitted before it (untracked
buffers: B starts 0.3-1 us after A ends and reads all its words; with no fence B runs
beside A and reads none); a wait with no work after it waits too (its handler 0.11-0.16
ms after A's GPU end); an update in a command buffer Metal holds, at an MTLSharedEvent
or MTLEvent wait, behind one held so, or behind an uncommitted enqueue, is not waited
for (B completes in 0.2-3.5 ms without A's writes, A still Committed).

Every rt queue submits to the device's one VkQueue and each segment ends with a
barrier, so a wait sees every update submitted before it. B passes A in four places:
(i) A's head held at an event wait, (iii) behind an uncommitted enqueue, both Metal's
own behaviour per the probe, so no hold and no gap; (ii) A's command buffer in a group
the submit thread holds while A's submissions run, and (iv) held groups released in
FIFO order rather than commit order, both rt's own. For those: each command buffer
keeps the fences its encoders wait on and update (empty, nothing allocated, when it
uses none); before a segment of a command buffer that waits on a fence is staged, the
submit thread sends first any other queue's held group (member or partial head) that
updates one, by send_through as a host wait does. A command buffer with nothing for the
GPU that waits on a fence retires no earlier than the last submission carrying an
update of it (the fence keeps that progress value, set in close). Same-queue fence use
is unchanged in submissions; no fence: one empty-Vec test per staged segment.

Tests: the two other-queue cases turned to accept; a new device test with A held in a
group behind the busy gate: (1) B's wait committed after reads A's fill, (2) B's wait
held at a shared event, released after A's later update joined the group, reads it,
(3) B's fence-only wait does not complete before A's update; and a corner test: a wait
on B runs while A's update is held at an event wait or behind an enqueue, without its
write, then A runs once let go. Docs: fence.rs, the three encoder sites, the rt README,
REFUSALS regenerated, api_signatures.tsv loses the variant.
2026-11-19 07:04:20 -08:00
Anees Iqbal 4231c5ba25 rt, translator: a declared write of a texture with no storage element refuses the argument-buffer dispatch
What: bug 4's held path. A compute encoder's use_resource with a usage that writes a texture (or a
view of one) made for shader writes with no storage element (Texture::unstored) now makes every
later dispatch of that encoder whose kernel may reach a texture through its storage image beyond
its bound slots Gap::StorageElement, with no slot and the texture's format. A kernel without such
an access dispatches whatever is resident, and use_heap declares nothing (Apple's header: useHeap
declares the heap's resources read only through an argument buffer), so a write through a
resource ID with no write-usage use_resource stays dropped, outside documented Metal.

How: the translator had no fact for that access (writes_unbound_resources with
texture_writing_stages would also refuse a kernel that writes a bound texture and a buffer through
an argument buffer), so StageInterface and PipelineInterface gain unbound_storage_textures,
decided in compile/unbound.rs beside the read and write facts: a texture write or atomic, or a
read of a texture the operation declares access::write or access::read_write, on a handle that
may come from memory, an integer or a call; an intersection or a call the entry cannot see into
counts; indirect-command and acceleration-structure operations touch no texture.
Gap::StorageElement's slot becomes Option<u32>. The render encoder builds no useResource:, so the
draw half has no trigger; the README says it waits for it.

SEMANTICS_VERSION 2190 -> 2191 and ARTIFACT_FORMAT_VERSION 547 -> 548 (one field in
StageInterface and PipelineInterface). docs/REFUSALS.md regenerated; api_signatures gains the
field and the variant's new shape; docs/API.md states the fact; the rt README's known gap says
what is refused and what stays dropped.

Tests: the translator's unbound-facts test states the new fact (an argument buffer's texture
write and a read_write read count, a sample and a read do not); storage_element gains
every_device_refuses_a_declared_write_of_a_texture_with_no_storage_element over RGBA8Unorm_sRGB,
BGRA8Unorm_sRGB, A8Unorm and an sRGB view of an RGBA8Unorm texture, and the same formats in a heap
under use_heap alone.

Verified so far: cargo fmt; refusal_surface.py, signatures.py --check and metal-coverage --check
give no further diff. The build, the suites and the device legs follow in potluck jobs.
2026-11-19 05:09:37 -08:00
Anees Iqbal cce95596b4 rt: a threadgroup within Metal's limit for the kernel and past this device's is the device's Limit, not Metal's refusal
A compute state answers the least of Metal's maxTotalThreadsPerThreadgroup for the kernel and
this device's limits for it (maxComputeWorkGroupSize, its subgroups' count, and for emulated SIMD
groups their scratch beside maxComputeSharedMemorySize). A dispatch past that answer was
Refusal::ThreadgroupSize, which states that Metal itself refuses the threadgroup: on lavapipe
compute-threadgroup-simd-scratch's 1024 threads, which Metal runs, were refused as "past the
state's 256" and the suite counted our refusal where the old runtime reports the device's lack
(MaxComputeSharedMemorySize 32768 against 57344).

The interface keeps Metal's own answer beside the state's
(ComputePipelineMetalInfo::metal_max_total_threads_per_threadgroup, or a required size's
threads). A threadgroup past Metal's answer stays Refusal::ThreadgroupSize; one within it and past
the state's is the new Limit::ThreadgroupThreads { size, max }, basis device. The conformance
crate's rt side reads that limit as the venue's lack, as it reads the translator's device gaps.
REFUSALS.md and api_signatures.tsv regenerated.

Verified at this commit: cargo fmt, refusal_surface.py, signatures.py --bless and coverage.py
--check; the build, the suites and the lavapipe replay (where the case should read lacks-feature)
run in the lane's check job.
2026-11-19 04:44:17 -08:00
Anees Iqbal b683148a41 rt, translator: the identity domains give a SIMD-group's threads no lockstep order
What: under the identity domains (the new runtime's profile) the translator no longer inserts the
barriers that make Apple's SIMD-group lockstep explicit (`lockstep::order`): `OrderKey::of` is
`None` there and `ordered_entry` takes the specialized entry as it is. The resident-table domains
(the old runtime's) keep the order until the cutover. With no lockstep barrier on the new
runtime's path, its one-row machinery is dead and deleted: `Compiled::rows`, `pipeline::one_row`,
`encoder::Module::Rows`, `keeps_rows` and `choose`'s `rows`, the `OneRow` and `RowLockstep` arms,
and the translator's `CompiledFunction::runs_lockstep_barriers_in_rows` with
`KernelFacts::lockstep_in_rows` (the API signature table; the version numbers rise in the
branch's last commit).

Why: documented Metal orders the threads of a SIMD-group only through barriers and atomics; the
Metal Shading Language calls two of them that conflict between barriers a data race. The order was
an emulation of undocumented Apple-GPU behaviour (owner's rule 1). Its barriers made 1,443 of 5,368
distinct kernels of the recorded streams observe their threadgroup partition, every pair of them
unproven, and they stopped partial-threadgroup dispatches the variant cannot run (rt's frame-320 and
frame-335 refusals of the 30-wide kernels). docs/API.md's accepted differences gain one entry, the
conformance case `simdgroup_lockstep` leaves its output words unchecked against it, and
CONFORMANCE-COVERAGE.md and REFUSALS.md are regenerated.

Tests: the identity-profile one-row test becomes `the_identity_domains_order_no_lockstep_pair`
(barriers under the default domains, none under the identity domains, the partial variant in
tiles); the harness's cells test keeps the old domains' one-row facts and adds the identity
domains' none; rt's one-row tests and the row-lockstep tree test go, and `row_cells` runs every grid
on its tiles' pipeline made with the state.

Verified: cargo fmt; coverage.py and refusal_surface.py regenerated. Clippy and the suites run on
the check job named when the branch is handed over.
2026-11-19 04:21:14 -08:00
Anees Iqbal 42f9e9137f rt: a pass keeps its visibility result buffer; Disabled is the visibility mode built
The two tessellation streams' render passes set a visibility result buffer and
enable no mode; rt skipped every such encoder (Unheld(visibilityResultBuffer)).
On an Apple M3 Max (macOS 27.0.1, job m3-max-51220) a pass with the buffer and
no mode leaves the buffer's bytes as they were under Reset and under Accumulate,
so the planner's minimal form is exact and carries no note.

- RenderPassDescriptor.visibility_result_buffer: checked for its device
  (Refusal::OtherDevice) and kept by the command buffer until it retires, as
  Metal's pass holds it. It declares no access and joins no hazard set: no
  command of the pass reaches it.
- RenderCommandEncoder::set_visibility_result_mode: Disabled at any offset is a
  no-op; Boolean and Counting are Gap::Draw of the new DrawKind::VisibilityResults.
- visibilityResultType is not a field: it decides only what an enabled mode
  writes.
- Device test: the pass draws, the buffer's gauge holds after the test's handle
  is gone and falls once the command buffer retires, its bytes are unchanged,
  and the pass takes the submissions, barriers and passes of one without it.
- Conformance: the rt side passes the buffer and the mode; new cases
  visibility-disabled-reset and visibility-disabled-accumulate (no mode in one
  pass, Disabled at both words in the next); recordings follow from the M3.
- Player: setPass's visibilityResultBuffer goes into the new field (a skipped
  buffer still marks the pass unheld).
- rt README, api_signatures and docs/REFUSALS.md regenerated.

Verified: cargo fmt only so far; builds, clippy and device legs follow as
potluck jobs.
2026-11-19 03:30:37 -08:00
Anees Iqbal f811bb4716 rt: a blit encoder releases an exported block to the other API, in its command buffer
The read direction of an export: another API (a video encoder) reads what a blit
wrote into an exported block. BlitCommandEncoder::release_to_external(&buffer),
which Metal has no counterpart of, records one buffer barrier into the encoder's
command buffer after every earlier command: the whole block's release from rt's
queue family to the acquire's other family (EXTERNAL for an opaque handle,
FOREIGN_EXT for a dma-buf), src ALL_COMMANDS / MEMORY_WRITE. No submission of its
own, nothing on the submit thread, no wait. It is a write use of the buffer for
the encoder's ordering: textures over a buffer in the block copy back first, and
since Vulkan ignores a release's second scope and only ALL_COMMANDS waits for it,
the barrier after it is owed (Building::release_command, beside owe_pass; the
flag owed_pass is now owed_all), paid by the next command or the command buffer's
end barrier. Counted in Metrics::external_releases and Metrics::barriers. A
buffer whose block is not exported is Refusal::NotExported (its doc and Display
now name the release too).

Release after release without an acquire is the spec's own case (7.7.6 NOTE: "It
is valid to never call the acquire operation after a release, and instead simply
start using the resource on any queue (even the releasing queue), but the
contents should be reinitialized before being read"), so the next frame's blit
needs no acquire. The README and the acquire's doc state the read direction's
contract: the other API reads from the command buffer's completion; from the call
until the consumer's next write through the runtime, the runtime reads nothing of
the block and the consumer encodes no read of it.

The export device test now releases through the call, twice in two command
buffers with no acquire between (fill, release, fill, release), and the second
device reads the second fill's bytes; a release of a buffer in a taken block is
NotExported; external_releases grows by 2. REFUSALS.md and the API signature table
regenerated; the replay's metrics name external_releases.

Verified: build and device legs follow (job ids in the lane's report).
2026-11-19 02:42:38 -08:00
Anees Iqbal 0ecac16dd3 rt: a render state answers Metal's imageblock sample and memory lengths; one imageblock gap
The consumer asked for RenderPipelineState's imageblockSampleLength and
imageblockMemoryLengthForDimensions:. Metal's render answer is not 0 without an explicit
imageblock: it counts the color attachments' texels (measured on an M3 Max and an M4, and kept
by the translator as metal::format::imageblock_sample_length: [R8Unorm, R32Float] is 8). rt makes
no state whose fragment function reaches an imageblock (RenderPipelineKind::Imageblock), so a
state's sample is its colors alone, computed once per content from the descriptor's color
formats; the memory length is that times the width, the height and the raster sample count, none
rounded, as the old runtime answers it from the same measurements. A color format with no
measured place in Metal's record answers the gap.

The gap is one variant for both states: Gap::ImageblockMemoryLength { dimensions } becomes
Gap::ImageblockLength, which the compute state answers for a kernel that declares an imageblock
it never reaches (or whose compile kept no reflection to tell) and the render state for an
unmeasured color format. The compute state's imageblock_memory_length_for_dimensions answers u64,
as the render state's does.

Test: every_device_answers_a_state_s_metal_answers also makes a render state of R8Unorm and
R32Float colors: 8 bytes a sample, 512 for 8 by 8 pixels of one sample. README (render states;
the compute paragraph's gap name), api_signatures.tsv and REFUSALS.md regenerated.

Verified at this commit: cargo fmt only. The build and device legs run on the lane's tip.
2026-11-19 02:36:04 -08:00
Anees Iqbal c57b0436c8 rt: a compute state answers Metal's static threadgroup memory, execution width and imageblock length
The consumer counts each Metal answer rt holds but does not give. ComputePipelineState now
answers three more, each from its whole module's translation, kept per content (Answers):

- static_threadgroup_memory_length(): staticThreadgroupMemoryLength, the translator's
  ComputePipelineMetalInfo::static_threadgroup_memory_length (rounded up to 16 as Metal reports
  it); the threadgroup memory rt adds beside it is not counted.
- thread_execution_width(): threadExecutionWidth, the translator's thread_execution_width, 32 on
  every device (the old runtime answers the same value from the translator): a kernel that
  observes its SIMD group runs it 32 wide, and one that does not cannot tell its width.
- imageblock_memory_length_for_dimensions(dimensions): 0 for a kernel that declares no
  imageblock. rt makes no state for a kernel that reaches an imageblock (the translator records
  RuntimeFact::ImageblockSize on its first use, which the interface refuses as Gap::KernelInput),
  but the translator plans only used parameters, so a kernel that declares an imageblock it never
  reaches does get a state. For it, and where the compile kept no reflection to tell, the answer
  is the new Gap::ImageblockMemoryLength { dimensions }: no authored case measures Metal's length.
  Whether the kernel declares one is read once per content from the reflection its compile kept
  (ComputePipelineDescriptor::reflection over StageSource::Compiled, decoding nothing).

Test: every_device_answers_a_state_s_metal_answers (device cfgs): the harness's block_scan
answers 1024 bytes of static threadgroup memory (256 words), sample_down 0; both 32 wide and an
imageblock length of 0. README (compute states), api_signatures.tsv and REFUSALS.md (26 -> 27
gaps) regenerated.

Verified at this commit: cargo fmt only. The build (clippy of rt under both device cfgs) and the
device legs run on the lane's tip.
2026-11-19 02:36:03 -08:00
Anees Iqbal 18c52e7a8c rt: a heap's resources take one id in the hazard sets, the heap's
What: every buffer and texture placed in one heap takes the heap's id in the compute encoders'
hazard sets, whatever its tracking mode and whatever bytes it reaches. A heap is the one at its
offset in its block (`HeapRange`); `HeapIds` maps each to an id that lives while a resource of the
heap does, the entries of gone heaps dropped once the map doubles (at least 64). Textures placed
by `new_heap_texture` take it at once. Buffers take it through the new
`Device::new_heap_buffer(heap, offset, length)`, `MTLHeap`'s `newBufferWithLength:options:offset:`
(a buffer past the heap's end is `Refusal::HeapBufferPlace`); a buffer placed by `new_buffer` is no
heap's and keeps its own id. Views take their parent's; a texture in place over a heap buffer takes
the buffer's. Only the hazard sets read it: the copies over buffers and a pass's attachments keep
naming resources by their own ids (`Accesses::each(interface, tracked)`). The player places a
stream heap's buffers with `new_heap_buffer` and a stream block's with `new_buffer`; the
conformance crate's heap buffers take `new_heap_buffer`.

Why: Metal tracks a heap's resources as one, "tracking is done at the granularity of the heap"
(MTLHeap.h, hazardTrackingMode), and the old runtime keys a heap buffer's and a heap texture's
hazard identity by its heap (metal2vulkan-runtime heap.rs, tracker.rs). rt keyed them by resource,
so inside one encoder, or after an encoder that only read, a write through one heap resource and a
use of another over the same bytes got no barrier.

Tests: `every_device_orders_a_heap_s_resources_as_one`: two heap buffers over the same bytes take
a barrier between a write and a use and the second sees the first's words; two apart in one heap
take one too; two heaps' none; a buffer past its heap's end is refused; 200 heaps that come and go
leave at most 64 entries. docs/REFUSALS.md and the API signature table regenerated (two records
added: the method and the refusal).

Verified: cargo fmt; refusal_surface.py and signatures.py --bless. Build, clippy and the device
suites on the check job named when the branch is handed over.
2026-11-19 02:17:05 -08:00
Anees Iqbal 608e084db1 rt: Block::external_writes_done, the acquire of another API's writes into an exported block
A decoder writes a frame into an exported block through its import of the handle; the
runtime's commands may read it only after the block's ownership comes back from the other
API's queue family. Vulkan's external memory requires that transfer whatever the sharing mode
(section 7.7.6, "Resources shared with external APIs or instances using external memory must
also explicitly manage ownership transfers between local and external queues").

Block::external_writes_done() records the acquire: one buffer barrier of the whole block, from
VK_QUEUE_FAMILY_EXTERNAL for an opaque handle (same device and driver) or from
VK_QUEUE_FAMILY_FOREIGN_EXT for a dma-buf (another driver), to the runtime's family, visible to
every later command. It goes in the upload, as zero_block_range's fill does: submitted ahead of
every command buffer committed after the call, holding the block until it completes, with no
wait for the GPU. The consumer calls it after its own wait on the decoder. A dma-buf names the
foreign family, which VUID-VkBufferMemoryBarrier2-srcQueueFamilyIndex-09099 allows only with
VK_EXT_queue_family_foreign enabled; new_exported_block already refuses a dma-buf export where
it is not (Limit::ExportType { listed: None }), so every exported dma-buf block can name it.

No release back to the other API is recorded. Section 7.7.6: "If an application does not need
the contents of a resource to remain valid when transferring from one queue family to another,
then the ownership transfer should be skipped." A decoder that overwrites the whole block needs
nothing the runtime left in it, so only the decoder-to-runtime direction is a transfer. The
contract, in the rt README beside the two calls: between external_writes_done and the other
API's next write of the whole block, the other API does not access the block, to read or to
write. The old runtime records the same acquire and no release.

Metrics::external_acquires counts the acquires (each also one of Metrics::barriers); the
replay report prints it. A block that is not exported is Refusal::NotExported. memory::Own's
Export carries the handle, which names the family.

docs/REFUSALS.md regenerated; api_signatures blessed.

Tests (src/tests/export.rs, device cfgs): after the second device has read rt's bytes, it fills
the whole block and releases it to the external family; external_writes_done is counted, and a
blit then reads the second device's bytes. An acquire of a taken block is refused typed.

Verified at this commit: cargo fmt only. The lane's build and device legs run on the tip that
carries it.
2026-11-19 01:50:14 -08:00
Anees Iqbal ea9b65a972 rt: Device::new_exported_block, one dedicated exportable allocation per block
The consumer's video path shares decode surfaces with a hardware decoder: the decoder imports
rt's memory and writes decoded frames into it. Metal has no counterpart, as it has none of
presenting.

The form is one on every device: an allocation of its own in the Private memory type,
dedicated to the one buffer that spans it (VkMemoryDedicatedAllocateInfo), exportable as the
handle the consumer names, never a range of a pooled allocation. Vulkan lets a driver require a
dedicated allocation for an export (VK_EXTERNAL_MEMORY_FEATURE_DEDICATED_ONLY_BIT), so the
dedicated form is the one every driver takes, and what exportable memory costs each submission
falls on these allocations alone.

- ExportHandle: OpaqueFd (unix), DmaBuf (unix), OpaqueWin32 (Windows). A handle is offered
  where the device lists its extensions and vkGetPhysicalDeviceExternalBufferProperties says its
  buffers export it; elsewhere Limit::NoExport, before anything is allocated.
- A dma-buf's other side is another driver, which an ownership transfer names as
  VK_QUEUE_FAMILY_FOREIGN_EXT; without VK_EXT_queue_family_foreign that family may not be named
  (VUID-VkBufferMemoryBarrier2-srcQueueFamilyIndex-09099), so a dma-buf export there is
  Limit::ExportType { listed: None }. A buffer whose memory requirements do not list the
  Private type is Limit::ExportType { listed: Some(bits) }.
- Export carries the new handle (the consumer's to close), the allocation's size and its memory
  type, which an import of an opaque handle names again
  (VUID-VkMemoryAllocateInfo-allocationSize-01742, and the dedicated import of
  VUID-VkMemoryDedicatedAllocateInfo-buffer-01879).
- The extensions stay out of the floor: VK_KHR_external_memory_win32 and
  VK_EXT_queue_family_foreign join the optional list, enabled where listed.
- Gauges::exports counts exported blocks whose memory is not yet freed; the block-maker thread
  frees them as it frees imports (memory::Own).
- No image is made in an exported block's memory, which is dedicated to its buffer
  (VUID-vkBindImageMemory-memory-10926): a texture over a buffer in it takes the counted copy,
  as over an import, and a heap texture in it is Gap::HeapTexture.

docs/REFUSALS.md regenerated; api_signatures blessed; the rt README has the call, its
extensions and its known gap.

Tests (src/tests/export.rs, device cfgs): every offered handle exports, is written by rt,
released by the test's own barrier and read back through a second device's import of the
handle, with the gauge back after the free; every other handle is refused typed; an exported
block holds no image; and the submit cost with 64 live exports against none, printed.

Verified at this commit: cargo fmt only. The lane's build (clippy plain and under both device
cfgs, Rustdoc, signatures, refusals) and device legs run on the tip that carries it.
2026-11-19 01:50:13 -08:00