Commit Graph
11 Commits
Author SHA1 Message Date
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 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 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 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