Commit Graph
14 Commits
Author SHA1 Message Date
Anees Iqbal ab139e4b6e RUNTIME 2366: Runtime FALLBACK repro bundle at a creation refusal (default-off diagnostic)
What: metal2vulkan-runtime writes the FALLBACK repro bundle the command line
writes for its own failures when it refuses a library or pipeline creation,
where METAL2VULKAN_REPRO_DIR names a directory (unset, nothing is written).

- The CLI's bundle writer moves into the library as the hidden crate-root
  module metal2vulkan::repro (feature serde), shared by the binary and the
  runtime. A bundle's directory is named by its content
  (metal2vulkan-repro-<16 hex>), written under a temporary name and renamed,
  so an identical failure is written once, across threads, processes and
  runs. The CLI's own bundles keep their files (input, profile.json, the
  descriptor files, repro.sh, repro-command.txt, failure.txt); only the
  directory's name changed, so a bundle written before still replays.
- The CLI takes --device FILE in place of --profile: the JSON of a
  DeviceDescription and DevicePolicy (ReproDevice), which builds the
  runtime's own compile device.
- The runtime hooks each creation where its refusal returns: a library of a
  metallib, a function's lookup, every compute and tile state
  (ComputePipelineState/TileState::create_adding: creations, added binary
  functions, archive adds) and every render state
  (GraphicsState::create_reflecting). It bundles Unsupported, NotImplemented
  and Compile refusals but a cancelled compile and a name the library lacks
  (Metal's own nil); never Invalid/Nil/MetalError. The bundle holds the
  library's bytes, device.json, the request as the CLI's options and
  descriptor files, and failure.txt with the call, the refusal and what the
  command does not replay. That list comes from a full destructuring of the
  compute, tile and render descriptors (and the stage functions): a new
  descriptor field fails to compile in repro.rs until it is replayed or
  listed.
- Bounded: at most 32 bundles and 256 MiB per process; past either nothing
  more is written and one line says so. Written on the refusing thread; the
  call returns the same refusal; a write failure is said once. Each bundle
  is named in one line through the device's message sink (id name
  metal2vulkan-repro). The runtime's metal2vulkan dependency gains serde.
- Not bundled: mesh states (no CLI mesh path), a dispatch's or draw's later
  variant, driver VkPipeline makings, Metal-source libraries.

Docs: env_vars registry, README CLI, docs/HOWTO.md section 4, the runtime
README's Errors section, the CLI help.

Tests: runtime CPU tests of the bounds (a tally with the seam's limits);
a lavapipe/GPU device test (ob3_stage_input with no stage-input descriptor:
one bundle with the expected parts and command, device.json rebuilding the
runtime's compile device by profile fingerprint and answering the same
refusal, none for a second identical refusal or a missing name, none
without a directory); CLI tests replaying library-written runtime bundles
(compute, and render with a vertex descriptor) through repro.sh to the same
FALLBACK, and --device compiling what --profile does.

Verified at ae56b195e9 (msi, m3-max-32986): metal2vulkan cli,
api_surface and api_signatures 25 passed; runtime repro tests 9 passed;
clippy -p metal2vulkan -p metal2vulkan-runtime all targets, all features
0. Lavapipe (m3-max-32978): repro_device writes one bundle that the
CLI replays to the same refusal; a second identical refusal writes
nothing.
2026-11-15 10:14:52 -08:00
Anees Iqbal d6d695d951 Link the tests' and the tool's void vertex functions unrasterized, as Metal makes them
m3-max-5121 (the whole metal2vulkan suite at ffc6619794) failed eight tests
on the link's RasterizedVoidVertex refusal:

- five link tests (render.rs) replaced a vertex stage's io with one that
  writes no position; they now keep the position (positioned);
- engine_link's graphics-state test linked ob3_index_buffer, a void vertex
  function, rasterizing; it now links it with rasterization disabled, the
  one form Metal makes of it;
- the command line compiled a void vertex function with no fragment as a
  rasterizing pipeline (cli's ob3_vertex_input test): with no --fragment
  it now asks whether the vertex function returns a value and compiles a
  void one with rasterization disabled (README says so);
- the new link test ran on vk12-floor, whose vertex stage stores nothing,
  as the void function does; it runs on lavapipe's profile.

(cherry picked from commit 5da2f008274b04019121fe173adb98efa4f3ec26)
2026-11-07 14:02:59 -08:00
Anees Iqbal adef203530 Describe each driver deviation's route as the code takes it now
One work packet, landed as 10 commits (262093ec48..8e4bfa28b4 on archive/development-linear-2026-10-28), in order:

* Describe each driver deviation's route as the code takes it now

The DriverDeviation, VkProperty and driver-table docs still named the
exact emulations the native-arithmetic change sets deleted (Metal's
libm, division, denormal flushing, NaN selection, min/max picks, the
emulated sampler, the color, storage and Depth16 write roundings, the
depth stand-in). Each variant's doc now says what a profile that takes
it gets and what one without it gets: the device's own answer with the
precision note recorded, or, where a capability hangs on the answer, its
emulation or refusal.

- error/mod.rs: DriverDeviation's header and the float-function, NaN,
  sampler, color-write, FMA, denormal, quantize, min/max, half
  arithmetic, storage-write, texel-write and Depth16 variants.
- device/requirements.rs: the matching VkProperty docs; MetalColorWrites
  says no module requires it (compile.rs never adds it), and
  MetalHalfQuantize drops the clamp claim the code does not make.
- device/driver_facts.rs: the table preambles and measurement paragraphs
  (docs and citations only, no row or variant changed); the deleted
  resolve_rounding::color_resolves_against_metals_rules citation now
  names the_device_resolve_rounds_as_announced, which holds the row.
- runtime_lane/heap_textures.rs: heap_depth_textures_keep_their_bytes,
  renamed from ..._with_their_twins (no twin exists), with the two
  driver_facts.rs citations updated.
- lower/texture/mod.rs and pipeline/compile.rs: the storage_properties
  doc and comment list the four properties select_write relies on,
  dropping the 0x7fc00000 store.

Verified by reading each route in lower/ (narrow, fma, denormal, nan,
arith, sampler, stage_io/color_write, texture) and pipeline/compile.rs,
and by git grep for every cited test and item.

* Describe the pixel samplers, routines and color-write inputs as they run now

Translator docs that still described the deleted emulated sampler, the
cube face fold routine, the compiler-word-bound fit and the shader's own
color-write rounding:

- pipeline/artifact.rs: PixelSamplerScaling no longer names a linear
  sample's emulation or a MetalSampler condition; a runtime word's linear
  pixel sample snaps onto its footprint cell on every device
  (position::plan plans SnapKind::WordCell with no device test), a word of
  mixed filters is the device's. ArgumentPixelSamplerScaling says it is
  recorded on every device for any access but a 2D gather and a sample
  without a comparison, as select.rs pixel_note does.
- lower/sampler/select.rs (pixel_note) and lower/sampler/mod.rs
  (RuntimeSlot::cells, ::texels): the cell snap holds on every device; the
  slot's word filter fields are read for a half texel's conversion alone,
  on a MetalSampler device (half_converts requires !device_texels).
- device/profile.rs: FunctionsInlinedAtEveryCall lists the routines that
  exist (wide-integer divisions, precise fmod, texel conversions, filter
  sums, sampling routines; no face fold); takes_driver_deviation names the
  route a deviation's docs give for a driver without it.
- error/mod.rs: RuntimeInput::ColorWrites says what the color-write map
  decides (the conversion that records a note, and NearestEven's half
  rounding), not a rounding of every output.
- bind/color_resolve.rs and its tests: drop the citation of
  resolve_rounding's cost test, which is deleted.
- device/mechanism.rs: drop the trailing comment on the deleted
  ExactFormsOverCompilerLimit fact.

Verified by reading position::plan, select.rs pixel_note and the
half_converts branch, spirv/builder/module.rs's routine kinds and every
mb.routine site, pipeline/color_writes.rs, and git grep for each cited
item.

* Describe texel conversion, YCbCr filtering and depth comparison as the device's

Translator docs still named the deleted linear-filter emulation, the
shader's own depth comparison and the depth twin:

- lower/texture/half.rs: off MetalSampler devices the device's sampler
  filters and the half is its float texel rounded to nearest even
  (device_texels), not this routine's; the only fetch-computed filter that
  skips the routine is the in-place YCbCr one.
- lower/texture/mod.rs (half_texels): drop the example of a runtime
  sampler's sRGB raw-code emulation for the `arm` clauses.
- metal/format/mod.rs: a two-plane YCbCr texture's linear sample is the
  device's filter, noted, but where its planes are read in place.
- pipeline/artifact.rs (RestrictedDepthRange) and lower/texture/slot.rs
  (depth_comparison): every comparison is the device's; no shader-made
  comparison is left to exclude.
- lower/sampler/select.rs: a depth comparison reads the texture's own
  depth image (no twin).
- lower/sampler/mod.rs (Sampling::words): list the terms plain_words
  sums; no linear emulation, level grid or shader comparison term exists.

Verified by reading device_texels, half_texels and both its callers,
linear.rs filter_note and metal_filtered_ycbcr, depth_comparison's one
caller, in_place.rs, and plain_words.

* Describe the runtime's YCbCr filter notice and variant kinds as they fire now

- degradation.rs: YCbCrFilterNotExact fires on a device that samples
  through Metal's own sampler alone (linear.rs metal_filtered_ycbcr is
  None elsewhere), where the stage records HalfSampleFilter or
  FloatSampleFilter for any two-plane YCbCr format bound; a native sampler
  announces device-sampling. The module doc drops the exact forms dropped
  to fit a compiler word bound, whose kind and fit are deleted.
- ycbcr.rs: linear filtering of the converted texels is the device
  sampler's (Metal's own on MoltenVK, announced ycbcr-filter-not-exact);
  only planes read in place are Metal's filter exactly.

Verified by reading lower/sampler/linear.rs, in_place.rs and the runtime's
Kinds::of and degrade_bound_formats.

* Describe the lanes' and cases' native forms where they named deleted emulations

Docs and comments only; no expectation changed.

- validation runtime_lane/driver_deviations.rs: the half quantize,
  min/max, half arithmetic and half widening bullets say what the module
  does off the deviation (the device's own conversion or quantize, the
  same NMin/NMax/NClamp noted native-min-max, narrow::from_bits' decode),
  not the deleted integer rounding, operand picks and exact_answers
  decode.
- validation observation_contract/comparison.rs: HalfSampleFilter and
  FloatSampleFilter are a YCbCr texture through Metal's own sampler.
- validation runtime_lane/pixel_samplers.rs, conformance
  cases/pixel_samplers.rs: the pixel coordinates reach Metal's texels
  through the translator's snaps, filtered by the device's sampler.
- conformance cases/snorm_tile_store.rs: no exact tile store and no
  FAST-PATHS row; only extended-range, padded and bfloat attachments take
  a load pass.

Verified by reading the lanes' assertions, select.rs pixel_note,
position::plan and narrow.rs.

* State the native forms in the doc pages where they promised exact switches

- README.md: the promise that every speed-for-accuracy choice has an
  opt-in exact switch was false for the device's maths, rounding,
  conversions and sampler, which have none; it now says those are the
  device's, recorded, and the runtime's choices keep their switches.
- docs/API.md: exact_answers selects the runtime's five switches (as
  policy.rs's exact_answers sets them), not exact forms of the native
  arithmetic; an unmeasured driver takes each deviation's documented
  route, not a conservative one; half widening's NaN and denormal are the
  device's under its own conversion or the float controls; Depth32Float
  texels are the depth image's, announced where it clamps or flushes; the
  catalogue intro names the native forms.
- docs/ARCHITECTURE.md: the native forms are the device's on every device
  with no policy choice; the policy's accuracy switches are the runtime's.
- docs/FAST-PATHS.md (after the opening section): a YCbCr texture's image
  form holds Metal's texels exactly and its linear sample is the device's
  filter; only the in-place form is Metal's filter.

Verified against device/policy.rs, lower/arith/narrow.rs, the depth twin's
deletion (c11e653acd) and lower/sampler/linear.rs.

* Drop the exact golden table from VALIDATION.md's emitter-stability contract

4bf2c22aad deleted golden_hashes_exact.tsv and its table in
golden_hashes.rs; VALIDATION.md still described a second table of every
sampling fixture under exact_answers. The contract now names the one table.

Verified: crates/metal2vulkan/tests/ holds golden_hashes.tsv alone, and
golden_hashes.rs names no exact table.

* Re-pin the runtime sources after the doc audit

The audit's commits edit doc comments and comments only in files the
runtime guard hashes (degradation.rs, ycbcr.rs, and translator files the
build lists); no run's behaviour changes, so RUNTIME_VERSION stays.

Verified: the_runtime_sources_are_the_committed_ones failed with 81ebd500
committed against 8bc0e06b computed, and passes after this pin.

* Drop the 0x7fc00000 hand-off from half_write_nans_converted's doc

a6e97e7f93 deleted the NaN canonicalization before storage writes
(StorageImageClass::SmallFloatQuietNan among it): a half write to a
packed small float hands the device the half widened, as to a 16-bit
float channel. The doc still said such a write hands it 0x7fc00000, and
tied MetalHalfTexelWrites to both kinds, where it states the 16-bit
float store alone (lower/texture/mod.rs half_write_nans).

Verified by reading half_write_nans and the write emission
(lower/texture/emit.rs), which canonicalizes no small-float NaN.

* Re-pin the runtime sources after the half-write NaN doc fix

metal/format/mod.rs is a runtime guard input; the preceding commit edits a
doc comment there alone, so no run's behaviour changes and RUNTIME_VERSION
stays.

Verified: the_runtime_sources_are_the_committed_ones failed with 8bc0e06b
committed against 279b25d4 computed, and passes after this pin.
2026-10-28 17:24:21 +02:00
Anees Iqbal 48bf2286bd Take the test line back out of the README
Content: the tree of `development` at 2839e1fe31, unchanged.
2026-10-26 13:19:13 +02:00
Anees Iqbal 0cb3502553 Sweep every 32-bit integer vertex and attribute format, which needs an integer-declared attribute
The steps this packet landed as, in order:
- Name the store actions and resolve filters the pass sweeps already put to Metal
- Name the filter sweep's sites after the attachments' own filters, not the row's unrotated ones
- Read the function type of a mesh pipeline's own two stages
- Read the function type of a visible function, which is a callee rather than a stage
- Give the wide stage-in attribute its own entry point, so stage_in_fetch keeps its four
- Reflow the import lists the rebase resolution unioned

Content: the tree of `development` at be60af4862, unchanged.
2026-10-26 13:19:13 +02:00
Anees Iqbal 615be46647 Mark the README's library sketch as the uncompiled sketch it is
Content: the tree of `development` at 6a35eddd48, unchanged.
2026-10-26 13:19:08 +02:00
Anees Iqbal ea89d3f8ed Mark the project beta in the README
The README's status notice said alpha; the user moved the project to beta. The rest of the notice
(the API, command line, pipeline JSON and SPIR-V may change during 0.x) stands.
2026-10-17 06:44:08 +03:00
Anees Iqbal 0175289314 Batch the development-fast round: tessellation without tessellationShader, primitive ids, mesh tooling, color groups, the vk12 floor, runtime timing and teardown fixes
One commit of the 247 on development-fast (720ef1ce9a..9f46fdf80d), squashed at the user's request.

Translator:
- Tessellation on a device without tessellationShader: Metal's tessellator emitted as SPIR-V, a
  one-workgroup scan placing each patch's triangles in Metal's order, and the post-tessellation
  function as a plain vertex stage (EmulatedTessellationDraws; SEMANTICS 1739, ARTIFACT_FORMAT 419).
- [[primitive_id]] on a device without geometry or tessellation shaders, as a flat varying the
  vertex function writes; indexed lists, lines and points drawn de-indexed (RuntimeGap::PrimitiveIdIndices).
- Fragment functions of more colors than the device draws at once, compiled in color groups
  (PrecisionNote::ColorAttachmentGroups).
- Object functions' threadgroup memory from the render encoder; a kernel's mesh draws from an
  indirect command buffer; mesh payload sizing.
- The Vulkan 1.2 floor profile (vk12-floor) and the gates it needs; Metal 27.0.1 answers as the M3 Max.
- Overflow tests in the runtime-built modules by the product's high word (NVIDIA's compiler fails
  the division form), guarded crate-wide by tests::owned_divisions.

Runtime:
- Color-group passes replayed per group over twin depth/stencil; snapshot and copy-back cost cuts.
- Command buffers finish on the queue waiter that saw them; the waiter holds no device handle, so
  a program's drop after its wait is the device's last.
- Every object an encoder was handed held until its command buffer completes; deallocator order
  and announcements.
- Driver defects recorded and announced: ANV counts a visibility sample once per color output
  (visibility-count-per-color); MoltenVK fails pending work when memory that held a device-address
  buffer is freed, so freed memory waits for the work in flight (host-deallocator-delayed).
- RenderCommandEncoder::set_object_threadgroup_memory_length; Visibility::counting().

Validation: mesh tooling (object, mesh and ICB-mesh cases on both executors), the authoring
census closed, the queue storm judged in Metal's unit, load-robust exits and indirect-census
bounds, and the golden hashes, printouts, fixture inventory and authored compile census blessed.

Docs: FAST-PATHS.md trimmed to a ledger of what is true now; API.md's catalogue and accepted
differences, REFUSALS.md and METAL-COVERAGE.md current.

Verified on development-fast before the squash: the full suites on the RTX 5080, RTX 3090,
RX 7900 XTX, Radeon 780M, Iris Xe, lavapipe and the M3 (MoltenVK and the Metal oracle), lint in
every configuration, rustdoc, doc tests, packaging and public case qualification; the timing and
teardown lanes x5 on every venue; the authoring-capability census 16656/16656 with 0 unresolved,
the vk12-floor translation census at 6139 translated with the slowest row 794 ms and peak 126 MiB.
The tree is development-fast's at 9f46fdf80d.
2026-10-16 11:12:03 +03:00
Anees Iqbal 13b279df1b Squash 11203 commits of translator, runtime, and validation work
Rolls up everything since 43c46ac8 into a single commit. Its tree is
identical to the tree of private master at
b3c77f2d2b20a432be10591a2129547c10b1c24b.

- A Cargo workspace of five crates under crates/: metal2vulkan (the
  translator and the metal2vulkan command), metal2vulkan-runtime (the
  Metal API on Vulkan), metal2vulkan-air (the AIR front end),
  metal2vulkan-validation and metal2vulkan-devtools.
- Dual license: GPL-2.0-or-later OR LGPL-3.0-or-later.
- docs/: API, architecture, fast paths, how-to, Metal coverage,
  refusals, runtime porting and validation guides.

Private-Commit: b3c77f2d2b20a432be10591a2129547c10b1c24b
2026-10-11 20:09:13 +03:00
Anees Iqbal 08970cacd2 Consolidate translation, linkage, and validation work
Squash 147 commits (2026-08-20 through 2026-08-31) into one change on top
of the exact-kernel-grid work. Covers native lowering and pointer/layout
construction, AIR intrinsic and funnel-shift coverage, BDA address
preservation across aggregate calls, CFG structurization, function-constant
and visible-function specialization, the 30-second translation ceiling, the
authored-case corpus and linkage validation suite, and refreshed byte-exact
MoltenVK evidence.

The kernel-grid lowering in this tree supersedes the 324-line variant in
the parent commit; that file is reduced to its current 139-line form here.

Resulting tree is identical to 7174c7b. Prior history remains reachable at
tag pre-squash-backup and branch backup/pre-squash-7174c7b.

Claude-Session: https://claude.ai/code/session_01D1u4vU7Mr5QNWrnnRHC8iS
2026-08-31 09:03:42 +03:00
Anees Iqbal 9ff250502c Make exact kernel grids safe by default
Model kernel dispatch geometry as a typed contract shared by lowering, reflection, validation, and the CLI. Cull surplus dispatchThreads invocations using fixed or reflected push-constant grid bounds, make that safe dynamic-grid path the default, and require an explicit whole-workgroup assertion to omit it.

Reject unsafe source-barrier kernels before every product emission facade by following the selected AIR entry graph, including quoted LLVM symbols. Exercise the same default contract in authored candidate validation and document the host ABI.

Keep corpus audit parent concurrency bounded by feeding isolated translation workers from scratch-backed stdin files instead of creating one feeder thread per row. This removes the scoped-thread exhaustion that aborted late full censuses while retaining child decoding inside the time and memory watchdog.

Verified with format checking, warnings-denied workspace clippy and Rustdoc, validation tests at concurrency 16, the unchanged downstream repro, a forced 88,819-row audit completing in one invocation at jobs 16, failure retries, and a zero-read warm pass.
2026-08-22 02:16:13 +03:00
Anees Iqbal 8b78eaca3b Expand macOS 26 AIR translation coverage
Overhaul the validation workflow around sharded authored cases, dependency-exact observations, incremental indexed corpus audits, bounded parallel translation, and native Metal/Vulkan comparison.\n\nExpand native AIR lowering, reflection, linked-function specialization, resource and stage-interface support, and structural CFG/pointer repair across the harvested macOS 26 corpus. Add exact intrinsic inventory, distributed 16x16x16 matrix lowering, explicit opaque tensor linkage, and regression coverage for the newly supported feature classes.\n\nThe final corpus verification accounts for all 88,819 indexed AIR modules under the current product fingerprint: 65,355 translate and validate directly, 23,464 require exact authored linkage, and zero fail or remain unresolved.
2026-08-13 21:46:27 +02:00
Anees Iqbal 75d3d39d05 Document Apple trademark notice 2026-07-23 19:54:20 +03:00
Anees Iqbal 3007485352 🆕 Open Source metal2vulkan 2026-07-22 13:15:24 +03:00