Commit Graph
39 Commits
Author SHA1 Message Date
Anees Iqbal 4b564766ec Sample extended-range textures through Metal's bicubic filter
A sample of a BGR10_XR, BGRA10_XR or RGB10A8_2P_XR10 texture (or an sRGB twin) through a constexpr
bicubic sampler, or through a runtime sampler whose bound word states Cubic, was refused
(NotImplemented(SamplerBicubicFilter) in the lowering, NotImplemented(Format) in the binder). It is
now Metal's bicubic filter of the decoded texels, measured on an Apple M3 Max (macOS 26.7) through
the owned fixture xr_bicubic: random codes of each of the six formats at 16x16, 7x5, 3x3, 2x6 and
1x1, 2,304 coordinates each (every texel's centre, then random ones up to 0.15 of the texture past
its edges), through 12 kernels (a runtime Cubic sampler with float and half results; constexpr
samplers under clamp to edge with float and half results, repeat, mirrored repeat, clamp to zero,
the opaque-white and opaque-black borders, pixel coordinates, and an offset under clamp to edge and
repeat): 3,317,760 lanes.

What Metal does, and what the lowering now does: the footprint, weights, addressing, a mirrored
axis and a level below four texels are the other formats' bicubic filter's, each tap the decoded
texel or the border texel through the format's channels; a level below four texels sums as the
extended-range linear filter (terms truncated); otherwise each tap's step is weighed by the
product of Metal's weights and summed exactly (no term truncated, unlike the linear filter), the
step rounded half up, clamped into the steps of the codes 0 and 1023 (a color lane's (0-384)/510
and (1023-384)/510, an sRGB twin's table steps, alpha [0, 1]), and divided by the grid exactly; a
half result rounds as the linear filter's does. The clamp is applied to the rounded result, which
equals clamping the step because each rounding is monotonic. Every lane but 4,050 matches that
model; each of the 4,050 is one step from Metal's (1/8160 a color lane, 1/8192 an sRGB color lane,
1/4080 alpha), its exact sum within 0.014 of a step of a rounding tie that Metal rounds the other
way. No model of Metal's datapath tried closes that residue, so the sample records
PrecisionNote::BicubicFilterArithmetic, and docs/FAST-PATHS.md and docs/API.md say so. A bfloat or
padded form's bicubic sample, a swizzled texture's and a gather through a bicubic sampler were not
measured and are refused.

How: select_extended takes the bicubic state of a constexpr sampler or of the slot's cubic-sampler
variant (LoweringInputs::cubic_samplers) and plans Metal's bicubic filter; the extended sampler emits
it through bicubic::filter with Texels::Extended, which fetches each tap's raw texel and decodes it,
through the exact routines alone, then clamps. The binder takes a cubic word at an extended-range
slot as the cubic-sampler variant's, and gives such a slot the neutral BicubicTexels value in the
plan of the pipeline as compiled, which binds the neutral there (it refused the format before
naming the variant: the device lane found that). SEMANTICS_VERSION 1693; RUNTIME_VERSION 1184, as
a run of an existing artifact with a cubic sampler at an extended-range slot is no longer refused;
the runtime-sources hash re-pinned.

The table: xr_bicubic.tsv (2,067 samples of the probe's, per texture and kernel the middle
texel's centre, four random coordinates, the first sample with a lane at a clamp bound and the
first with a lane at a tie), shared through metal2vulkan_devtools::xr_bicubic with the probe's
texture generator.

Verified on homelab-gem10 (debug builds):
- tests::engine_extended_range::bicubic, on the CPU interpreter on the lavapipe and MoltenVK-M3
  profiles: every lane of the table through the same 12 kernels, compiled under the six forms'
  variants (the runtime ones under the cubic-sampler word the binder plans), is Metal's bits but
  the 136 lanes the table marks, each one step away; each compile validates and its estimate
  bounds it. A padded or bfloat form's bicubic sample, a swizzled texture's and a gather are
  refused as above (a two-plane gather as Format, under any sampler); on every committed profile
  the pipeline as compiled plans the variants with the XR texture and a Cubic sampler bound, and
  the variant's pipeline plans the same key.
- runtime_lane::extended_range_bicubic (new): the 8,268 lanes on the Radeon 780M (RADV), the RTX
  3090 and lavapipe, textures written as the probe wrote them: 0 differ from Metal (136 at a tie,
  one step away), and the state announces bicubic-filter-arithmetic. The extended_range_samples,
  two_plane_samples and two_plane_copies lanes, whose helpers this shares, pass on all three.
- Release build, 12 kernels x 6 forms x 5 profiles (lavapipe, 780M, RTX 5080 Laptop, Arc ANV,
  MoltenVK-M3): 360 translations, mean 1.31 ms, slowest 1.97 ms (xrb_runtime, BGRA10_XR sRGB,
  780M), budget ledger peak at most 935 KiB, process peak RSS 15.6 MB; the linear XR kernels
  take 0.81 ms on average.
- clippy -D warnings (workspace, all features, all targets; validation also under m2v_gpu),
  rustdoc -D warnings and the doctests pass. Suites: metal2vulkan, -air, -runtime and -devtools
  4,566 of 4,567, validation 1,293 of 1,293. The one failure is tests::golden_hashes, whose 380
  stale cells are the two new fixtures' alone (smw_writers 7 and xr_bicubic 12 entries x 20
  profiles), left to be blessed on development.
2026-10-13 17:04:18 +03:00
Anees Iqbal 61a2efc7d3 Fix the GPU test failures seen on the 3090, 5080, XTX, 780M and M3
What and why, per failure (all release, --cfg m2v_gpu):

AMD RADV, Ubuntu Mesa 26.0.8 (RX 7900 XTX, Radeon 780M):
- generated_executions faulted the GPU (amdgpu gfxhub page fault, ring
  reset): RADV before 26.2 skips re-emitting a compute pipeline it thinks
  is bound, so the second execution's implicit preprocess ran our kernel.
  New RuntimeDriverDefect::ImplicitPreprocessAfterExecutionSet (RADV at
  every identity but the measured clean 780M at 26.2.4): the runtime
  preprocesses every execution of a range explicitly, then a barrier, then
  runs them preprocessed. RUNTIME_VERSION 1183.
- The validation executor's generated-commands replay had the same fault;
  it now preprocesses apart on the same defect (runtime's
  generated_commands::preprocess_apart, now public).
- float_denormals under fast math: the test checked a / b, smoothstep and
  (a / b) * c bit for bit, but without VK_KHR_shader_fma (26.0.8) the fast
  reciprocal is the device's OpFDiv(1, y), within 2.5 ulp. Those words are
  now checked at Metal's edges there, in full elsewhere.

NVIDIA 615.71.09 (RTX 3090, RTX 5080 Laptop):
- render_commands_and_render_states_run_as_the_executor_compiles_them: the
  executor used Vulkan device addresses as Metal addresses, and NVIDIA's lie
  below 2^32, where a record's address names no buffer. An addressed
  allocation's guest address is now its device address read signed (RADV's
  are sign-extended) plus 2^47 + 2^32, one translation for every allocation.
- the_runtime_probe_measures_the_test_device_consistently: two driver
  answers Vulkan does not allow (3090: a buffer read after a linear-image
  copy over the same memory in one submission reads stale bytes; both: an
  explicit linear pitch the driver does not lay out is moved, not refused)
  are listed with their evidence in the test; the runtime records neither.
- exits (5 tests): vkDestroyDevice takes ~55 ms alone and up to 2 s beside
  other processes' GPU work on the 3090, so the exit-timing tests run alone
  (.config/nextest.toml); the 1.5 s limit is unchanged.
- pipeline_records (5080): the test assumed the driver finds a pipeline only
  in byte-identical records, but NVIDIA's bytes vary per compile and the two
  formats share entry keys. It now copies a compute pipeline's record over
  the render state's records, which no driver can hit.
- compile_worker (5080, under load): a worker faster than the 1 ms sampler
  left no peak RSS. Each worker now reports its own peak (VmHWM on Linux,
  ru_maxrss on macOS) and the parent takes the larger.
- tests::completion (both, under load): slow rounds were the GPU starting
  late behind another process's ~200 ms busy kernel, or NVIDIA's
  vkQueueSubmit returning up to 64 ms late; the completion was seen within
  1 ms of the moment it could be. A command buffer is now judged from the
  later of its GPU end and its submission's return where the device
  calibrates timestamps (from the commit elsewhere, as before).
- first_use::new_resources_wait_for_no_gpu_work (both, under load): the
  busy kernel's rate came from one wall-clock run, which collapsed under
  load (3 of 28 calibrations), so the busy work lasted milliseconds. The
  rate is now the fastest of every run at every size by GPU time, for all
  four lanes that share it (gpu_times::read_kinds predicts the notice a GPU
  time read emits, for the neutrals test).

Apple M3 Max, MoltenVK 1.4.1:
- heap_textures allows the shadowed-texture route for depth on drivers that
  lay heap depth textures apart.
- The argument-buffer intersection-table test states Metal's own metadata.
- The indirect lane classifies the deferred pipeline-making failure as
  compile-failed alike and keeps only the failed pipeline's error; Apple's
  33-bit closed-form compiler crash is a known gap in docs/FAST-PATHS.md.

Docs: CONTRIBUTING.md and docs/VALIDATION.md say the golden tables and the
compile census are re-blessed on development.

ENGINE_EXECUTOR_ABI is vulkan-engine-v181 (the RADV replay and the Metal
addresses change what the executor submits): every recorded candidate row
and the authored compile census go stale and need re-recording
(scripts/rerecord-venue per venue, rerecord-commit, corpus-status --c3,
corpus-triage --audit authored-compile --bless).

Still open: M3 frees_in_flight, XTX bfloat clears, 780M half NaN blur and
the 5080's one 2 s rebind_bytes_no_copy did not reproduce; the wall-clock
busy calibrations of framebuffer_fetch/storage_forms.rs and queue_storms
remain.

Verified:
- um780 full suites at the AMD fixes (before the executor and NVIDIA
  commits): XTX 3535/3535, 780M 3535/3535, no amdgpu kernel lines.
- Each fix's focused tests before and after on its GPUs (in the agents'
  commits: e.g. generated/indirect 178/178 on XTX and 780M at 26.0.8 and
  26.2.4; candidate 229/229 on 3090, 780M and Iris Xe; the worker peak 0
  of 1440 under 24-way load on the 5080).
- The combined tip: fmt, clippy (with and without --cfg m2v_gpu) and
  rustdoc on ms01; clippy of the validation crate on macOS; a focused run
  on the 3090 was stopped at 333 of 334 passed, none failed. No full suite
  ran on the combined tip.
- The completion and first_use fixes: 3090 load set 1 of 4 runs failed
  before, 4 of 4 passed after (completion) and 12 runs with no first_use
  failure (84 calibrations, 10.19M-11.24M loads); 5080 6 of 6 and 12 of
  12. fmt and clippy (no cfg, m2v_gpu, m2v_cpu_icd) on ms01.
2026-10-13 01:15:18 +03:00
Anees Iqbal ecb80e019d Place heap textures needing up to 256 KiB alignment instead of refusing them
A heap's memory started at a multiple of 64 KiB of the runtime's block, and a
heap texture whose image needed a coarser alignment was refused
NotImplemented(HeapTextureAlignment), by heapTextureSizeAndAlign and
newTexture alike. On an RX 7900 XTX that refused nearly every depth texture a
program puts in a heap: four runtime-lane tests failed there on every run,
each with `alignment: 131072`, while the Radeon 780M in the same machine,
under the same driver, passed them.

Measured with a raw Vulkan probe on homelab-um780 (vkGetImageMemoryRequirements,
optimal tiling, attachment|sampled|transfer usage, 11 formats, sides 1 to
16384, 1/2/4/8 samples, one level or full mips), RADV under Mesa 26.0.8:
- RX 7900 XTX: 128 KiB for D16, D32F and D32FS8 images of 8 x 8 texels or
  more; 256 KiB for multisample depth, stencil and color images from about
  128 x 128 texels; single-sample color, storage and BC1 images at most
  64 KiB. Nothing past 256 KiB.
- Radeon 780M: at most 64 KiB for every shape.

The base is now 256 KiB (HEAP_BASE_ALIGNMENT), the largest alignment measured.
The check moves into check_heap_base, which a GPU-free test can reach, and the
typed refusal stays for anything past the base. A heap over host pages
already starts at offset 0 of its own import, which meets any alignment.

Whole units of the base would have pushed the largest heaps past one
allocation: heap_size admits a heap up to maxMemoryAllocationSize in whole
16 KiB, and where that limit is no whole number of 256 KiB the largest heaps
asked more than the device allocates. RADV (4 GiB less 4 bytes) asked a 4 GiB
allocation for every heap from 4 GiB less 240 KiB, with a block's buffer of
addresses past maxBufferSize; MoltenVK (41,747,087,360 on the M3 Max,
9,534,832,640 on the M4, multiples of 128 KiB but not 256 KiB) would have
asked 128 KiB past the limit for its largest 128 KiB of sizes. So a buffer
past half a pooled block (32 MiB) now keeps its own size (buffer.rs's
`placed`). Such a buffer always takes a block of its own, where nothing
follows it; whole units exist only so the next placement in a pooled block
starts where the last ends. Buffers up to half a block still take whole
units, and half a block is a whole number of 256 KiB.

Cost: a heap of up to 32 MiB now starts at a multiple of 256 KiB of its pooled
block and takes whole 256 KiB units of it, up from 64 KiB units, so a small
heap can hold up to 240 KiB more of its block, on every device. A heap or
buffer past 32 MiB takes exactly its size, no longer rounded up. Programs see
no change where their images need 64 KiB or less. On the 7900 XTX the shapes
past 64 KiB now answer 128 or 256 KiB, are placed, and announce
heap-texture-larger-than-metal.

RUNTIME_VERSION 1179 -> 1181: heapTextureSizeAndAlign and newTexture answer
and refuse differently on such devices, heap buffers lie at other offsets in
the runtime's blocks, and every buffer and heap past half a pooled block
allocates its own size (WorkCounts::device_memory_allocated answers it).
runtime-sources.sha256 is re-pinned. docs/REFUSALS.md is regenerated, and the
reach mark's text says 256 KiB.

Tests:
- tests::heap::every_image_alignment_measured_fits_a_heap_s_base (GPU-free):
  the measured alignments fit the base, and one past it is refused typed.
  With the constant back at 64 KiB it fails (Err(NotImplemented(
  HeapTextureAlignment { alignment: 131072 }))).
- tests::heap::the_largest_heap_asks_one_allocation_of_its_device (GPU-free):
  every committed profile's largest heap asks at most one allocation and one
  buffer. With `placed` rounding every size it fails on amd-780m-radv
  (4,294,950,912 bytes asking 4294967296).
- runtime_lane::heaps::the_largest_heap_lies_in_one_allocation: where the
  largest heap is at most 4 GiB, making it grows the runtime's memory by at
  least its size and at most one allocation, with no validation message.
  Without the size fix it failed on the 7900 XTX ("the largest heap,
  4294950912 bytes, took 4294967296 bytes, past one allocation of
  4294967292"). It reserves the memory without touching it: on Iris Xe a 4 GiB
  heap took 0.04 s and a 53 MiB peak RSS; on lavapipe (debug) a 2 GiB heap
  took 127 MiB.

Verified (release, --cfg m2v_gpu, one GPU pinned):
- The heap set (`test(/heap/) | test(/rebind/) | test(/no_copy/) |
  test(/alias/)`, metal2vulkan-validation and metal2vulkan-runtime), before ->
  after: RX 7900 XTX (RADV, Mesa 26.0.8) 176/180 -> 183/183 (the four
  refusals pass); Radeon 780M (same host and Mesa), RTX 3090 and RTX 5080
  Laptop (NVIDIA 615.71.09) and Iris Xe RPL-P (ANV, Mesa 26.2.4) 180/180 ->
  183/183; lavapipe (--cfg m2v_cpu_icd, debug) 134/134. No kernel GPU
  messages.
- Apple M3 Max (MoltenVK 1.4.1): the heap set plus `test(/buffer/)`. Every
  failure fails identically at the base: heap_textures_answer_and_place_as_
  metal_s_do, argument_buffer_intersection_table_is_encoded_at_reflected_field,
  frees_while_the_gpu_is_busy_fail_no_command_buffer and
  every_case_of_buffers_alone_runs_from_a_command_as_its_dispatch_2.
- Full GPU suites: RX 7900 XTX 3528/3531 and RTX 3090 3526/3531. Every
  failure fails at the base or passes on rerun: on the XTX,
  float_denormals_read_as_metal_reads_them and the two generated_executions
  tests, which fail on the 780M too; on the 3090,
  render_commands_and_render_states_run_as_the_executor_compiles_them and
  the_runtime_probe_measures_the_test_device_consistently fail at the base,
  and three timing tests pass on rerun.
- On the 7900 XTX, the heap lane's output shows answers and placements at
  0x20000 and 0x40000 alignment and no HeapTextureAlignment.
- The runtime crate's GPU-free suite: 856/856. Clippy (workspace, all
  targets, all features, and --cfg m2v_gpu) and rustdoc are clean,
  refusal_surface.py --check passes, and the runtime-sources guard passes.
2026-10-12 20:57:59 +03:00
Anees Iqbal 11715e2a3f Import no-copy memory a driver refuses from the caller's dma-bufs
RADV imports host pointers through amdgpu userptr with ANONONLY, so it
refuses MAP_SHARED memfd pages (QEMU's memory-backend-memfd guest RAM and
views of it): every no-copy buffer, heap and rebind over them was refused,
and a macOS guest could not boot on AMD. NVIDIA imports the same pages.

What:
- The five no-copy entry points (new_buffer_with_bytes_no_copy, both
  new_heap_with_bytes_no_copy calls, Buffer and Heap rebind_bytes_no_copy)
  take a HostMemory; HostMemory::with_dma_buf adds a retained DmaBufSource.
- Where the pointer import is refused, and only there, on any device that
  lists VK_KHR_external_memory_fd and VK_EXT_external_memory_dma_buf, the
  runtime asks the source for dma-bufs of the window's pages (chunks cut at
  the device's sparse granule, sized by the caller within udmabuf's default
  limits) and binds one buffer over them: plain for one chunk, sparse for
  several (vkQueueBindSparse signalling queue 0's timeline; later work waits
  on it, no host wait). Every path that imported before is unchanged.
- Textures over such pages get a dedicated DRM_FORMAT_MOD_LINEAR image import
  of their own pages where the driver takes the plane offset and row pitch
  (multiples of 256 on RADV), with 64-bit modifier features; elsewhere, or on
  a source error, the existing shadow path.
- The extensions are enabled outside the compile profile: no device's enable
  set, fingerprint or ARTIFACT_FORMAT_VERSION changes. The translator crate is
  unchanged.
- Imports free inside exit-guard sections; the source is never called with a
  runtime lock held. WorkCounts gains dma_buf_imports, dma_buf_sparse_buffers,
  dma_buf_images and dma_buf_image_fallbacks.

Verified:
- Product suites 4553/4553, validation suite 1289/1289, clippy in every
  configuration, rustdoc -D warnings, scripts/api-docs.
- runtime_lane::dma_buf_imports and rebinds on RADV Mesa 26.2.4 (validation
  layer clean), the RTX 3090 and lavapipe (pointer imported, source never
  called), and dma_buf_imports on RADV Mesa 26.0.8.
- reims-vgpu on the Radeon 780M (RADV 26.0.8, udmabuf at its defaults): a
  macOS 26 guest cold-boots to the desktop and runs Safari; 5,119 dma-buf
  requests, none refused.
- 64 MiB on RADV 26.2.4, release: pointer import 187 us; one chunk 665 us;
  16 chunks 16.9 ms, about half of it the refused pointer attempt. The old
  host-fence bind waited 1.26 s behind queue-0 work on RADV 26.0.8.
2026-10-12 11:33:41 +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 43c46ac8a2 Squash 680 commits of translator, validation, and corpus work
Rolls up everything since 9e0e99a4 into a single commit:

- src/native, src/passes, src/reflect, src/meta: AIR intrinsic lowering,
  access-chain and pointer handling, constant/composite dedup, storage
  and descriptor-slot fixes, function-constant folding.
- validation/: Metal and MoltenVK oracles, triage, observation contract,
  and the case runner.
- validation/corpus and fixtures: new authored cases and re-recorded
  candidate observations at the shipping fingerprint.
- tests/: module-level oracles for reflection, NonWritable, gated
  varyings/system values/descriptor slots, loop budget, and fallback.
2026-09-06 23:58:13 +03:00
Anees Iqbal 9e0e99a41d Report only the constexpr samplers the module binds
`StaticSampler` is a descriptor translation invents. Nothing in Metal's API puts
one there, so the only reason a consumer creates a `VkSampler` at that binding
is that this reflection asked for one.

Reflection named one per `!air.sampler_states` entry -- every constexpr sampler
state the source wrote -- and the interface pass gives each the same binding in
the same order. But a state no sample reads leaves a variable nothing
references, and the module drops it, so reflection went on describing a sampler
that is not there. Over the 2880-source sample: 112 such bindings in 60 modules.

`StaticSampler` was the last translator-invented kind still reported without the
module's agreement; `reconcile_buffer_address_table` and
`report_synthesized_placeholders` already close the same gap for the other
three. Sweeping all four kinds over the sample now finds none.

Nothing moves. The interface pass allocates a binding per global before the
unused ones are dropped, so the states that survive are still on the bindings
that carry them -- confirmed by a reflection A/B over the sample, where 60
modules lose exactly those 112 entries, nothing is added, and no other field of
any binding changes.

The new fixture is three constexpr samplers with two samples, which reports a
ghost at binding 161 on HEAD~. `assert_invented_descriptors_are_declared` now
runs over every public fixture as well: it is the direction
`assert_reflection_covers_declarations` does not check, and for a resource the
translator invented the module is the only thing that can say a consumer has to
bind it. `REFLECTION_VERSION` is now 41.
2026-09-01 07:04:21 +03:00
Anees Iqbal 35f8b8bfce Bind a fixed texture array at the length AIR declares
`array<texture2d<half, sample>, 32>` states its length twice -- in the type
name and as the second `air.location_index` operand -- and the decoded
`TextureShape` already carried it. The interface pass still emitted
`OpTypeArray` of 128 and reflection still reported `count: 128` for every
handle array, fixed or runtime, so one `ResourceBinding` contradicted itself:
`texture_shape.array_length` said 8 while `descriptor.count` said 128, and a
consumer following the reflection had to supply 128 valid descriptors (or
`descriptorBindingPartiallyBound`) for an array of 8.

Both sides now derive from `TextureShape::descriptor_count`, the only reader of
the capacity constant. Only a runtime `array_ref`, whose length is a function
constant rather than part of the type name, still reports it. 40 of 14579 local
corpus sources declare a fixed array, lengths 2, 3, 4, 8, 32 and 80; every one
of the 76 declarations agrees with its `air.location_index` count operand.

The same unification fixes a depth-texture array bound as a single image. The
interface pass asked `contains("array<texture")` while the shared type-name
decoder asked about `array<depth` too, so `array<depth2d<float, sample>, 2>`
was not recognised as a handle array at all: the module declared one `depth2d`
where the shader indexes two, while reflection reported a `TextureArray` of 128
at that binding. There is now one predicate, `TextureShape::array_ref`, and one
scan behind it -- "is this an array" and "how long is it" can no longer be
answered by two different rules.

`tests/reflection_covers_declared_bindings.rs` now requires the reported count
to EQUAL the array the module declares rather than merely cover it, which is
what makes over-reporting detectable; the runtime fixture cannot catch it,
since its declared capacity IS the ceiling. Two fixed fixtures are added, one
of them spelled over `depth2d`, because a handle-array test that only ever says
`texture` cannot tell whether the emitter recognised the depth spelling.
Reverting either half of the fix fails them.

A/B over the 2880-source sample: 0 status changes; 8 modules change, each only
an `OpTypeArray` length 128 -> 2/8/32/80 and the ids that renumber behind it.
`REFLECTION_VERSION` is now 40.
2026-09-01 06:10:04 +03:00
Anees Iqbal 798b526fa7 Report the threadgroup ceiling this translator enforces
Translation refuses a `kernel_local_size` whose product exceeds the entry's
`[[max_total_threads_per_threadgroup(N)]]`. A bound a consumer has no way to
read leaves it guessing at the dispatch shape until it hits the refusal, so
`ShaderReflection` now reports `max_work_group_size`.

Reflection reports it and does not enforce it: discovering the bound is the
reason to call it, and refusing the call that asks would be circular. The
authored test drives both halves off the one declaration -- it reads the ceiling
out of reflection, then dispatches exactly that many threads and one more --
so the number reported and the number enforced cannot drift apart. A kernel that
declares no ceiling reports `None` and bounds nothing.

`REFLECTION_VERSION` is now 39; `docs/REFLECTION.md` documents the field.

Verified: `cargo fmt --all --check`, `cargo clippy --workspace --all-targets -D
warnings`, warnings-denied all-features Rustdoc, `cargo test -p metal2vulkan` in
debug and release, `cargo test -p metal2vulkan-validation`. Dropping the field
back to `None` fails the new test and no other. A/B against the previous commit
over 2880 corpus sources: 0 status changes and 0 SPIR-V byte changes.
2026-09-01 05:50:57 +03:00
Anees Iqbal 49fdfa0d65 Ask the emitter whether a kernel needs its address table
Whether a module carries a buffer-address table is a property of the pointer
graph the emitter constructs, and the emitter decides it with
`requires_device_address_model` over the parsed source. Metadata-only reflection
has to answer the same question, and answered it separately: a scan of the AIR
text for lines beginning `inttoptr` or `load ptr addrspace(1)`.

Two derivations of one fact, and the second was much the worse. Over 2880 corpus
sources the scan disagrees with the finished module 63 times. 49 of those report
a binding no module declares, which costs a consumer a descriptor slot. The
other 13 report none for a module that does declare one, which costs a consumer
a binding the shader reads -- and the scan cannot be fixed into seeing them,
because they are modules with no device pointer written anywhere in the AIR at
all: the address model is chosen for them during construction.

Asking the emitter's predicate leaves 8 disagreements, four in each direction,
and the remainder are the same kind -- decisions made after the pointer graph is
parsed. It costs a parse: metadata-only reflection goes from about 1.6 ms to
about 13 ms per shader, against 39 ms to translate one, so the path stays the
cheap one it is there to be.

The authored case for this was previously a bare `inttoptr` with nothing reading
it. That is precisely what the scan over-reports, so it now loads through the
pointer, and its dead twin is pinned beside it as the case that must report no
table. A second case loads a device pointer out of a struct member, which no
line-prefix scan can see and the pointer graph reads directly.

No module's SPIR-V changes and reflected translation is untouched, since it reads
the table off the module either way. `REFLECTION_VERSION` is 38.
2026-09-01 04:33:22 +03:00
Anees Iqbal eebedc3994 Size a buffer member AIR names but never describes
`air.struct_type_info` gives each member an offset, a byte size, an array
length, and a type name. When the member is a user struct or class the name is
all the metadata says about its interior -- `Espresso::padding_params_t`,
`VFX_RE_C_LightSpot`, `vfx_light::(unnamed)` -- and there is no nested node to
recurse into. The decoder answered `float` for every one of those, which states
a type AIR never stated and sizes the member at four bytes no matter what it
declared. Over 2880 corpus sources 2513 such members appear across 817 modules,
and 2357 of them declare a size other than four; the largest understates a
408-byte member by 404.

`AirType::Opaque { size }` makes the case representable, so the decoder can say
what AIR said and nothing more. Every consumer that needs a concrete type still
gets one -- the same size-derived storage shape that argument-buffer handles and
non-strict nested structs already use -- but the two consumers that need the
truth now get it. `air_metadata_extent` bounds a decoded layout against
`air.arg_type_size`, so understating a member let a layout that over-runs its
argument pass the check; with true sizes every corpus layout still fits, which
is the corroboration the old numbers could not give. And the emitter's member
matcher no longer demands a shape the metadata never stated: an emitted member
occupying exactly the declared bytes is the member AIR meant, where a float leaf
matched nothing and threw away the declared offsets for the entire buffer.

Making the variant explicit also forces the question at every site: four
exhaustive matches on `AirType` had to decide, rather than silently inheriting
`float`. Over the corpus no module changes status and no module's SPIR-V changes
by a byte. `REFLECTION_VERSION` is now 37 because reflected `type_layout`
reports the new variant.
2026-09-01 03:30:49 +03:00
Anees Iqbal dd04f204e1 Report an argument-buffer handle at the size it occupies
Metal spells a resource-handle member of an argument buffer with the type it
points AT -- `char` for a `device char *`, `float4x3` for a `device float4x3 *`,
`texture2d<half, sample>` for a texture, an opaque class name for a
`device Foo *` -- while the member itself stores an eight-byte handle. Reading
that name as the member's storage put a 64-byte matrix where the buffer holds an
address, and shifted the meaning of every member after it. `MTLGenericBVHData`
reported a 120-byte member layout for its 72-byte argument, with eight of its
nine members mistyped.

The member's `air.indirect_argument` node already says which it is, and nothing
read it: `air.indirect_constant` is the one role that means "stored inline";
`air.buffer`, `air.texture`, `air.sampler`, `air.indirect_buffer`, and the
pipeline-state / command-buffer roles are all references. `parse_struct_info`
walked past that suffix to find the next member; it now binds it to the member it
trails, exactly as `embedded::embedded_argument_members` does, and lets the role
decide. An unrecognized role is treated as a reference, since the declared size
describes the bytes either way while a handle mistaken for its pointee corrupts
the rest of the layout.

Over 2880 corpus sources the split is clean: 63,137 members carry no suffix or an
`air.indirect_constant` one and every single one of them agrees with its name;
2,762 carry a resource role and every single one of them declares eight bytes.
1,736 of those were mis-sized before -- 795 named a primitive of the wrong width
across 9 type names, 941 named a type AIR never defines, which silently became a
four-byte float.

This is not only a reporting fix. Twenty-one modules' SPIR-V changes, because
`infer_metadata_buffer_pointees` types a buffer from the same reconstruction:
they declared four-byte floats at eight-byte member offsets and now declare the
addresses AIR does. No corpus source changes status, and spirv-val is clean over
all 2880.

Reflection schema v36.
2026-09-01 01:00:13 +03:00
Anees Iqbal 8f9b185908 Report the access a buffer's descriptor is actually used with
`ResourceAccess` is what a consumer reads to decide whether a buffer's contents
have to be staged, whether results have to be read back, and which barriers the
resource needs. It came from AIR metadata, tightened by the specialized entry's
parameter attributes -- neither of which is the module. AIR's declared access is
not a guarantee about the body: over 2880 corpus sources, 20 buffers reflected
`ReadOnly` are stored through, 9 reflected `WriteOnly` are loaded from, and 3
reflected `Unused` are both. `ReadOnly` on a buffer the shader writes is not a
lost optimization; it is a missing barrier, and a write into memory a consumer may
have placed as read-only.

The footprint analyzer already resolves each load and store to the descriptor it
belongs to -- through access chains, copies, phis, and function parameters -- so
the direction is one more field on the access it already collects, not a second
walk. `MemoryAccess` gains it, `analyze` returns the per-descriptor union
alongside the footprints, and `attach_buffer_footprints` widens the reported
access to cover it.

It only ever widens. The walk follows the pointer graph it can attribute, so
finding no write is not proof there is none -- an access through a device address
it cannot attribute would be missed -- and narrowing on that basis would turn a
conservative answer into a wrong one.

`OpCopyMemory` needed the direction to belong to the access rather than the
instruction: it has a reading pointer and a writing one. Atomics are classified
read-modify-write, which is conservative for the two that only read.

Verified over 2880 corpus sources: SPIR-V bytes identical, failure count unchanged
at 204, and 34 modules' reflection changed -- the 32 the access sweep named plus
two the sweep's per-class conditions did not separate. The sweep now reports 0.

New `tests/reflection_access_covers_the_module.rs`: an authored kernel that
contradicts both of its declared accesses -- `air.read` stored through, `air.write`
loaded from -- plus the same check over every public fixture. Verified as a
detector: dropping the widening fails the fixture test.

`REFLECTION_VERSION` 34 -> 35, `docs/REFLECTION.md` follows, and
`reflect_sanitized`'s doc comment now lists all three per-binding fields that are
the declaration rather than the module when no module is built.

Gate: fmt, clippy -D warnings, warnings-denied all-features rustdoc, cargo test
-p metal2vulkan (debug and release), cargo test -p metal2vulkan-validation.
2026-09-01 00:34:11 +03:00
Anees Iqbal ff227d77ea Check the descriptor count a consumer is told to allocate
`docs/REFLECTION.md` tells a consumer to group reflected entries by
`(set, binding, descriptor type)` and take the largest `count`. That number is
what sizes `VkDescriptorSetLayoutBinding::descriptorCount`, so if it does not
reach the largest array the module declares at that binding, the layout is smaller
than the array the shader indexes into. The rule was documented and untested.

`assert_counts_cover_declared_arrays` reads the largest `OpTypeArray` behind each
decorated binding out of the module and requires the grouped maximum to cover it.
An authored `array_ref<texture2d<float, sample>>` kernel is the case with a real
array -- it declares the descriptor-ABI capacity, 128 -- and the fixture sweep
runs the same check. Verified as a detector: reporting one fewer descriptor for a
`TextureArray` fails both.

Measured over 2880 corpus sources first, since a test that only ever passes is not
evidence: 0 bindings where the module's array outruns the grouped maximum. The
naive comparison -- each entry's own `count` against the module -- reports 193
across the function-constant-gated modules, where one binding legitimately carries
both a scalar and a 128-element variable and reflection reports an entry for each.
That is the case the grouping rule exists for.

The same sweep compared `local_size` against `OpExecutionMode LocalSize`: 0
disagreements over 2880 sources, so no check was needed there.

No product change.

Gate: fmt, clippy -D warnings, warnings-denied all-features rustdoc, cargo test
-p metal2vulkan (debug and release), cargo test -p metal2vulkan-validation.
2026-09-01 00:23:01 +03:00
Anees Iqbal 9d629a3e9f Reflect the image the module binds, not the one the type name implies
`ShaderReflection::texture_shape` is what a consumer feeds into
`VkImageViewCreateInfo`, and Vulkan requires the created view's type to match the
`Dim` and `Arrayed` of the image variable the descriptor is read through. The
shape was decoded from the AIR type name, and the emitter does not always bind the
image that name implies: SPIR-V has no cube texel fetch, so `resources::discovery`
binds a `texturecube` that is only ever texel-read as a `Dim2D` ARRAY image with
the face in the layer slot. Reflection kept saying `Cube`, so a consumer following
it created a `VK_IMAGE_VIEW_TYPE_CUBE` view for a 2D-array image variable and the
dispatch was invalid.

`reconcile_texture_shapes` corrects each shape from the module's own `OpTypeImage`
at that binding, the same way `reconcile_buffer_address_table` and
`report_synthesized_placeholders` read their facts off the finished module.
`array_ref` and `array_length` describe the descriptor array rather than the
image, so they stay with the metadata that decides the descriptor count.

A binding is only corrected when its image variables all declare the SAME image
type. A function-constant-gated `air.location_index` puts several
differently-shaped variables on one binding -- 67 corpus modules do -- and there
the module has no single answer to read: the consumer picks one by choosing its
function constants. `reflect_sanitized` builds no module and keeps the
type-name-derived shape; its doc comment already listed what it approximates.

`TextureFormat::from_spirv_format` inverts the existing `to_spirv_format` over a
new `TextureFormat::ALL`, with a round-trip test that also proves the mapping is
injective -- otherwise the inverse would not be single-valued.

Measured over 2880 corpus sources by comparing every reflected shape against the
`OpTypeImage` behind its binding: 2 modules disagreed, both cube textures
reflected as `Cube` while the module declares 2D arrayed; 0 after. SPIR-V bytes
identical and the failure count unchanged at 204; exactly those 2 modules' -- and,
from the version bump, every module's -- reflection changed.

New `tests/reflection_describes_the_image_it_binds.rs`. The cube fixture binds one
AIR type name, `texturecube<float, ...>`, as two different emitted images: the
texel-read source as a 2D array, the written destination as a cube. Verified as a
detector -- with the reconcile removed it fails. A second authored kernel covers
four shapes across dimensionality, component class, and storage format, and
asserts they stay four distinct shapes so a decoder that widened them all could
not pass by moving both sides together. Only one public fixture binds a texture,
which is why the grammar probe carries the coverage; the fixture sweep is there
for when that changes.

`REFLECTION_VERSION` 33 -> 34: a cached v33 shape can name a view type the module
rejects. `docs/REFLECTION.md` follows.

Gate: fmt, clippy -D warnings, warnings-denied all-features rustdoc, cargo test
-p metal2vulkan (debug and release), cargo test -p metal2vulkan-validation.
2026-08-31 23:54:56 +03:00
Anees Iqbal e195fce0be Report the descriptors only the translator knows about
Two passes bind a real resource with no Metal argument behind it, so an AIR value
has a legal SPIR-V type: `air.get_null_texture_*()` gets an `OpTypeImage`,
`air.get_read_sampler()` gets an `OpTypeSampler`. The parent commit retracts those
whose value nothing consumes. One that IS consumed stays -- and nothing in the AIR
metadata describes it, so a consumer building its `VkDescriptorSetLayout` from
`ShaderReflection` produced a layout the module reads outside of.

This was the last of the module-vs-reflection descriptor mismatches. Over 2880
corpus sources the count is now 0, down from 267 when the oracle was first run.

`ResourceKind::SynthesizedNullTexture` and `ResourceKind::SynthesizedReadSampler`
report them. Which placeholders survive is a fact only the passes hold, so
`transform` now returns it -- `Transformed` replaces the `(Module, EmitSidecar)`
tuple -- and `finish_module` narrows the list to what the finished module still
declares, since the steps after `transform` delete instructions and the liveness
pass there can take a variable with them. Reflection reads each placeholder's
class from the module's own `OpTypeImage`/`OpTypeSampler`, and a null texture's
`texture_shape` off that image's operands, so nothing is inferred from binding
numbers. That mirrors `reconcile_buffer_address_table`, which closed the same kind
of gap for the address table.

`validate_descriptor_abi` constrains a placeholder to its ABI band rather than to
a recomputed `base + index`: it takes the first binding in the band no Metal
argument claims, so there is no index to recompute from.

Validation: `unsupported_reflection_requirements` marks a reflection carrying a
placeholder with the new `ToolingRequirement::SynthesizedPlaceholderDescriptor`.
The Vulkan executor has no authored resource to write at a descriptor no Metal
argument produces, and the Metal oracle has nothing to encode, so the row is
honestly not executable until the harness can supply a deterministic placeholder
resource. It is not claimed as supported without execution evidence. Before this,
such a row built a layout that omitted a binding the shader reads, so it was
already failing rather than silently passing. The exhaustive `ResourceKind` match
in `executor_contract.rs` is what forced the decision; that is what it is for.

`reflect_sanitized` builds no module and therefore reports neither placeholder;
its doc comment now says so alongside the address-table approximation it already
documented.

`REFLECTION_VERSION` 32 -> 33: a cached v32 reflection is missing a binding its
module declares. `docs/REFLECTION.md` gains both kinds in its binding-map and
descriptor-type tables.

Verified over 2880 corpus sources: SPIR-V bytes identical, failure count unchanged
at 204, and -- measured before the version bump, which changes every reflection
hash -- exactly one module's reflection changed, the one the mismatch scan named.

New authored fixture in `tests/reflection_covers_declared_bindings.rs`: a kernel
that queries the placeholder's width, the counterpart to the unconsumed probe
beside it. Verified as a detector: passing an empty placeholder list to
`report_synthesized_placeholders` fails exactly that test.

Gate: fmt, clippy -D warnings, warnings-denied all-features rustdoc, cargo test
-p metal2vulkan (debug and release), cargo test -p metal2vulkan-validation.
2026-08-31 23:34:36 +03:00
Anees Iqbal 42a7998514 Name each reflected resource once
`ShaderReflection::bindings` is a work list: a consumer walks it and acts once per
entry, allocating a descriptor, writing it, and sizing per-resource budgets from
the length. `from_fragment` called `append_embedded_resources` twice with the same
arguments, so every fragment entry with an `air.indirect_buffer` argument listed
each of its argument-buffer residents twice and asked for that work twice.

Nothing in the emitted module records the repeat -- the decorations it duplicates
are already there once -- so `reflection_covers_declared_bindings.rs`, which asks
whether reflection covers what the module declares, cannot see it. Measured over
2880 corpus sources: 405 fully-identical duplicate entries across 19 modules, all
fragment `EmbeddedArgBufferTexture` and `EmbeddedArgBufferBuffer`. After: 0.

To keep the class from returning silently, `validate_descriptor_abi` -- which both
`reflect_sanitized` and the reflected translation path run -- now rejects two
entries that agree in every field. Equality is the right test rather than the
`(set, binding)` pair, which raw-word alias buffers legitimately share and which
this check deliberately still allows; genuinely distinct resources always differ
somewhere, in the Metal index, the entry-parameter index, or an argument-buffer
resident's field offset.

New `tests/reflection_describes_each_resource_once.rs` with an authored fragment
fixture: one `air.indirect_buffer` holding a writable texture and a nested device
buffer. Verified as a detector -- with the second append restored the fixture test
and the gate test both fail. It also sweeps every public fixture and pins the gate
itself, so deleting the check cannot make the other two pass by not looking.

`REFLECTION_VERSION` 31 -> 32: a cached v31 reflection for such a fragment carries
entries a consumer would act on twice. `docs/REFLECTION.md` follows.

Verified: 2880 corpus sources, SPIR-V bytes identical and the failure count
unchanged at 204; 19 modules differ in reflection only, the same 19 the duplicate
scan named.

Gate: fmt, clippy -D warnings, warnings-denied all-features rustdoc, cargo test
-p metal2vulkan (debug and release), cargo test -p metal2vulkan-validation.
2026-08-31 23:09:09 +03:00
Anees Iqbal ca14b5b544 Report an imageblock plane wherever the module asks for one
The interface pass materializes a descriptor-backed render-target plane wherever
it lowers an `air.load/store.implicit_imageblock.*` call, and the detector that
finds those calls scans the module body -- it never looks at the stage. Reflection
did look at the stage: `KernMeta` carried the detected attachments and `from_kernel`
reported them, while `from_fragment` and `from_vertex` hardcoded an empty list.

A fragment entry that reads its render target back through the implicit imageblock
therefore emitted `OpDecorate %n Binding 200` and reflected nothing, so a consumer
building its `VkDescriptorSetLayout` from `ShaderReflection` produced a layout that
did not cover the shader. Verified on the authored fixture: before this change the
module declared Binding 200 with `implicit_imageblock_attachments: []`; now it
reports the plane at that binding.

`FragMeta` and `VertMeta` now carry the field, filled by the same stage-agnostic
detector, and one `implicit_imageblock_planes` helper does the meta-to-reflection
mapping for all three constructors instead of the one copy `from_kernel` had.

Scope of the evidence: all five corpus users of those intrinsics are kernels, so
this is not a claim about how common fragment imageblock read-back is in real AIR.
It is the module and its description disagreeing, which is a defect whether or not
a shipped shader has hit it.

`REFLECTION_VERSION` 30 -> 31, since a cached reflection from v30 is missing a
binding its module declares. `docs/REFLECTION.md` said 29 and now says 31.

Verified: 2880 corpus sources byte-identical (this changes reflection, not
emission).

The sweep in `tests/reflection_covers_declared_bindings.rs` stays at each fixture's
declared stage. Translating a module at a stage its AIR does not declare leaves the
stage parse with no source at all, so the reflection is a stub regardless of what
the module contains; that is a different question from this one.

Gate: fmt, clippy -D warnings, warnings-denied all-features rustdoc, cargo test
-p metal2vulkan (debug and release), cargo test -p metal2vulkan-validation.
2026-08-31 22:46:04 +03:00
Anees Iqbal c470af1290 Describe the nesting reconstruction step in the architecture guide
The CFG structurization section still described reconstruction as the bounded
relooper alone. Record that nesting runs first for reducible functions, what a
staged edge is, and why the pass checks its own value flow before adopting a
nesting.
2026-08-31 12:17:22 +03:00
Anees Iqbal 7154e84d2c Lower the per-translation wall-clock ceiling from 30s to 20s
The hard end-to-end ceiling per translation attempt is now 20 seconds,
in the corpus-triage worker guard that enforces it and in the AGENTS.md
and docs/VALIDATION.md statements of the contract. The 500-MiB memory
budget is unchanged.

Verified: corpus-triage unit tests (15) pass; fmt clean.
2026-08-31 10:26:25 +03:00
Anees Iqbal 52c961b4de Tighten owned numeric conversion contracts
Split ConversionClass so each width-changing conversion carries its own
shape contract instead of sharing IntegerToInteger and FloatToFloat
buckets. OpUConvert, OpSConvert, and OpFConvert now require the source and
result component widths to differ: a same-width conversion is not a no-op,
it is an invalid instruction. OpUConvert additionally requires an unsigned
result type, since it names a zero extension or truncation.

Reject OpSatConvertSToU and OpSatConvertUToS as a shape class before they
reach a numeric contract that does not describe them; the saturating OpenCL
conversions require the Kernel capability and have no Vulkan environment.

Switch the conversion checks from scalar_type_shape to numeric_type_shape
so component width is available alongside opcode and lane count.

Cover each rejected and accepted shape with a test that pairs the owned
verdict against the independent spirv-val verdict, so the construction-time
rule stays a restatement of the Vulkan rule rather than a local invention.

Verified: cargo clippy --all-targets (clean). Per request, the cargo doc
check and workspace test run were skipped.

Claude-Session: https://claude.ai/code/session_015sJUGShcKseDFnk4WvaJU2
2026-08-31 09:50:44 +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 8e95e84d0c Close specialization and descriptor audit gaps
Distinguish image descriptors from texel buffers, scope synthesized binding occupancy by descriptor set, and decouple the Metal texture source limit from configurable descriptor ranges. Centralize retry finalization and runtime sampler projection so layout and specialization contracts cannot drift across paths. Refresh consumer documentation and add adversarial descriptor tests.
2026-08-20 08:31:42 +03:00
Anees Iqbal 12abadb798 Add caller-selected descriptor layouts
Thread a versioned, validated descriptor layout through emission, reflection, synthesized resources, retry-created address tables, and Vulkan validation. Preserve the existing ABI as the explicit default and cover cross-stage separation, static samplers, embedded textures, raw aliases, invalid ranges, and default byte identity.
2026-08-20 07:52:35 +03:00
Anees Iqbal c37cd41b29 Align storage image reflection refusals
Enforce runtime storage-image component compatibility at the metadata-only reflection boundary as well as executable translation. Update every matching reflected storage binding, cover the authored embedded-texture checker path, and advance reflection and executor fingerprints to prevent stale reuse.\n\nVerified with cargo fmt, warnings-denied workspace clippy and Rustdoc, 1364 serial product tests, and 144 serial validation tests.
2026-08-20 07:05:05 +03:00
Anees Iqbal f3e376361b Specialize embedded runtime storage images
Route writable argument-buffer textures, including fixed descriptor arrays, through the runtime storage-image format and capability contract. Reflect their applied state by synthetic resource index and teach authored validation to resolve structural owner/offset identities through reflection before candidate translation. Bump reflection and executor fingerprints so stale outputs are not reused.\n\nVerified with cargo fmt, warnings-denied workspace clippy and Rustdoc, 1364 serial product tests, and 144 serial validation tests.
2026-08-20 07:00:10 +03:00
Anees Iqbal 547a59d99b Specialize runtime storage image formats
Accept runtime storage surface formats and host feature facts by Metal texture index, specialize image types before interface creation, and reflect the exact explicit or formatless contract. Track runtime origins through arrays and image aliases so every read, write, imageblock write, emulated fetch, and atomic operation checks the required capability or refuses honestly.\n\nWire authored validation resources into the same product options, bump the reflection and candidate executor contracts, document consumer use, and cover type splitting, dependent loads, exact formatless capabilities, atomics, incompatibility, missing bindings, imageblock writes, and pixel-gather storage reads.\n\nVerified with workspace clippy -D warnings, warnings-denied all-features Rustdoc, serial product and validation suites, both packaged AIR reproductions plus spirv-val Vulkan 1.3, and release measurements under 0.5 seconds / 23 MiB RSS.
2026-08-20 06:47:22 +03:00
Anees Iqbal f263d8a195 Reject lost runtime sampler specialization
Propagate exact sampler state through bounded sampler-typed SSA aliases and mark mixed joins ambiguous. Refuse pointer-selected runtime samplers instead of silently substituting the default sampler and returning to native sampling.\n\nAdd a selected-sampler regression and clarify the consumer contract.
2026-08-20 06:07:22 +03:00
Anees Iqbal 04666b0f44 Specialize runtime sampler state structurally
Accept bounded pipeline sampler state by Metal index, attach it to the emitted runtime sampler SSA value, and reuse the static sampler lowering seam for pixel-coordinate sampling, addressing, depth, comparison, and LOD refusals. Reflect only applied sampler states and make the validation executor consume that synchronized contract.\n\nCover normalized/pixel switching, fragment and kernel indices, all supported address modes, offsets, depth comparisons, serde, validation plumbing, and honest unsupported-state refusals.
2026-08-20 05:59:50 +03:00
Anees Iqbal 7cf240e05a Fix descriptor binding band collisions
Replace overlapping resource bases with checked sampled-texture, sampler, color, imageblock, storage-texture, and synthetic descriptor bands shared by emission and reflection. Reject unknown or cross-class descriptor layouts at the final module boundary, keep constexpr/default allocation inside its band, and bump reflection ABI version 22.

Also resolve kernel function-constant resource locations consistently, coalesce compatible aliases in the Vulkan validation consumer, and cover high/last indices plus sampled/storage aliases end to end.

Verified with serial product and validation tests, warnings-denied workspace clippy and Rustdoc, the packaged descriptor collision repro, a 500-row current-fingerprint translation checkpoint, and release translation at 0.02s / 22,216,704-byte max RSS.
2026-08-20 05:14:56 +03:00
Anees Iqbal adb19e2c2c Make AIR vector layout authoritative
Preserve and parse the source datalayout, use allocation strides through aggregate byte walkers, and correctly map uchar vectors from AIR struct metadata. Record typed mapping outcomes so authoritative metadata cannot disappear silently.\n\nCover scalar families, custom vector alignment, raw and inline lowering, retry emission, metadata matching, and path-based translation.
2026-08-20 03:58:18 +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 1b013834bc Improve translation correctness and oracle safety
Add structural lowering fixes for function constants, byte aggregates, texture arrays, sampling, and SIMD operations. Harden corpus oracle planning and quarantine unsafe or non-comparable rows without GPU resubmission. Reject reused SPIR-V merge ownership and fast-fallback oversized systematic CFG failures so broken AIR returns promptly instead of emitting invalid bytes after lengthy retries.
2026-08-10 16:54:26 +02:00
Anees Iqbal 3fbe8e516b Harden AIR translation and consumer validation
Expand structural image, buffer, control-flow, and passthrough lowering, including driver-safe relooper limits and regression coverage.\n\nExpose buffer extent, type, and refined access in reflection v4 for downstream consumers.\n\nHarden corpus oracle planning and loop safety, quarantine non-semantic rows, and refresh the affected translation and execution ledgers.\n\nVerified with cargo fmt --all, workspace clippy with warnings denied, and serial product and validation test suites.
2026-08-10 11:44:46 +02:00
Anees Iqbal 53b627809c Expand AIR translation and validation coverage 2026-07-26 00:43:57 +03:00
Anees Iqbal 3338acecb5 Reflect AIR constexpr sampler state
Reserve translator-owned constexpr samplers inside the sampler descriptor\nband instead of allowing framebuffer-fetch bindings to push them into the\ncolor-input range. Decode the full two-word AIR sampler state and expose it\nthrough reflection schema version 3 so Vulkan consumers can create the exact\nimmutable sampler rather than guessing from the emitted descriptor.

Keep emission and reflection ordering aligned by the stable AIR sampler\nglobal suffix, and cover the pipe25 shape with runtime sampler, two static\nsamplers, and a framebuffer-fetch color input.

Verified with:\n- cargo test --workspace --all-features -- --test-threads=1\n- cargo clippy --workspace --all-targets --all-features -- -D warnings
2026-07-24 02:23:35 +03:00
Anees Iqbal 6a14365536 Rework validation corpus workflow around ledgers
Replace the old drift/harvest scripts and generated corpus-test path with
Rust validation binaries that use JSONL ledgers as the durable corpus and
execution record.

- Move translate banking from validation/corpus/drift-ledger.jsonl to
  validation/corpus/metal2vulkan-ledger.jsonl, and seed tracked Metal and
  MoltenVK execution ledgers with hash-identified rows and output_b64
  payloads.
- Add corpus-harvest, corpus-mint, corpus-remint, corpus-why, corpus-triage,
  and corpus-run-{metal,vulkan,moltenvk} binaries for shard harvesting,
  additive/remint translate banking, single-case fallback inspection,
  status triage, and backend execution.
- Rework corpus runners to infer execution plans from shard-backed AIR at run
  time, merge per-run deltas into sorted ledgers, support focused reruns, and
  keep Metal oracle coverage available for translate FALLBACK rows while SPIR-V
  backends remain gated on translate status=ok.
- Bound control-parameter seeding and add loop-budget instrumentation,
  quarantine handling, subprocess timeouts, Ctrl-C worker cleanup, slow-case
  logging, panic backtraces, and MoltenVK/Homebrew Vulkan discovery for safer
  offline execution.
- Consolidate validation helpers for AIR stage/entry parsing, corpus source and
  shard resolution, hashing, JSONL I/O, texture shape policy, translate-ledger
  rows, runner status rows, and triage summaries.
- Remove obsolete Python drift/harvest scripts, generated corpus stubs,
  broken/tolerances sidecars, TOOLCHAIN.lock, and unused validation harness
  modules from the repo surface.
- Update validation, corpus, A/B, architecture, contributing, and agent docs,
  plus gitignore rules, to describe the shard-backed ledger workflow and its
  expected generated artifacts.
2026-07-23 20:01:24 +03:00
Anees Iqbal 3007485352 🆕 Open Source metal2vulkan 2026-07-22 13:15:24 +03:00