bbc7866fa02caefd16d6c6ead0d79ed61ddb73dd
43
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
8d75695ead |
Answer per buffer whether a no-copy buffer's bytes are imported in place or copied
A no-copy buffer whose import the caller's gate refuses, or whose admitted import fails, is made over a copy of its pages (copied.rs), announced once per device. A consumer that probes whether an import worked could only read a WorkCounts::copied_host_buffers_made delta, which races with buffers other threads make on the same device. A per-buffer answer cannot. What: - Buffer::host_backing(&self) -> Option<HostBacking>, a runtime extension (Metal has none: a no-copy buffer's bytes are always the caller's pages there). HostBacking is #[non_exhaustive]: ImportedByPointer, ImportedAsDmaBuf, InHostRam (bound in a guest RAM's chunk), Copied (the copied-host-pages degradation) and Detached. None for a buffer over no host memory of the caller's; a buffer placed in a no-copy heap answers its heap's. The answer is where the bytes lie now, so it changes only at a rebind (which may move between an import and a copy) or a detach. It reads the import's shape and its copy registration alone: no page read, no import exposed (unlike gpu_address). - buffer::Shape records whether the bytes are bound in a RAM chunk (Placement::over_ram_chunk, a 6-line accessor in memory.rs), so the answer needs no read of the import's objects. - Buffer::copied (crate-internal) now reads host_backing, so the runtime's own decisions and the public answer cannot disagree. - Docs: the runtime README's runtime extensions, HOWTO's copied host buffers section, the copied-host-pages declaration and its docs/API.md catalogue entry name the query. api_signatures.tsv re-blessed: 7 records added, none changed or removed. The metal2vulkan api_surface table does not cover the runtime, so it is unchanged. RUNTIME_VERSION unchanged: a pure query, nothing the runtime does with an artifact moved. Verified on this M3 Max (MoltenVK 1.4.2, macOS 27.0.1), --cfg m2v_gpu, under memcap and maclock: - copied_device: host_backing_answers_what_the_gpu_uses_for_a_buffer_s_bytes (own buffer and own heap's buffer None; pointer import ImportedByPointer; gate-refused Copied; a no-copy heap's buffer its heap's, then Copied after the heap's gate-refused rebind; Detached after a detach; ImportedByPointer after rebinding) and host_backing_follows_a_rebind_between_an_import_and_a_copy (import, gate-refused copy, import, failed-import copy, each read back on the GPU); every copied test's lies_in_a_copy asserts Copied; host_ram_device asserts InHostRam for chunk-bound buffers and rebinds, and Copied for a refused rebind onto two runs. - The host-memory filter (copied|rebind|host_import|in_place|heap|detach|host_ram|host_aliases| host_residency|stand_in|host_backing): 148 passed, 0 failed, no device skipped. - Negative controls: forcing Copied and InHostRam to answer ImportedByPointer (the internal copied kept right) failed 10 tests; forcing Detached to answer None failed the new test. - clippy -D warnings plain and --cfg m2v_gpu; rustdoc -D warnings for the runtime; the api_signatures, api_surface and degradation catalogue tests; refusal surface and Metal coverage checks current. Not run: ImportedAsDmaBuf on a device (the dma-buf import is a Linux path; nothing here ran it). One work packet, landed as 2 commits on archive/development-linear-2026-10-29: 31b81906af, then 27ba200e86 (the re-pin). |
||
|
|
6e88d181dd |
Record each pipeline state creation, and warm a device from an earlier process's records
DeviceOptions::pipeline_records (and RawDevice::pipeline_records) hands a
hook an opaque PipelineRecord once per pipeline state creation that made its
state. That covers compute, render, mesh and tile states, the
additional-binary-functions forms, and a render state's draw-time twins (the
one-sample and factor-scaling ones). A failed creation and a binary
archive's add make none. A record holds the descriptor field by field
("M2VPREC\0", RECORD_FORMAT 1, the library table by content hash, SHA-256),
read back and compared at its making. Its libraries are kept once in the
shader cache's content directory. to_bytes and from_bytes carry it between
processes.
Device::warm(records, byte_budget) stands in for Metal's own pipeline caches
across processes:
- One background thread per device (utility QoS on macOS, Urgency::Warm in
the making budget) runs each record's creation under the default options
and drops the state. Translations, creation records and driver
pipeline-cache data are then in place before the program asks.
- The guest sees nothing of it: no identifier, resource ID, sampler number,
neutral, room, stand-in copy, kept-variant traffic, live-variant sharing,
announcement or record.
- It stops at byte_budget of added driver data.
- An unread record is counted, and the device's first is announced as the
warning metal2vulkan-warm-record-unread; nothing fails.
- WarmStatistics and Device::warm_statistics report the pass.
Ports dev-perf 14df1fb5fe and 66fe0ada29 without per-entry stamps.
Development's build directory names the translator, and its creation records
name RUNTIME_VERSION, so no entry of another translator or runtime version
is ever found, and dev-perf's re-translate-and-compare check has nothing to
do. Adapted:
- the memo is asked but never hands a warm thread a live variant the
program holds;
- a warm thread's waits rank Urgency::Warm, not Program (making.rs), and the
pipewait creation bound still applies on warm threads;
- unread records are announced.
DeviceOptions' and RawDevice's Debug are hand-written. PipelineRecord is
among the consumer auto-trait checks. api_signatures re-blessed; runtime
README and HOWTO updated. RUNTIME_VERSION 1707.
Verified on the M3 Max (MoltenVK 1.4.2), on development 2e2e238346:
- 140 device tests and 500 plain tests pass.
- Five sabotages each fail their guard: an archive add making a record; a
pass answering Warmed without creating; no unread announcement; a warm
state taking an identifier; a warm thread taking a live variant.
- clippy plain and --cfg m2v_gpu, and rustdoc -D warnings, clean.
- Release, 5 runs of the cross-process test, three creations (render,
compute, indirect compute):
- after a warm pass: 3.11-3.42 ms, with 0 stages decoded, 0 translated, 0
directory lookups and 0 driver caches loaded;
- unwarmed over the same directory: 4.19-4.32 ms (6 lookups, 2 loads);
- cold: 4.98-5.10 ms.
Small shaders, and Metal's own cross-process compiler cache serves all
three legs.
Lane commits: ws/warmrec-lane (8d106f29ab hook, 30de4fc948 warm).
One work packet, landed as 2 commits on archive/development-linear-2026-10-29: 8c709f27a7, then e2f0f2a3d9 (the re-pin).
|
||
|
|
3fd1f6672b |
Cut copied host buffers' CPU sync: page-at-a-time compare, log-gated copy in, merge only what may be written
The consumer's 4K boot on the RTX 5080 at the stock vm.max_map_count was unusable past its import gate: about 680 MiB of live copies (2,934 made) were compared whole at every commit and every completion, costing about half a core on both sides. Until the GPU copy is wired, three exact cuts, plus the dirty-log reports change 1 needs (the consumer's audit, A to C). - Change 3, a page-at-a-time compare (copied.rs sync): each 4 KiB page is compared whole (slice equality, vectorized), and the byte-exact merge runs only inside a page that differs. Same bytes as before; unit-tested against the old routine on random data, both sides changed included. - A, the copies' merge-back is reported: each copy keeps its pages' DirtySource and a writer id. sync collects the runs it wrote, and merge_back reports them with wrote_as before the completion is visible. Bytes a read-only copy drops are not reported. - B, the runtime's own CPU writes into logged pages are reported: replaceRegion into a heap's shadow texture (texture/heap.rs), the argument encoder and copyParameterDataToBuffer, as buffer_texture.rs already did. - C, GPU writes into logged pages imported in place are reported: each command buffer's written uses over memory with a dirty source, as writer 0 (the consumer's own writes, which every copy counts). They are reported at commit, before signals in the completion turn, and at completion, minus the shadows' own copy-backs. Collection is on while copies or such imports are live. Past the use cap, each written import is reported whole. A texture's use is reported as its whole buffer or heap (correct, coarse). This also closes the texture-shadow gap for pages reached through two imports. - Change 1, the log gates the copy in: where a copy's pages have a log (HostRam::with_dirty_pages, or the object's HostMemory::with_dirty_pages), a commit compares only the pages the log reports written since the copy last agreed. It uses one stamp per log and commit for every copy, waited for as the shadows' gated copy-in waits (DirtyPages::wait). A false wait, a copy's first copy in, bytes no log covers, and a copy that merged back 1 MiB or more since its last copy in compare everything. The copy in now runs before the commit's second state-lock block, since it may wait up to the log's bound. - Change 2, merge-back skips copies no finished batch may have written. Its "may write" is the bindings' write answers plus unnamed reach: a command buffer with a function that reads addresses (a root table), or one that executes an indirect command buffer, counts every copy as written. WorkCounts (new): copied_copy_in_bytes_skipped, copied_merges_compared, copied_merges_skipped. RUNTIME_VERSION 1705. Docs: copied.rs (Cost, Coherence), dirty_pages.rs' trait doc (what the runtime reports), FAST-PATHS (copied-host-pages known gap; the shadow gap closed), HOWTO copied host buffers. Measured, release, 680 MiB of live copies (2,049), median of 7, copy in / merge back in ms: - RTX 5080 laptop host (Core Ultra 9 275HX): - nothing changed: 231.8 / 231.6 before; 0.16 / 0.00 with all three; - 1% of pages changed: 233.7 / 233.8 before; 3.43 / 33.0; - one copy redrawn: 254.6 / 261.6 before; 29.4 / 34.1. - M3 Max: - nothing changed: 314.5 / 314.0 before; 0.12 / 0.00; - 1% of pages changed: 321.4 / 321.4 before; 4.54 / 18.5; - one copy redrawn: 353.9 / 395.4 before; 39.4 / 54.9. The merge-back figures are with the batch naming what it writes. A real frame's skip rate was not measured; the new counters show it. Verified: - M3 Max, MoltenVK 1.4.2, --cfg m2v_gpu, under memcap and maclock: the runtime lib suite passes 1445, 2 skipped. - RTX 5080 Laptop, NVIDIA 615.71.09, one 42 s hold: copied|dirty_pages| host_ram|event 101 pass. - New tests: 6 plain gating and merge-skip tests; a contract test that a concurrent CPU write survives both ways, log on and off; 7 device tests of the B and C reports, the gated copy, a read-only batch skipped, and an unnamed write still merged back. - Negative controls, each shown failing then passing once restored: gate forced off; A's report removed; C's registration or completion reports removed; the shadows' copy-backs not subtracted; B's heap report removed; merge skip forced off; unnamed reach ignored. - clippy plain and --cfg m2v_gpu (Mac, and msi niced), rustdoc -D warnings, api_signatures, api_surface, fast_paths. Lane commits: ws/cpusync-lane (180fc103c1 .. 59d82299ad, 9 commits). One work packet, landed as 2 commits on archive/development-linear-2026-10-29: bb00ae47f6, then 2b8ad3ab58 (the re-pin). |
||
|
|
97116bb420 |
Keep pages the kernel cannot pin from NVIDIA's driver, and copy them as a failed import is copied
On NVIDIA's driver (615.71.09, RTX 5080 Laptop), a failed host-pointer
import of pages the kernel cannot pin breaks the process's later
host-visible allocations. The consumer's device-creation probe hit this, so
no guest RAM chunk imported afterwards. The runtime now asks the kernel
first on that driver, refuses such pages itself with the answer Vulkan
requires, and never hands them to the driver. The object then goes its
other ways: the dma-buf source, else a copy.
Cause, measured on msi's 5080 through runtime device tests that logged each
call's VkResult and errno, the fd table and the process's maps:
- The consumer's probe makes no dma-buf import on NVIDIA. Its 1025-page view
is past udmabuf's list_limit, so its source refuses. What fails is the
runtime's import of the view's pointer, a VM_PFNMAP mapping of a udmabuf:
vkGetMemoryHostPointerPropertiesEXT succeeds (types 2 and 3), then
vkAllocateMemory answers ERROR_OUT_OF_DEVICE_MEMORY on both.
- After that, vkAllocateMemory answers ERROR_OUT_OF_DEVICE_MEMORY to every
host-pointer import measured:
- memfd pages from 8 KiB to 8 MiB at any offset;
- anonymous pages;
- RAM 512 MiB away;
- 40 retries over 3 s;
- a second VkDevice.
It also fails a plain 64 KiB host-visible allocation. Device-local
allocations still work. The chunk import fails in vkAllocateMemory, not
in the properties query or the requirements check.
- Not the cause: a failed udmabuf import itself (the next 8 chunk imports
bind, and NVIDIA closes the handed clone: F_GETFD EBADF), the properties
query alone, mapping a udmabuf, address reuse, the fd table, VmPin/VmLck,
the kernel log.
Vulkan (vkspec 1.4.366, 11.2.6): such a restriction "must fail the memory
import operation with the error code VK_ERROR_INVALID_EXTERNAL_HANDLE_KHR";
and (Return Codes) "VK_ERROR_OUT_OF_*_MEMORY errors do not modify any
currently existing Vulkan objects."
Fix:
- RuntimeDriverDefect::UnpinnablePagesBreakHostMemory (NVIDIA_PROPRIETARY,
no GPU probed clean, per the defect table's rule).
- On such a device, Device::refuse_unpinnable runs before a no-copy
object's, heap's or rebind's own import and before a guest RAM chunk's
import. It walks the mappings over the pages (PROCMAP_QUERY, or the maps
lines before Linux 6.11) and reads one byte of each through
process_vm_readv. The kernel refuses a whole VM_IO/VM_PFNMAP mapping, so
one read per mapping answers for all its pages.
- Pages it cannot pin get its own Unsupported/HostMemory refusal naming the
defect. That refusal sends the object to the dma-buf source; with none,
or where the source's import fails, the object is a copy, announced as
copied-host-pages and counted as a failed import. This holds for buffers,
heaps and rebinds. A RAM chunk over such pages is not imported, and the
objects over it end in the copy. Pages not mapped readable keep their
refusal. The new refusal reaches a caller only where pages remapped after
their first import are imported again (docs/REFUSALS.md regenerated).
- Counted: WorkCounts::host_imports_unpinnable.
- Every other driver, and every OS but Linux, asks nothing and keeps its
path.
- Docs: driver_defects.rs (the measurement), FAST-PATHS known gaps, HOWTO
section 6 and its copy causes, the runtime README, copied.rs,
CopiedHostPages and its API.md entry.
- RUNTIME_VERSION 1704.
Verified:
- RTX 5080 Laptop, NVIDIA 615.71.09, --cfg m2v_gpu: the runtime filter
host_ram_device|copied_device|rebind|dma_buf|host_residency|
driver_defects|host_memory|host_import|copied passes 97/97 on the
committed tree.
- New: a_chunk_is_imported_after_a_refused_import_of_a_dma_buf_mapping
failed without the fix ((0, 0) where (1, 2) is expected) and passes
with it.
- New: pages_refused_before_the_driver_with_no_source_are_copied: a
buffer, a heap and a rebind over a udmabuf mapping with no gate and no
source give 3 refusals before the driver and 3 copies. The GPU reads
the right bytes, and a chunk then imports with 2 buffers bound.
- The consumer's repro, with its device probe in front
(os::linux::host_ram::tests::a_buffer_over_one_run_of_the_ram_is_bound_in_its_chunk,
built from a read-only copy of their 2cb3c8f91): passes. It fails against
development 2e2e238346.
- M3 Max, MoltenVK 1.4.2: the same filter 83/83; runtime unit tests 1161;
API, refusal-surface and fast-paths tests 34; rustdoc -D warnings clean.
Clippy -D warnings is clean on the Mac (plain and --cfg m2v_gpu) and on
msi (plain and --cfg m2v_gpu).
Left: RADV and ANV refuse such pages themselves, so an object there with no
source is still refused (not run there). A failed chunk import is not kept,
so the kernel is asked again for each object over that chunk (cost not
measured).
Lane commits: ws/chunkfix-lane (a2420020ea, a56fa43f2b).
One work packet, landed as 2 commits on archive/development-linear-2026-10-29: a0a1ea79d4, then 22fa5003db (the re-pin).
|
||
|
|
44eaa09898 |
Copies of read-only pages drop the GPU's writes; the gate is asked before write permission
The consumer's 4K boot on the RTX 5080 (NVIDIA 615.71.09) died at a buffer rebind onto 12 KiB of
read-only pages (`replaceBackingWithRanges:readOnly:`) with `OutOfMemory(Device)`, its gate having
refused the pages.
Cause: on Linux the runtime asked the pages' write permission before the caller's gate. Read-only
pages with a dma-buf source were sent to the source (by_pointer cleared), and the gate, asked only
for pages imported by pointer, was skipped. NVIDIA 615's import of the source's dma-bufs fails with
VK_ERROR_OUT_OF_DEVICE_MEMORY, and that failure was answered as the call's error, where a failed
pointer import takes the copy. The copy path itself never ran. Reproduced on the 5080: a buffer's
rebind, a heap's rebind and a no-copy buffer over read-only pages under a refusing gate each
answered OutOfMemory(Device). On macOS the gate was asked and the copy made, and the copy's
merge-back then wrote the read-only pages: SIGBUS in all three.
Fix:
- The gate is asked before the write permission, at a no-copy buffer's or heap's making and at a
rebind. Pages it refuses, and bytes moved in their page, are a copy, their permission unasked;
only pages imported have it asked.
- An admitted import of the caller's dma-bufs that fails (out of memory, another Vulkan error)
takes the copy too, as the pointer's import did: the gate's documented contract.
- A copy of pages the process cannot write drops the GPU's writes (copied.rs), as Metal drops them
for read-only memory (read_only_view.rs). The copy asks the system as it is made
(`mapped_writable`: PROCMAP_QUERY on Linux, mach_vm_region on macOS). At each completion, every
byte the GPU changed in the copy takes back the byte the pages and the copy last agreed on, and
nothing is written to the pages. Later commands of the same batch read the write back; a later
command buffer reads the pages' bytes. CPU writes through another mapping are copied in at each
commit as before.
- The copied-host-pages detail says so; read-only-pages-written is not announced over a copy.
Changes beyond the consumer's case: gate-refused pages and moved-bytes copies no longer ask the
kernel for write permission (no host_mappings_queried for them). Read-only pages with no source
under a refusing gate are a copy instead of Unsupported.
WorkCounts::copied_dropped_bytes (new). RUNTIME_VERSION 1703. api_signatures.tsv blessed;
REFUSALS.md regenerated, unchanged. Docs: HOWTO (copied host buffers), API.md (copied-host-pages,
read-only-pages-written), FAST-PATHS (the read-only-memory known gap now excepts copies),
ImportGate, HostMemory::new, new_buffer_with_bytes_no_copy, Buffer::rebind_bytes_no_copy, the two
Degradation declarations, copied.rs module docs.
Tests:
- Device, copied_device:
- a no-copy buffer, a buffer's rebind and a heap's rebind over read-only pages under a refusing
gate, the consumer's form: a read-only shared mapping, a dma-buf source on Linux;
- checked in each: the gate asked once with the pages, the source never called, a copy that
reads the bytes and a CPU write through the writable mapping;
- a blit fill completes with the pages unchanged, nothing merged back, copied_dropped_bytes the
fill's changed bytes, and a later command buffer reading the pages' bytes;
- Linux: the rebind under an admitting gate whose dma-buf import fails is a degraded copy that
drops the writes.
- Unit: restore, merge_back of an unwritable copy, mapped_writable (Linux and macOS).
- Negative controls:
- the three refusing-gate tests on the unfixed runtime: RTX 5080 3/3 fail with
OutOfMemory(Device) at the call; M3 Max 3/3 die with SIGBUS;
- the admitted test with only the source-failure copy arm removed: the 5080 fails with
OutOfMemory(Device).
Verified:
- RTX 5080 Laptop, NVIDIA 615.71.09 (msi; four holds, each under a minute): runtime
copied_device|rebind|host_ram_device|tests::copied::|can_be_written 52/52 at the final tree. The
admitted test's copy path ran (its line printed).
- M3 Max, MoltenVK 1.4.2, --cfg m2v_gpu under maclock and memcap: the same filter 49/49 (the
admitted test is Linux-only).
- Mac: degradation_catalogue, copied and host_memory unit tests with api_surface and
published_crates 37/37; api_signatures and fast_paths 16/16; clippy --workspace --all-targets
--all-features, plain and --cfg m2v_gpu, clean; rustdoc -D warnings for the runtime clean.
- msi: clippy -p metal2vulkan-runtime --all-targets --all-features --cfg m2v_gpu clean.
- Not run: the validation suites. The runtime-sources pin is left for landing.
One work packet, landed as 2 commits on archive/development-linear-2026-10-29: 5012056c31, then 6385d650b9 (the re-pin).
|
||
|
|
c0617d796e |
Rebinds take the copy where the gate refuses: heaps, images in place, moved bytes, one-run chunks
The NVIDIA RAM route's rebind part, with RunResolver's doc saying a rebind asks it. One work packet, landed as 4 commits on archive/development-linear-2026-10-29, in order: * Rebinds take the copy where the gate refuses: heaps, images in place, moved bytes, one-run chunks (c0e37e8984) The NVIDIA RAM route's rebind part (consumer spec, part 4). A buffer's rebind with an image in place over it, and a heap's rebind, now take the copy of the new pages (copied_pages) where the caller's gate refuses their import or the admitted import fails, instead of refusing NotImplemented(RebindTextures) or failing the call. Heap rebinds ask the gate like any import. A buffer's rebind to bytes at another offset in their page, under a texture planned at the old offset, takes a copy laid out at the old offset (the gate unasked: nothing is imported) instead of refusing. - The copy's memory, where images will bind in it, holds the window's whole pages from a multiple of the import's unit. The heap's textures bound to its bytes and the images in place over the buffer are made again over the copy: in memory the device allocates, as linear images that start PREINITIALIZED, whose first move keeps the copy's bytes (Vulkan: "the transition away from this layout will preserve that data"). - Where images in place ride on the copy, it lies in fresh pages the runtime maps and imports by pointer (Device::fresh_page_buffer), and each image is made as over the caller's pages for host allocations, under the device's in-place check for fresh pages (PagesClass::Fresh, else RebindTextures). On the RTX 5080 the driver's own linear image does not lie at Metal's 256-byte pitch, so the first form still refused there. - The run resolver at rebind (ram1's route_runs and bind_in_chunk): asked once with the new window, on the calling thread with no runtime lock held, before the gate. One run inside one chunk binds in the chunk's import (no import, no gate); any other answer takes the gate, then the import or the copy. The runs are kept with the new pages, copies included; bytes moved in their page are never chunk-bound. - Metal's rebind order is unchanged: the pending check runs before the gate, and committed-not-submitted command buffers are encoded again over the copy. - RebindTextures stays, for a device that makes no image over the copy at the texels' pitch, memory type or alignment, and for drops-writes buffers (option bit 24) whose bytes moved. WorkCounts (new): copied_rebind_pages_moved (a third cause within copied_host_buffers_made) and copied_rebind_images_made. No new Error variant. heap_raw_image takes (memory, at) and a memory-type check. RUNTIME_VERSION 1702. Docs: HOWTO copied host buffers and guest RAM, API.md copied-host-pages, FAST-PATHS (the heap and in-place rebind exception removed from the known gap), the runtime README, ImportGate, HostMemory::with_runs and with_import_gate, rebind.rs, copied.rs module docs, RebindTextures; REFUSALS.md and api_signatures.tsv regenerated. Verified: - RTX 5080 Laptop, NVIDIA 615.71.09 (msi, one hold): runtime copied_device|host_ram_device|rebind|in_place 48/48; the image over the copy is made (copied_rebind_images_made asserted 1) in the gate-refused, moved and ordering tests. Validation rebinds|dma_buf_imports 28/30: the two failures (ycbcr planes over chunks "off the grid", dma-buf in place "one run") also fail at development 2cfd8d6ef9 on the same GPU. - M3 Max, MoltenVK 1.4.2, --cfg m2v_gpu under maclock: runtime host-memory filter 157/157; validation rebinds|dma_buf|copied|no_copy|host_memory 75/75; at the final tip copied_device|host_ram_device|rebind 40/40. Here textures over buffers are shadows, so only the heap image over the copy runs (1 per heap test). - 7 new device tests: gate-refused buffer rebind with a texture over it, moved bytes, heap rebind gate-refused and import-failed, ordering with a held and an uncommitted command buffer, resolver at rebind (one run binds in the chunk; two runs go gate then copy). - Focused non-device tests 76/76; clippy plain and --cfg m2v_gpu clean; rustdoc -D warnings clean for the runtime. - Not covered by one venue: both images over a copy at once. Lane commits: ws/ram3-lane (d3945d0d9d, 7a114b599e, b93a6c1eac, 8b9fa5fb46). * Re-pin the runtime sources at the landing tip (7f76090454) * Say that a rebind asks the run resolver, as c0e37e8984 made it (8dcba47435) RunResolver's doc still said a rebind to new pages does not ask it. Since c0e37e8984 a buffer's or heap's rebind asks it once with the new window, before the gate, except where the bytes moved in their page under a texture, which take a copy without asking (with_runs' and Buffer::rebind_bytes_no_copy's docs already say so). Doc only. * Re-pin the runtime sources at the landing tip (17896b4366) |
||
|
|
76d89d87a8 |
See an event signal behind a copied host buffer at its completion turn
An event signal behind a copied host buffer is seen at the batch's completion turn, and the
copied host pages' cost is announced as the catalogue states it.
One work packet, landed as 4 commits on archive/development-linear-2026-10-29, in order:
* See an event signal behind a copied host buffer at its completion turn (8fc9c56dcb)
A batch's event signal is its GPU signal of the event's timeline semaphore,
and the host read the semaphore's counter directly (`EventShared::value`),
while a copied host buffer's GPU writes reach the caller's pages only at the
batch's completion turn (`completion.rs`, merge then `reached`). So a CPU
that saw the value could read the pages before the GPU's writes, and a plain
event's wait chained on the VkQueue let another queue's work start before
them: Metal's writes before a signal are in the pages once its value is
seen (the documented gap in FAST-PATHS, now closed).
A signal kept while the device holds a live copy is marked behind the merge
(`EventTimeline::keep`). No counter read observes it or any signal after it,
and no wait is handed its index (the scheduler's own host wait included); a
plain event's wait for it is held as a shared event's is. The completion
turn, which merges first, observes it and wakes every host wait and held
batch. The signal stays the batch's GPU signal: no submission is added. The
cost per such signal: its value reaches readers one completion turn later
than the counter shows it, and a GPU wait for it is a host hold plus a
vkQueueSubmit at that turn. Counted: WorkCounts::event_signals_behind_merge.
The same mechanism will hold for the GPU-kept copies.
RUNTIME_VERSION 1699 (renumbered at landing).
Verified on the M3 Max (MoltenVK), --cfg m2v_gpu, under memcap and maclock:
57 copied, event, scheduler and fast-path tests pass, among them the new
a_shared_event_s_value_is_seen_once_the_copy_s_bytes_are_in_the_pages
(six rounds, spin reads and host waits, a 64 MiB copy beside to lengthen
the merge) and the timeline unit test
a_signal_behind_a_merge_is_seen_at_its_completion_turn_alone. Negative
control: with the mark off, the device test fails on the byte check
("the write is in the pages once the value is seen"). clippy (plain and
--cfg m2v_gpu) on metal2vulkan and metal2vulkan-runtime, api_signatures
re-blessed (the new field), api_surface pass.
RUNTIME_VERSION 1700.
* Re-pin the runtime sources at the landing tip (2cef515da6)
* Announce the copied host pages' cost as the catalogue states it; list what pack.rs reaches (e9ba27478b) (its crates/metal2vulkan-runtime/src/degradation.rs part)
The final gate on 3e20b58763 failed two tests.
- degradation_catalogue: the signal-behind-merge fix (8fc9c56dcb) closed the
shared-event gap and rewrote the API.md entry for copied-host-pages, but the
runtime still announced "(behind a shared event's value among them)". The
announced cost now drops it, so the catalogue's entry starts with it word
for word again.
- the_runtime_sources_are_the_committed_ones: pack.rs became a runtime input
(the mipmap kernel's sRGB transfers), and it also reaches
metal2vulkan-air's intrinsics, lower/arith/math.rs and lower/arith/narrow.rs
through its pack and unpack intrinsics, which only the compile emits. They
are listed as not runtime with that reason. The stale comment about
srgb.rs's encode, tables and steps (deleted by the mipmap and n7 packets)
now says only what is true.
Verified: the two tests on the landed tip (see the landing).
* Re-pin the runtime sources at the landing tip (538f3f1161)
|
||
|
|
f4394b8712 |
Copy a no-copy buffer's pages the kernel cannot pin where the process maps them readable
Cause: a copied host buffer (the caller's gate refused the import, or the admitted import
failed) read its first bytes only through the kernel: `process_vm_readv` of our own pid on
Linux. That read pins each page, and no page of a VM_PFNMAP or VM_IO mapping can be pinned, so
on a dma-buf's mapping (udmabuf's on Linux 7.2) it fails although the pages are mapped
readable. `CopiedBuffers::add` then answered `NotCopied::Unreadable`, and the buffer, heap or
rebind was refused as not importable (`Unsupported { HostMemory, NotRepresentable }`): the copy
never worked for dma-buf mappings, which is where a consumer's gate refuses imports on NVIDIA
at the kernel's default vm.max_map_count.
Fix: where the kernel's read fails, the copy asks the process's mappings whether every page of
the range is mapped with read permission and, if so, reads it with plain loads, the access the
copy's comparisons already make at every commit and completion (`copied::read_caller`). The
mapping check generalizes the import's write check: `PROCMAP_QUERY` tests
`PROCMAP_QUERY_VMA_READABLE` as it tested `..._WRITABLE`, and before Linux 6.11 the
/proc/self/maps lines' `r` as their `w` (`host_memory::Access`, `queried_permitted`,
`permitted`, `mapped_readable`). Pages not mapped, or mapped without read permission, are still
refused. All three users of `add` (buffers, heaps' own buffers, rebinds) take it. Off Linux
nothing changes (no mapping is asked; macOS's mach_vm_read path as before). RUNTIME_VERSION
1696 -> 1697 (renumbered at landing). Docs: API.md's copied-host-pages entry, HOWTO's copied
host buffers, the runtime README, and FAST-PATHS' known gap with the measured cost.
Evidence (verified):
- msi (Linux 7.2.8, RTX 5080): tests::copied + tests::host_memory 21/21; the udmabuf test
printed "the kernel cannot read this udmabuf mapping: copied with plain loads".
Under the GPU lock on NVIDIA: tests::copied_device + tests::copied 15/15, among them the new
copied_buffer_is_made_over_a_dma_buf_mapping_the_gate_refuses (gate refusal -> copy made,
announced, CPU writes copied in and a fill merged back over the udmabuf pages).
- Negative control on msi: with the fallback disabled the two new copied tests and the new
device test FAIL (the device test at the buffer's refusal); restored, PASS.
- macOS (M3 Max, MoltenVK, under maclock): copied, copied_device, host_memory 25/25; plus
degradation, catalogue and fast_paths 45/45.
- clippy -D warnings clean: macOS plain and --cfg m2v_gpu; Linux (msi) plain and
--cfg m2v_gpu, runtime crate, all targets, all features. rustdoc -D warnings clean (runtime).
- Cost, release, msi: one add of a 64 MiB udmabuf range 15 ms (the failing kernel read 6 us,
the mapping query 22 us); each comparison of a 64 MiB copy 22-41 ms on the CPU; on NVIDIA a
live 64 MiB copy makes each empty command buffer's commit and wait 45-68 ms (0.2 ms without).
- Not run: the Mac's Linux container exposes no /dev/udmabuf.
RUNTIME_VERSION 1698 at landing.
One work packet, landed as 2 commits on archive/development-linear-2026-10-29: 1612481fb3, then 95852120a3 (the re-pin).
|
||
|
|
442a9fd538 |
Bind no-copy objects over one run of guest RAM in the device's chunk import
The NVIDIA chunk route's API (HostRam, Device::use_host_ram, HostMemory::with_runs), the chunk
source and one-run route, and a chunk-bound buffer's out-of-bounds writes held to the device's
own containment (a device test and a known gap).
One work packet, landed as 7 commits on archive/development-linear-2026-10-29, in order:
* Add HostRam, Device::use_host_ram and HostMemory::with_runs (d3617f7e1d)
The API of the NVIDIA chunk route (guest RAM imported whole): the types the
chunk source, the GPU copy and the rebind lanes build on.
- HostRam (unsafe new(ranges, keep_alive)): the consumer's guest RAM ranges,
checked as non-empty, whole host pages, within the address space and apart;
a typed refusal otherwise (Invalid, Problem::HostRam). with_dirty_pages
takes one DirtyPages log for the whole RAM whose offsets are host addresses
(the log's pointer is 0), so one stamp per commit can serve every copy. The
keep-alive is dropped with the HostRam (forgotten while the process exits).
- Device::use_host_ram(&Arc<HostRam>) -> HostRamUse: a guard, since runtime
devices live for the process while a lease promises its RAM for one guest
device's life. Dropping the guard ends the use; a later RAM may be used
after. Several RAMs whose ranges are apart may be used at once; one whose
ranges meet a used RAM's (itself among them) is refused as misuse
(Invalid, Problem::HostRam). A device without VK_EXT_external_memory_host
is refused (Unsupported, naming it).
- HostMemory::with_runs(RunResolver): RunResolver is
Arc<dyn Fn(start, len) -> Option<Vec<Range<u64>>> + Send + Sync>, asked with
the import window, answering host addresses in the RAM's ranges. Stored
here; the routing that calls it comes in a later commit.
No Metal counterpart for any of it; the doc comments say so. The chunk import
itself (lazy 64 MiB chunks) and the routing in buffer_over_host_memory follow.
Verified: cargo clippy -p metal2vulkan-runtime --all-targets --all-features
-D warnings (Mac); host_ram unit tests 4/4 (range checks, refusals,
keep-alive drop); api_signatures and refusal_surface 7/7 after the re-bless
and regeneration; rustdoc -D warnings for the runtime crate.
* Re-pin the runtime sources at the landing tip (22c47609a9)
* Bind no-copy objects over one run of guest RAM in the device's chunk import (7f07d19b3d)
What: the chunk source and the one-run route (host_ram.rs).
- Chunk source: a device that uses a HostRam imports it by host pointer in
64 MiB chunks (CHUNK_BYTES), never across a range's end, lazily. Each chunk
is imported the first time an object over it is made, on that thread, once,
under a lock of its own (ChunkSlot). It goes through the existing
Memory::import_host: a coherent type, and the device-address flag where
bufferDeviceAddress is on. A whole-chunk VkBuffer is kept for the runtime's
own copies only, never named by a Metal buffer, root entry or binding.
- Chunk lifetime: chunks are never released while idle (they are no
HostImport, so host_residency never sees them). Once the HostRamUse is
dropped, a chunk is freed when nothing holds it: Placement gains ram_chunk,
so every buffer bound in a chunk holds it, and every command buffer that
used one does too. The RAM, and so its keep-alive, goes after the free
(release_then's after), dropped as the program's. Exiting leaves it all to
the process's end.
- Routing in buffer_over_host_memory: a buffer that lies in a live import of
the same bytes is unchanged. Otherwise, where the device uses a RAM and the
memory has a resolver, the resolver is asked once with the import window, on
the calling thread with no lock held, before the writability query and the
gate. Memory whose GPU writes bit 24 drops is never routed.
- One run inside one chunk: Device::bind_in_chunk makes the VkBuffer with
host_buffer against the object's own window, checks it with binds_in
against that window, and binds it at run offset + binds_in offset in the
chunk's memory. That offset must be a multiple of the buffer's alignment,
and the buffer must allow the chunk's memory type. Its placement
(Placement::ram_chunk) holds the chunk and maps the caller's pointer, so
contents stays the pointer. The buffer gets no import of its own, the gate
is not asked, and buffer_of keeps the import fixed (no Again).
- Several runs, a run crossing a chunk's end, a chunk that cannot be imported
or a buffer that cannot bind exactly: today's gate path (import, or copy
where the gate refuses).
- The RAM and runs are kept on HostPages (ram_runs) until rebind or release,
for the GPU copy lane.
- An answer that is not whole pages of one used RAM totalling the window is
refused: Invalid, Problem::HostRam.
- Heaps over host memory take the same routing (of_heap goes through
buffer_over_host_memory).
- rebind_host_pages only ignores the new HostParts.runs (`runs: _`). The
rebind lane asks the resolver there with Device::route_runs and
bind_in_chunk.
- New WorkCounts: host_ram_chunks_imported, host_ram_chunk_bytes,
host_ram_chunks_live (a gauge), chunk_bound_buffers_made.
- Docs: HOWTO "Guest RAM imported whole", the runtime README's extension list.
RUNTIME_VERSION 1697 -> 1698.
Why: the NVIDIA route (the consumer's spec). On a device that refuses
dma-buf views, each import of scattered guest pages takes a kernel mapping per
page, past vm.max_map_count at 4K. One-run objects bound in chunks take none.
How verified (this Mac, M3 Max, MoltenVK, under memcap + maclock):
- host_ram unit tests 8/8: chunk spans and lookup; one run in a chunk, a
chunk's last pages and a range's short last chunk; several runs and a run
crossing a chunk (gate path); broken answers refused.
- New device tests tests::host_ram_device 6/6. The path ran: the log prints
"chunks imported 1, chunk-bound buffers 2".
- One run binds in the chunk: 1 chunk import of 64 MiB, 0 pointer imports,
gate not asked, contents == pointer, the GPU reads the bytes, a fill
reaches them, a second buffer in the chunk imports nothing.
- Containment: a 1.5-page buffer's copy reach <= its 2-page window, and a
fill of all of it leaves the sentinel page before and the bytes after it
unchanged.
- A no-copy heap binds in the chunk.
- None, two runs and a crossing run ask the gate once and import; short and
outside answers are refused.
- A command buffer held behind an event keeps the chunk (live gauge, and
the keep-alive not dropped) after the buffer, the use and the RAM are let
go of; once it completes the chunk is freed and the keep-alive dropped.
- The same RAM twice and an overlapping RAM are refused, a RAM apart is
taken, and a new RAM over the same ranges is taken after the first use
and imports again.
- Regression on the same Mac: 249/249 for
host_|copied|dirty|rebind|heap|no_copy|dma_buf|in_place|detach|alias|
degradation|profile (copied_device, dirty_pages_device and the
host-import tests among them).
- clippy -D warnings plain and --cfg m2v_gpu (runtime, all targets, all
features); rustdoc -D warnings for the runtime; api_signatures 3/3 after
the re-bless.
Not run here: NVIDIA (msi 5080) and lavapipe; dma-buf devices' own tests
beyond the Mac's.
RUNTIME_VERSION 1699 at landing.
* Re-derive the generated documents at the landing tip (a9c042f142)
They are generated from the whole case set, and the set grew on `development`
while this branch was in flight, so the copy committed here counted a smaller
one.
Verified: regenerating at this tip leaves no change beyond the `Generated at`
stamp.
* Re-pin the runtime sources at the landing tip (2cfd8d6ef9)
* Hold a chunk-bound buffer's out-of-bounds kernel writes to the device's own containment (1b09d84fad)
What: a device test (tests::host_ram_device) whose kernel, the owned fixture's
scale_and_offset, writes three pages of words through a one-page buffer bound
in a chunk of guest RAM. It asserts that the page before the buffer and the
pages after it keep a sentinel, and that the kernel wrote the buffer itself.
The page-after assertion applies wherever the device keeps the same write,
through a one-page buffer of its own, out of the buffer made after it: the
chunk binding is held to the device's own containment, measured in the same
test. A known gap in docs/FAST-PATHS.md records the device that does not
contain such writes.
Why: containment (c) of the route. A chunk-bound VkBuffer ends at the
object's last page, but the chunk's memory goes on past it, so containment
rests on the device's buffer robustness or in-shader checks, not on the
import's end as a per-object import does.
Found and how verified:
- RTX 5080 laptop (NVIDIA 615.71.09), msi, one hold 06:00-06:02, strict form
(no device check): host_ram_device 7/7. The chunk's pages after the buffer
were untouched.
- lavapipe (linux-gate, slot lava, arm64), strict form: 7/7.
- M3 Max (MoltenVK 1.4.2), this form: 15/15 host_ram tests. It prints that
out-of-bounds writes changed 32720 bytes of the device's own next buffer and
32720 bytes of the chunk's next pages. A control run (not committed) showed
that a no-copy pointer import of one page changed 0 bytes past its page. So
MoltenVK's gap is within an allocation; it predates the route, which
inherits it.
- clippy --cfg m2v_gpu -D warnings (runtime, all targets).
Also: the RunResolver doc no longer says rebinds ask it; they do not until rebinds are routed (af9f1e057d).
* Re-pin the runtime sources at the landing tip (60c300198f)
|
||
|
|
bc1a6ebf8b |
Encode a half's bits by the device's narrowing, not an integer sequence
A half value whose bits are not known from a load (a store, a reinterpretation, a texel's or snapshot's bits) is encoded by the device: with shaderFloat16 one OpFConvert to 16 bits (NoContraction under the float controls), each lane read as a word beside a 16-bit zero; without it GLSL.std.450 PackHalf2x16. The exact integer sequence (rebias, NaN quieting, the 2^24 denormal scaling, the 0x7C00 cap under native rounding) is deleted. narrow::encodes_bits finds the narrowing; compile.rs records the widening's notes for it: NativeNanEncoding everywhere, NativeHalfConversion where neither the float controls nor MetalHalfArithmetic cover it. Bits known from a load, folded constants, an integer's half and bfloat stay exact. bits_words 136 -> 48 per lane. Tests pinning the old NaN bits accept the device's where the note is recorded; 40 known-gaps rows the Apple M3 Max no longer diverges at are dropped (29 attribute-format-fetches half-NaN sites, 3 each of half-texel-nans-r16f/ -rg16f/-rgba16f, 2 of math-frexp-ilogb-half: Metal's own NaN bits now). SEMANTICS_VERSION 1919. Verified: 347 translator tests (lower::arith::tests, the touched engine modules, every public fixture on every committed profile), clippy plain and --cfg m2v_gpu, rustdoc; a sabotaged encode form fails the new a_half_encode_is_the_devices_narrowing_in_every_form; on the M3 Max: conformance replay of 28 half cases exit 0 (every divergence a held ledger row), validation runtime_lane half tests 7/7, runtime nan_signs/vertex conversion notices/degradation sites 4/4. golden_hashes.tsv cells move, re-blessed on development. Not run: lavapipe, the full validation and conformance sets. One work packet, landed as 1 commit on archive/development-linear-2026-10-29: 0d7093d826. |
||
|
|
0a1851164d |
Copy a no-copy buffer, heap or rebind whose import the caller's gate refuses or that fails, announced
A new HostMemory::with_import_gate(ImportGate) asks the caller once,
holding no lock of the runtime's, just before a no-copy buffer, a
no-copy heap or a buffer rebind imports its pages, passing an
ImportRequest with the pages the import would map. If the gate answers
false, or an import the device and the gate admitted then fails
(OutOfMemory, another Vulkan error), the object is made over a copy of
the pages instead of failing. The default stays import-first. The copy
is host-visible memory owned by the runtime; `contents` stays the
caller's pointer. Each commit copies in the bytes the CPU changed since
the last sync, and each batch's completion merges back the bytes the GPU
changed (CPU wins where both wrote), byte by byte, before events,
waiters and handlers see it. Every copy is announced
(`copied-host-pages`) and counted. Pages the process cannot read are
never copied (the first copy reads through the kernel:
process_vm_readv / mach_vm_read_overwrite). A copied heap's buffers lie
in the copy and its textures are shadows. A rebind's copy is laid out as
its import would be. A rebind over an in-place image is refused
(NotImplemented(RebindTextures)) and a heap's rebind still imports
without asking. A caller's DirtyPages log stays attached to the copy as
to an import. The in-place check's pointer class skips copied buffers.
Ports dev-perf's fff961b7e5, 630d1b0174, 33d7aa5e98 and 9b4d4190f5 onto
a smaller coherence design: every live copy is compared in full at each
commit and completion, instead of dev-perf's log-driven,
encoder-collected copies (dev-perf's copied.rs, 79301a2515 and its
fixes, sat on a page log development has replaced). Also brings
789fa3d294's unreadable-page rule, 5190983470's lane site, and
1c7d49f788's copied-buffer skip. A driver that refuses the pointer
still fails the call (dev-perf copied there too; not taken). Known gaps
in FAST-PATHS: the compare costs O(size) per commit and completion, a
byte both sides wrote keeps the CPU's value, and a shared event's value
can be seen before the merge (c5db2d1b8a not ported). RUNTIME_VERSION
1690. Runtime-sources pin recomputed.
Public API: ImportGate, ImportRequest { start, length }
(#[non_exhaustive]), HostMemory::with_import_gate,
Degradation::CopiedHostPages, Device::fail_next_host_imports (test
hook), and the WorkCounts fields host_imports_refused_by_host,
copied_host_buffers_{made,refused,degraded}, copied_copy_in_bytes,
copied_merge_back_bytes, copied_rebind_pages_made, copied_heaps_made.
Verified on the M3 Max (MoltenVK, m2v_gpu): 11 new device tests
(tests::copied_device: buffer, rebind and heap, gate refusal and failed
admitted import, unreadable pages, a heap texture round trip) and 167
tests in the touched device filters pass; the counters move as
expected ([1,1,1,0,0] for a refusal, [0,1,0,1,0] for a failed import)
and the announcement is heard; on a 64 KiB copy 4079 bytes copied in and
4080 merged back for a 4 KiB CPU write and a 4 KiB fill, checked
exactly. Sabotage: ignoring the gate and removing the merge fails the 3
buffer tests; ignoring the rebind gate fails both rebind tests (no heap
sabotage). 249 host tests pass. Workspace clippy plain and
--cfg m2v_gpu, and rustdoc, clean; clippy re-run clean on the landing
merge. Not run on Linux.
|
||
|
|
8c09b7c2c0 |
Link a warm render creation from its recorded stages, and key the shader cache by its translator
A warm render state creation spent most of its own time in Device::render_variant_key, decoding and specializing every Function stage's AIR to learn its stages' compile keys, because the directory's variant record named only the pipeline's key and a sweep stores no pipeline artifact where the directory holds its stages. The record (v2: new tag and magic) now also names the stages' function compile keys (VariantStages); a creation that finds the record but not the pipeline finds the functions by those keys alone (Sources::found_function: memo, archives, disk, no translation) and links them (RenderVariant::link), decoding nothing. Every creation writes its record. The keys are valid exactly as long as the pipeline key beside them. (Ports dev-perf f4d864d160; development's lookup has no warm-pass Prior/Found and no fit_render_variant, and the bench it extended is gone.) The shader cache's build directory was named by the runtime's version, both artifact versions, the translator's SOURCE_DIGEST and the runtime's own source digest (its build.rs over every file under src/, tests included), so any runtime edit started the cache cold. Every translated entry is the translator's answer for the inputs its key and profile hash, so the runtime's digest goes (with build.rs, its sha2 build-dependency and the validation fingerprint's reference to it). The translator's SOURCE_DIGEST stays, as its doc promises: an unbumped translator change still starts afresh. The runtime's own creation records (linked-use answers, reflection, variant record) are runtime logic, so their names now hash RUNTIME_VERSION with their tag and key (creation.rs record_name): a runtime change that bumps it reads none of an earlier runtime's records. (Ports the idea of dev-perf db5f5baa73, narrowed: no per-entry stamp, no other_build_hits, no public API change.) Not ported from the same area: dev-perf's pipeline-record hook and Device::warm from an earlier process's records (14df1fb5fe, 66fe0ada29; ~3,200 lines on per-entry stamps this packet does not take). Verified on the M3 Max (MoltenVK): 84 device tests of the shader cache, creation, render-stage, sibling-work, archive and pipeline areas pass; the guard a_second_device_links_a_recorded_sweep_with_no_stage_decoded fails with the recorded-stage link disabled ((decoded, translated) = (2, 0)) and passes with it; a_creation_record_of_another_runtime_version _is_not_found passes. Release render-pipeline-split, integer-vertex-attributes, one run: warm processes decode 2 stages before and 0 after; cold counts identical; wall within run-to-run spread on this case's small shaders. Clippy (plain and --cfg m2v_gpu) and rustdoc -D warnings clean; 43 + 241 plain runtime/translator tests pass. No version bumps. Runtime-sources pin recomputed. |
||
|
|
04f6fb57b8 |
Read a half by UnpackHalf2x16 and narrow one by the bare quantize without float16
One work packet, landed as 4 commits (91d9e38f75..80ca8d6abd on archive/development-linear-2026-10-28), in order:
* Read a half by UnpackHalf2x16 and narrow one by the bare quantize without float16
On a device with 16-bit storage but no shaderFloat16 (QuantizeForm::Device: Pascal, the
lunarg-2023 baseline, vk12-floor, SwiftShader), the GPU's native arithmetic is the contract
(AGENTS.md rule 1), so neither the read nor the narrowing of a `half` emulates Metal's bits any
more:
- A `half` read from its bits (a load, a reinterpretation, a texel's or snapshot's bits, a
vertex fetch) is GLSL.std.450 UnpackHalf2x16 of the bits as the low half of a 32-bit word
(component 0), or of both halves for a pair (`narrow::from_bits`, `from_word_halves`). The
exact integer decode (`half_bits_to_f32_bits`) is deleted: UnpackHalf2x16 is core and needs no
capability, so no device lacks a native form. The module records NativeNanEncoding (a NaN's
bits) and NativeHalfConversion (the widening is neither under DenormPreserve 16 nor measured,
so a denormal may flush), by the rules 860ad1489f set for the float16 widening;
`narrow::widens_bits` counts the unpack.
- Every narrowing to `half` through `narrow::round` (fptrunc, every `half` operation, function,
sum, multiply-add, mix step, division, square root, dot, simd and matrix reductions, stage I/O,
color and fetch narrowing, texel rounding through `round_texel`) is the bare OpQuantizeToF16,
recorded NativeHalfQuantize on every such device, measured or not. The denormal arm (quantize,
compare, RoundEven of x * 2^24, select) and `device_round`, `scaled` and
`flushes_below_normal` are deleted; `native_rounding(form)` now depends on the form alone, so
`native_half` holds on every Device-form module. `round_integer` stays exact: it is the
workaround for NVIDIA 615.71.09 keeping an integer conversion unrounded under the quantize.
- No module requires VkProperty::MetalHalfQuantize any more (compile.rs drops the requirement);
DriverDeviation::MetalHalfQuantize and the property are kept and documented as measuring only.
Devices with shaderFloat16 are unchanged.
Integer roundings to `half` that never took `narrow::round` are unchanged: the extended-range
blend's `half_of` (every form but the controlled one), the extended-range color encodes, the
sampler's level and the bicubic routines (Metal's directed roundings among them), and the texture
routine's grid families, which round an integer code's ratio.
Docs: PrecisionNote's NativeHalfConversion, NativeHalfQuantize and NativeNanEncoding, the
runtime's declarations of the three, docs/API.md section 9 and docs/HOWTO.md state the new reach;
`fetch.rs`'s `half()` no longer says "exactly". SEMANTICS_VERSION 1886 -> 1887. The runtime
sources change in doc comments only, so RUNTIME_VERSION stays; the runtime-sources pin moves.
Tests (the arith interpreter harness now builds in QuantizeForm::Controlled unless a body sets a
form, so routine references stay Metal's; a half NaN through the device's widening is accepted as
a NaN, the interpreter's widening being canonical):
- `narrow::device_half_rounding_is_the_quantize_alone`, `engine_native_half::
a_half_below_the_smallest_normal_takes_the_devices_quantize` and `engine_arith::
a_half_rounding_without_float16_is_the_quantize_alone`: no RoundEven or compare after the
quantize, NativeHalfQuantize on every Device profile, sums and narrowings below 2^-14 answer
the signed zero on the interpreter. Negative control (the denormal arm restored in `round`):
all three fail, and `half_rounding_follows_the_operation`.
- `narrow::a_half_decode_is_the_devices_widening_in_every_form` and `engine_native_half::
a_half_read_from_memory_is_the_devices_widening_on_every_profile` and the loop decode test: one
UnpackHalf2x16 per word, no 16-bit type, no integer decode, NaN and conversion notes. Negative
control (the integer decode restored in `from_bits` and `from_word_halves`): all three fail.
- The texel tests accept the quantize's signed zero for a half denormal in the Device form; the
16-bit grid comparison runs the Device form under native rounding only (its one production
setting); the wide tests validate on vk12-floor in its own form.
Verified on this Mac (no GPU): cargo nextest -p metal2vulkan -p metal2vulkan-runtime
-p metal2vulkan-air -p metal2vulkan-devtools --all-features: 5014 run, 5013 passed, the one
failure golden_hashes_match_the_table (hashes moved; not re-blessed here). cargo clippy
--workspace --all-targets --all-features -D warnings, plain and with --cfg m2v_gpu; cargo doc
-D warnings for metal2vulkan and metal2vulkan-runtime. Every fixture below translated with
spirv-val (vulkan1.2, vulkan1.4) passing.
Words (instructions), the CLI on the public engine fixtures, before -> after:
hfb_filter_bank (fragment) Pascal 198141 -> 147460 (38283 -> 28981)
lunarg-2023 176378 -> 124545 (34510 -> 24920), same on
swiftshader and vk12-floor
unm_contract_chain Pascal 46258 -> 34491 (9333 -> 6952)
lunarg-2023 48303 -> 36536 (9699 -> 7318)
swiftshader, vk12-floor 48364 -> 36597 (9928 -> 7547)
fmx2_contract_fast Pascal 24177 -> 18912; lunarg-2023 25107 -> 19842
a1_half_denormals Pascal 4230 -> 3071; lunarg-2023 4353 -> 3194
hwd_half_reads Pascal 2647 -> 2194; lunarg-2023 2688 -> 2235
dsm_half_live_built Pascal 6782 -> 5988; lunarg-2023 6799 -> 6005
sum_regroup unchanged (Pascal 1047, the others 879)
* Hold the native half lanes to each rounding's bound, and bound the quantize's flush by its input
On SwiftShader (no shaderFloat16, so every half narrowing is the bare OpQuantizeToF16) two
native_maths lanes broke the note they check:
- half_rounding_answers_within_its_recorded_bound held half(a) + half(b) to one ulp of Metal's
sum, but the note bounds each rounding: SwiftShader's quantize rounds toward zero, so two
roundings land two ulps off (thread 30: -45.0625 for Metal's -45.125; failing on development
too), and a flushed denormal operand moves the sum by itself. The sum is now held to the bound
of the sum of operands each rounded within it (half_within_sum).
- native_maths_answers_within_its_recorded_bounds held a half fma below 2^-14 to one ulp; where
the stage records NativeHalfQuantize or NativeHalfConversion, the zero of its sign is the
note's bound.
The quantize tests the value it rounds, not the rounded result: SwiftShader answers -0 for
-6.1005354e-5, which Metal rounds to -2^-14. PrecisionNote::NativeHalfQuantize, the runtime's
declaration, docs/API.md (its section 9 entry and the device-answers paragraph, which still said
the widening was the device's only with shaderFloat16) and docs/HOWTO.md now bound a value below
2^-14, not a result, and the lane tests the input.
Verified: scripts/linux-gate --icd swiftshader, runtime_lane::(driver_deviations|half_|
native_maths|sum_regroup|math_routines): 26 run, 22 passed. The four failures fail identically
on development 60fe70fb12 without this branch (sum_regroup 3863 of 4096 pixels, RG11B10 small
floats 2005 of 71505 fields, the slice NaN lane's 17 stored halves, 86 and 484 float NaN words),
so they are SwiftShader's, not this change's; development there fails six, among them
half_loads_the_device_widens_answer_as_metal, which passes here. The same lanes on lavapipe:
26 of 26. clippy -p metal2vulkan-validation --all-targets --all-features --cfg m2v_gpu
-D warnings; the runtime's degradation catalogue tests.
* Number SEMANTICS_VERSION 1889, after development's 1888
The half read and narrowing change (91d9e38f75) bumped SEMANTICS_VERSION, and each rebase onto
development took development's own bump for it (1887 for the MoltenVK vertex fetch, 1888 for the
blend sweep's one compile), so this change shared a number with another. 1889 keys its modules
apart: Device-form modules read a half by UnpackHalf2x16 and narrow one by the bare
OpQuantizeToF16, with their precision notes.
Verified on the rebased tree: the core suites, clippy plain and --cfg m2v_gpu (see the change).
* Re-pin the runtime sources at the landing tip
The landed packet changed a runtime-sources input, so the committed digest no
longer described the sources and `the_runtime_sources_are_the_committed_ones`
would fail. Recomputed over the same inputs and committed by land-pkt.sh.
|
||
|
|
a3c550ca33 |
Read a half from memory by the device's widening, and sum one by its quantize
One work packet, landed as 3 commits (860ad1489f..46ec3ad81f on archive/development-linear-2026-10-28), in order: * Read a half from memory by the device's widening, and sum one by its quantize The owner's ruling on native half arithmetic, applied to the reads and sums that still emulated Metal's bits. A half read from memory or from its bits is the device's widening wherever the module holds 16-bit floats (every QuantizeForm but Device, i.e. every profile with shaderFloat16): the bits read as f16 (an OpBitcast of the word or words, a 16-bit storage unit read as a half itself) and one OpFConvert, with no use analysis. The module records NativeNanEncoding (the widening's NaN bits are the device's; a half stored unchanged keeps its bits through the noted bits). Its denormals are kept under the 16-bit float controls (ANV, RADV: DenormPreserve), read as Metal's by the measured MetalHalfArithmetic on MoltenVK (the module then requires the property), and elsewhere (NVIDIA, lavapipe) may flush, recorded as NativeHalfConversion. Without shaderFloat16 the integer decode stays: no 16-bit float type exists to read the bits as. The use analysis (lower/arith/widening.rs), ModuleBuilder::set_widens_halves, the loop-free offers it fed and the UnpackHalf2x16 decode are deleted. A half sum or difference (and the mix, muladd, fract and sqrt results that round the same way) takes the device's rounding alone (narrow::device_round): on a device without shaderFloat16 the bare OpQuantizeToF16, whose result below the smallest normal half may be a zero, noted NativeHalfQuantize whether or not the quantize is measured (narrow::flushes_below_normal). round_exact_below_normal is deleted. An integer's half stays exact (round_integer), documented as the workaround for NVIDIA 615.71.09 keeping an integer conversion unrounded under OpQuantizeToF16. SEMANTICS_VERSION 1883 -> 1884. The runtime-sources pin moves for doc comments only (device/driver_facts.rs, device/requirements.rs), so RUNTIME_VERSION stays. The golden hash table moves (2704 cells) and is re-blessed on development, not here. API signatures and REFUSALS.md are unchanged. Words (instructions) of the release command line's output, before -> after: hfb_filter_bank NVIDIA 5080 159876 -> 147962 (31488 -> 29438), lavapipe 160444 -> 148530, MoltenVK 153283 -> 148284, ANV 164906 -> 159903; unm_contract_chain NVIDIA 34516 -> 33048 (6985 -> 6769), MoltenVK 35366 -> 33666; fmx2_contract_fast NVIDIA 18983 -> 18272; sum_regroup pascal 3356 -> 3286, vk12-floor 2506 -> 2436. Every module passes spirv-val. Verified: the core suites (metal2vulkan, -air, -runtime, -devtools): 5056 of 5057 pass, golden_hashes_match_the_table the one failure (moved hashes, as above); a touched-test pass of 318 in metal2vulkan and the validation crate, the runtime pin included; clippy -D warnings with all features, plain and with --cfg m2v_gpu. New tests fail without the change (checked for the 16-bit unit read by disabling its note). Device lanes on lavapipe follow. * Re-pin the runtime sources at the landing tip The landed packet changed a runtime-sources input, so the committed digest no longer described the sources and `the_runtime_sources_are_the_committed_ones` would fail. Recomputed over the same inputs and committed by land-pkt.sh. * Re-bless the golden table after the half reads' native widening 860ad1489f reads a half by the device's widening on every shaderFloat16 profile and sums one by the bare quantize elsewhere, so 288 rows' cells moved. bless_engine_inventory, bless_golden_hashes and bless_engine_goldens at 9ac9892868; public_fixtures_engine, air_input and golden_hashes: 28 passed. |
||
|
|
e87d6e558f |
Drop the exact read of a 16-bit float texel's own bits
One work packet, landed as 6 commits (b07aaeec71..ffa0751e77 on archive/development-linear-2026-10-28), in order:
* Drop the exact read of a 16-bit float texel's own bits
The owner's ruling of 2026-10-27 ("just promise the GPU's native
arithmetics, no more 'exact' emulation") makes the device's decode of a
16-bit float texel the only answer a `half` or `float` read gives. So
`DevicePolicy::half_texel_bits` and `HalfTexelBitsPolicy` go, with
everything only its `Exact` value reached:
- the slot's second binding of the texture's unsigned-integer alias
(`RuntimeFact::HalfBitsTexture`, `metal::format::half_bits_read_view`,
`DeviceProfile::reads_half_texel_bits`), its declaration, the read's
branch on the bound class and its integer widening;
- the snapshot copy's alias arm and the read's codes beside the value;
`snapshot_copies_alone` now expects the copy's one fetch a slot;
- the binder's alias view and its in-shader swizzle for it, and the
runtime's alias view format on a sampled image;
- the fit's `half_texel_bits` field of `ExactFormsOverCompilerLimit`
and the runtime's name for it.
The read keeps the device's decode and its `DeviceNanEncoding` note.
The `StorageImageClass::HalfBits` storage path is untouched. Tests of
the deleted form go (`engine_half_texel_bits`, the snapshot alias and
swizzle tests, the golden check of the copy's arm); the ledger row goes,
and the conformance gap rows' reasons no longer cite the switch.
SEMANTICS_VERSION 1872, ARTIFACT_FORMAT_VERSION 455 (a RuntimeFact
variant and a field gone), RUNTIME_VERSION 1653.
Verified: cargo clippy --workspace --all-targets --all-features
-D warnings clean; nextest over fast_paths, catalogue, degradation,
profile, mechanism, compile::fit, engine_snapshot_exact,
engine_srgb_raw, engine_swizzled_storage, snapshot_codes, codec and
image_plan (276 tests) passed. api_signatures is re-blessed at the
lane's end.
* Drop the shader's exact 16-bit float blend of a half output
The owner's ruling is to promise the GPU's native arithmetic, so the
`half_blend` switch (`HalfBlendPolicy`) goes. Under its exact value the
pipeline named a blended 16-bit float attachment of a `half` output, and a
32-bit float one of a four-lane output under fast math, for the interlocked
storage form alone (`FramebufferFetchInputs::half_blends`), so the shader
computed Metal's blend where the device would otherwise blend. That path
is gone: `compile::blended_in_shader`, the `half_blends` set and its
"optional" handling in the fetch lowering, `fetch::blends_half_in_shader`,
`half_output` and `half_blend_attachment`, the policy field, the profile
field and the fit's `half_blend` flag in
`RuntimeFact::ExactFormsOverCompilerLimit`.
Kept: a fetched attachment's blend (the function reads it, so no Vulkan
blend applies) and an attachment a draw moves into the storage form
(`VariantKey::interlocked_colors`), both capability. `HalfOutputPrecision`
still describes the device's blend and is recorded as before; with no
switch it is no fast-default row, so the ledger test classes it with the
notes docs/API.md section 9 states. The ledger's `half_blend` row goes,
and the device-gap rows no longer cite it.
Tests of the exact form go (`engine_fetch_float32_reach`, two
`engine_stage_io` tests); the validation lane `half_output_blends` runs
under the device's blend alone, and `corpus-draw-ab --policy` no longer
takes `half_blend`.
Verified: cargo clippy --workspace --all-targets --all-features -D
warnings clean; nextest of engine_stage_io, compile::fit, fast_paths,
device::tests, pipeline::api_tests, lower::fragment, catalogue,
degradation, fitted_variant_notice, api_surface and link render tests
(246 passed), and of every fetch, blend, interlock and half_output test
(199 passed). Golden tables not run (re-blessed on development).
* Round half by the device's own conversion or quantize
The owner's ruling is that the GPU's native arithmetic is promised, with
no exact emulation. This deletes the half_rounding switch
(HalfRoundingPolicy, ProfileFields::half_rounding, HalfRoundingRoute)
and everything that only its Metal value reached:
- QuantizeForm::Integer: Metal's rounding to half by integer arithmetic,
its texel routine arms (grid16_by_integers), round_texel_plain and
texel_round's f32_to_half_by.
- The NoContraction barrier on the conversion pair, and the
MetalHalfConversion requirement it carried.
A half now rounds by the device's form:
- Controlled: the float-controls route (ANV, RADV), unchanged.
- Converted: the device's conversion pair, wherever the profile has
shaderFloat16. It records NativeHalfConversion, MoltenVK included.
- Device: OpQuantizeToF16 with its denormal arm, which becomes the
QuantizeForm default. It records NativeHalfQuantize unless the driver
is measured as Metal's (MetalHalfQuantize).
A Converted module reads a half from its bits by the device's widening,
MoltenVK now included. The tests that held a NaN's bits there now accept
any NaN where the module records NativeHalfConversion: engine_access,
engine_half_moves, engine_typed_threadgroup and engine_texel_nans.
The integer conversion of an int to half, and the integer decode inside
loops and on profiles without shaderFloat16, stay: they have no native
form with a recorded bound.
Docs:
- FAST-PATHS.md: the three half_rounding rows are deleted.
- API.md: the degrade catalogue entries are rewritten without the
switch.
- HOWTO.md: the half paragraph is rewritten.
Tests: deleted the integer-form tests, and rewrote the engine_native_half
and engine_arith half-rounding tests to the device's forms.
SEMANTICS, ARTIFACT_FORMAT and RUNTIME versions were already bumped to
this lane's reserved numbers.
Verified:
- cargo clippy --workspace --all-targets --all-features -D warnings,
plain and with --cfg m2v_gpu: clean.
- cargo nextest over half, narrow, texel_round, lower::arith,
engine_arith, engine_sampler, engine_link, fast_paths, device::tests,
compile::fit, catalogue, degradation, fitted_variant_notice,
api_surface, engine_texture, lower::texture and engine_snapshot
(939 tests): the 11 failures were fixed, and the 161 tests they touch
re-run green.
* Take the device's float Fma for a half fused multiply-add
The owner's ruling is that the GPU's native arithmetic is promised, with
no exact emulation. Where neither MetalHalfFma (the device's 16-bit Fma
measured as Metal's) nor a 16-bit OpFmaKHR under the float controls is
offered, a half fused multiply-add used to call Route::HalfOdd. That is
the translation's round-to-odd routine of Metal's once-rounded answer;
off MoltenVK it was taken only under FloatMathsPolicy::Exact. It now
takes Route::Native under every policy: the device's float Fma, its
result rounded to half, noted NativeFma.
Removed: Route::HalfOdd, its census name (arith.fma.half), its define,
emit, words and routine arms, and half_form. Routine::words,
Routine::words_among and complete no longer take the quantize form, now
that no routine holds a half rounding. half_sum stays, since the
extended-range blend uses it.
Docs: the fma module docs, the narrow docs, NativeFma's and
DeviceSignedZeroInfNan's docs, their API.md catalogue entries, the
runtime NativeFma declaration, and the FAST-PATHS float-maths row's
mention of the half routine.
Tests:
- The HalfOdd rounding test becomes a test of the two 16-bit routes.
- The mix and dot half tests run through F16Khr.
- The route, words and lane-count tests drop HalfOdd.
- The engine_arith fma, zero-sign, chain and denormal-rounding tests
expect the inline device Fma, and NativeFma within one half ulp.
Verified:
- cargo clippy --workspace --all-targets --all-features -D warnings,
plain and with --cfg m2v_gpu: clean.
- RUSTDOCFLAGS='-D warnings' cargo doc --workspace --all-features
--no-deps: clean.
- cargo nextest over lower::arith, engine_arith, engine_simd, engine_agx,
lower::sampler::face, fast_paths, catalogue, degradation, api_surface,
engine_native_half, engine_extended_range, fused and fma (938 tests):
935 passed. The three engine_arith failures were fixed, and
engine_arith re-ran 43 of 43 green.
* Bless the public signatures after the half switches' removal
These are the public items lane C's commits removed:
- HalfRoundingPolicy, HalfBlendPolicy and HalfTexelBitsPolicy, and
their variants;
- FramebufferFetchInputs::half_blends;
- metal::format::half_bits_read_view;
- DeviceProfile::reads_half_texel_bits;
- RuntimeFact::HalfBitsTexture.
RuntimeFact::ExactFormsOverCompilerLimit also loses its half_rounding,
half_blend and half_texel_bits flags.
docs/REFUSALS.md re-derives unchanged: no refusal changed.
Verified:
- signatures.py --check: clean.
- cargo nextest of api_signatures, api_surface, fast_paths, catalogue,
degradation, device::tests, compile::fit, fitted_variant_notice and
published_crates: 171 of 171 passed.
- scripts/api-docs: clean.
* Re-pin the runtime sources at the landing tip
The landed packet changed a runtime-sources input, so the committed digest no
longer described the sources and `the_runtime_sources_are_the_committed_ones`
would fail. Recomputed over the same inputs and committed by land-pkt.sh.
|
||
|
|
675a3ee122 |
Take sampled textures over host pages in place where the device's check passes
One work packet, landed as 2 commits (86ec320bae..8485bc6865 on archive/development-linear-2026-10-28), in order:
* Take sampled textures over host pages in place where the device's check passes
A 2D texture (or array) over host pages is now a linear image aliasing those pages, with no shadow,
when all of these hold:
- its declared usage only samples or reads it (no RenderTarget, ShaderWrite or ShaderAtomic);
- the pages are a no-copy buffer's, imported by their pointer or as dma-bufs, or a buffer the
runtime placed in fresh pages;
- a startup check shows that, on this device, the image's first move keeps every byte while the
CPU writes beside it.
Vulkan makes such an image start UNDEFINED (VUID-VkImageCreateInfo-pNext-01443) and lets the move
read and write every byte bound to it. Relying on the driver here, once checked, is the owner's
ruling ("In place, trusting the driver"): a deliberate, scoped exception, recorded in FAST-PATHS.
The switch is DevicePolicy::host_page_textures:
- HostPageTexturePolicy::InPlace is the default.
- HostPageTexturePolicy::Shadow is the exact form, which exact_answers() selects. Under it every
such texture stays a shadow and no check runs.
The check (in_place_check.rs):
- It runs on a thread of its own, started by the first texture that asks, per class of pages:
pointer imports, fresh pages and dma-buf imports. On a Unix target the dma-buf class uses an
exported allocation of the device's own.
- Each class tries 11 shapes, 3 rounds each, through the product's own Buffer::new_texture:
- packed rows of 1, 2, 4, 8 and 16-byte texels;
- rows with bytes between them, for the same texel sizes;
- one 3840x2160 surface.
A shape the device makes no image of is skipped, as the product makes none either.
- A writer thread writes the pattern's complement through texels, the bytes between rows and the
bytes after the image while the move runs. Every byte is then compared.
- The pattern is a 4099-byte prime period, so it lines up with no row, page or texel. The window
is filled by copies and compared written bytes first, then a period at a time. That makes the
33 MB surface cost about 11 ms a round in release.
The verdicts are kept as one record in the shader cache's content store:
- The record is named by vendor, device, driver ID, version, name and info, the UUID, the check's
kind and version, and RUNTIME_VERSION.
- It is checksummed. A bad, partial or other-version record counts as none: the check reruns and
overwrites it.
- With no cache directory, the check runs once per process.
- A forced failure (DeviceOptions::fail_in_place_check, a hidden test hook) keeps nothing.
Every texture that still takes a shadow announces why (shadowed-texture) and is counted by cause:
- the policy;
- usage that renders or writes;
- check pending, failed or unchecked;
- refused: rows, detached, image, pitch, placement, the dma-buf source, other dma-buf reasons.
WorkCounts also counts the in-place textures by class and pitched images, and the check's runs and
verdicts.
How an image in place is made, used and visible:
- Pointer and fresh pages take a linear image made for host allocations at Metal's pitch, or a
DRM_FORMAT_MOD_LINEAR image at an explicit pitch over the host allocation where the driver makes
one. Dma-buf pages take the modifier image over a dma-buf of the texture's own pages.
- A rebind remakes these images like the others.
- A write or pass beyond the declared usage goes through the existing usage shadow and attachment
stand-in.
- A CPU write reaches the image's commands as it reaches the buffer's (Host Write Ordering
Guarantees).
RUNTIME_VERSION 1643 -> 1644. The runtime-sources pin is left for the landing.
Check duration, Apple M3 Max on MoltenVK 1.4.2:
- 75-78 ms in release: Pointer and Fresh passed; DmaBuf unchecked, as there are no dma-bufs on
macOS.
- 1.76 s in a debug build.
- The first version took 4.1-4.2 s in debug, almost all of it the 3840x2160 shape's per-byte
hashed fill (240 ms) and compare (461 ms) per round, times 3 rounds and 2 classes; the GPU move
itself took 0.15-3 ms.
- Nothing was dropped from the check. The 64x64/256 shape became 64x16/256, and packed shapes of
each texel size were added, because MoltenVK takes no padded pitch: the first version made only
4-byte images there.
Verified on the M3 Max (debug lanes, --cfg m2v_gpu):
- in_place_textures, all five tests:
- the path follows the check, and an event-held CPU write after the commit is read;
- a kernel write and a pass beyond the usage go through their shadows and keep the image;
- a forced failure keeps the shadow and no record; the next device runs the check, and the one
after recalls three verdicts and checks nothing;
- the costs.
- first_use_writes under both settings: 1920x1080/7680 in place, 0 of 542 writes undone.
- no_copy_textures read/write under both settings: ShaderRead-only textures in place at packed
rows, the rest shadows.
- pitched_surfaces, including the new _in_place variants of the only-reads and read-only-pages
tests.
- The runtime and translator suites passed (4971 tests), with clippy plain and under --cfg m2v_gpu.
Cost on the M3 Max, release, median GPU time per command buffer, in place against shadow:
- 3840x2160, one pass reading a 32-row strip: 492 against 553 us.
- 1920x1080 strip: 457 against 452 us.
- 1920x1080 whole: 393 against 466 us.
- 1920x1080, three whole passes: 566 against 545 us.
Untested here: RADV, lavapipe and the dma-buf class, which follow; ANV and NVIDIA have no venue
now.
* Re-pin the runtime sources at the landing tip
The landed packet changed a runtime-sources input, so the committed digest no
longer described the sources and `the_runtime_sources_are_the_committed_ones`
would fail. Recomputed over the same inputs and committed by land-pkt.sh.
|
||
|
|
a73af4db0b |
Keep one driver pipeline cache per record, named by what converts a stage
The steps this packet landed as, in order: - Read the records lane's files only once the device that wrote them is gone Content: the tree of `development` at fdf4232b79, unchanged. |
||
|
|
fc63e360fa |
Count the render and the dispatch pipeline predictions apart
The steps this packet landed as, in order: - Write a creation's shader cache entries on the device's cache thread Content: the tree of `development` at 1ff199a2eb, unchanged. |
||
|
|
787d92fdc2 |
Answer a heap texture's allocatedSize from the place that holds it
The steps this packet landed as, in order: - Answer a kept heap texture requirement before asking the device's limits - Answer whether a command buffer or submission uses given objects, cloning nothing - List devices' registry IDs without making devices, and open one by its ID - Give a made pipeline state's reflection from its compile, after its creation - Enable optional device extensions where each device can, and say which it enabled - Let a caller vouch for its host pages' write permission, skipping the kernel's answer - Import read-only host pages from the caller's dma-buf source, and say whether a device takes shared pointers - Hold a texture of Apple's private usage 0x8 alone to what Metal does with it - Measure RADV 26.2.4 on the RX 7900 XTX: its pointer imports follow their address - Free a no-copy buffer's dma-buf imports before its keep-alive goes - Measure a file's pages mapped under a live RADV pointer import, a known gap - Let what waits for a dma-buf import's free go as its fields drop Content: the tree of `development` at 0a38130573, unchanged. |
||
|
|
b253a0ad98 |
Convert a two-plane YCbCr texture only where its planes changed since the last conversion
Content: the tree of `development` at b3c5e804ad, unchanged. |
||
|
|
e841dd6b4a |
Read the Radeon 780M of Hawk Point as the measured Phoenix 780M, with its own device profile
The Radeon 780M of Hawk Point (PCI device 0x1900) takes the driver facts measured on the Phoenix 780M (0x15bf), the same GPU, and gets its own committed device profile. Folds in: - Read the Radeon 780M of Hawk Point (0x1900) as the measured Phoenix 780M (0x15bf) Verified by each folded change's own checks; the tree this series ends on is the one verified at the tip on six GPUs, the CPU suites and lint (see the tables commit). |
||
|
|
b660f64e17 |
Copy equal rows between buffers as one dispatch on ANV and the RTX 5080 Laptop, and split long copy regions
A copy of rows between two buffers whose rows lie apart is one vkCmdCopyBuffer with a region per row, and ANV records each region as a blit operation of its own. In a guest frame's profile on the Iris Xe one such copy a frame took about 15.7 of the recorder thread's 19 ms. ANV's recording time for a single region also grows with the region's size at some sizes: one two-plane YCbCr texture's planes copied into its staging buffer cost about 15 ms of the recorder's time a frame. Row copies: - Every copy of rows between buffers goes through one place, row_copies.rs (RowCopies): a blit between a buffer and a texture over a buffer or between two textures over buffers (through its overlap scratch too), a buffer-texture copy's rows through its staging buffer, and every shadow's copy back out of its staging buffer, wherever it records: a render pass's steps between instances and before tile dispatches, a rotated texture's store, and a heap's two-plane and tiled textures' copies back. - RowCopies makes the copy one dispatch of the new translator kernel bind::rows_copy_module (RowsCopyModule) where the device is measured to run it faster (new DriverFact::RowCopiesDispatchFaster), the copy has 2 or more regions of the same size in whole 4-byte words, 4-byte aligned, evenly spaced with destination rows at least a row apart, and it fits the device's storage buffer range and workgroup counts. Invocation (x, y) stores word x of source row y at word x of destination row y and writes nothing else, so the bytes are the copy's. Every other copy stays regions. The kernel's set 0 is pushed through the device's checked push command where VK_KHR_push_descriptor exists, else allocated from a pool the command buffer keeps; the callers name the dispatch's accesses so the tracker orders it. - The fact holds on ANV (Mesa 26.2.4, keyed on the driver, so it covers the measured Iris Xe and UHD 770 identities) and on NVIDIA 615.71.09 on the RTX 5080 Laptop GPU. RADV is not listed: its GPU time rose 3 to 5% at 1080 rows. Long copy regions: every vkCmdCopyBuffer the runtime records goes through Vk::cmd_copy_buffer, which records each region over 16 KiB whose size is no multiple of 4 KiB as two regions of the same command, its bytes up to the last whole multiple of 4 KiB and the rest. The same bytes are copied by the same command, so the split is exact on every device and is not keyed to a driver; five helpers that recorded copies through a bare ash::Device now take the device's functions. Counters: WorkCounts::row_copies, row_copy_regions, row_copy_regions_most, row_copies_dispatched, copy_regions_split, and copy_sites, which names the places in the runtime that recorded buffer and image copies with their calls and regions (the device's checked functions record them through #[track_caller] methods). The runtime re-exports CopySite. Docs: docs/HOWTO.md's copies section, row_copies.rs, device/functions.rs, WorkCounts. Verified, as the commits state: - runtime_lane::row_copies::row_copies_cost (release, one blit a frame of 1920 BGRA8Unorm rows into rows 8192 bytes apart): 1080 rows on the Iris Xe CPU 3.1-3.3 -> 0.28-0.40 ms and GPU 5.3-7.8 -> 1.13 ms; on the UHD 770 CPU 0.77-0.83 -> 0.04-0.11 ms and GPU 3.3-5.3 -> 0.59-0.91 ms; on the RTX 5080 Laptop GPU 2.03-2.05 -> 0.42-0.43 ms. - rotated_textures::rotated_surface_frame_costs (1920x1080 BGRA8Unorm, release, UHD 770): rotation 1 clear+draw 4.41/4.43 ms against 7.24-8.24 ms, rotation 2 3.59-3.88 against 5.11-5.73 ms. - span_copy_cost on the UHD 770: one region of 8,294,411 bytes recorded in 0.018-0.020 ms against 28.4-35.1 ms, its GPU time 0.64-0.66 against 5.97-5.99 ms; the YCbCr frame 2.89-2.98 against 6.80 ms of GPU. On RADV and NVIDIA the split recorded in the same CPU time and ran within about 10 us of GPU time where one region was already quick, and faster where it was not (8,294,411 bytes on the RTX 3090: 1520 against 6051-6061 us). - Copy lanes with every byte checked under the validation layer (rows between buffers, a shadow's staged rows going back as one dispatch, blits of textures over buffers, textures over bytes past their VkBuffer) pass as dispatches on the UHD 770 and the RTX 5080 Laptop GPU and as regions on lavapipe; the rotated, tile-shadow, two-plane heap and heap-layout lanes pass on the UHD 770 with each rotated store's rows going back as a dispatched copy of rows. long_copies_of_any_size_copy_metals_bytes (prime sizes and offsets) passes on the UHD 770, the RX 7900 XTX, the 780M and the RTX 3090, and the YCbCr, blit, pitched-surface, no-copy, first-use, fill and frame-cost lanes pass on the UHD 770. - tests::exit_guard::only_the_listed_modules_keep_the_device_s_functions (the push goes through the checked functions), bind::rows_copy, the driver_facts tests, owned_divisions, api_surface, and the runtime unit tests named row_copies, work_counts, functions, copy, shadow, first_move and ycbcr; clippy in every configuration and Rustdoc. |
||
|
|
e35bf78bd5 |
Shadow every padded texture over a buffer and every texture over host pages, keeping CPU writes
A texture over a buffer could be an image bound to the buffer's bytes: a padded texture that only read (PaddedReadsPolicy::Alias, the default), and any 2D texture over a no-copy buffer's host pages (a linear image, a DRM_FORMAT_MOD_LINEAR image at Metal's row pitch, or on MoltenVK a Metal texture over the import's MTLBuffer). An image bound to imported memory starts UNDEFINED, and a layout transition "may perform read and write accesses on all memory bound to the image subresource range", so such an image kept Metal's bytes across its first move only through a host keep (read the bytes, submit the move alone, wait, write back what changed), which undid a CPU write made inside that window. Metal keeps every CPU write to bytes a command buffer does not write: on the M3 Max, a kernel reading half a padded no-copy texture while the CPU rewrote the bytes between its rows and its other rows kept every CPU byte in 10 of 10 rounds. Changing bytes in memory is not a precision note, so under the owner's rules it may be neither a default nor a switch; exact is the default, and cost chooses only among exact forms. Now a padded texture over a buffer, and every 2D texture (or array) over a no-copy buffer's host pages, imported by pointer or as dma-bufs, is a shadow on every device, whatever its usage: an optimal image of the runtime's memory, copied in from the bytes before a use and merged back after a write. Texture::vk_image answers None for such a texture. Removed: - DevicePolicy::padded_reads and the enum PaddedReadsPolicy (Alias, Shadow); its FAST-PATHS row, its tests::fast_paths choice and its api_surface row. - The images over host pages: the linear image for host allocations, the DRM_FORMAT_MOD_LINEAR image over host allocations with its refusal memo, the modifier image over a buffer texture's own dma-buf, the Metal texture over the import's MTLBuffer on MoltenVK (VK_EXT_metal_objects is no longer enabled for it), and the one image shared by textures of one plan over one import. - The first move's host keep, and its notice unrestored-first-move-bytes (Degradation UnrestoredFirstMoveBytes), retired. - WorkCounts fields first_move_keeps, first_move_kept_bytes, first_move_restored_bytes, pitched_host_images, pitched_host_image_refusals, pitched_host_image_refusals_recalled, shared_alias_images and shared_alias_moves_waited. Kept: the buffer's dma-buf import as the last resort where the pointer is refused, on any device; the images of heap textures over host pages, including over dma-bufs (a heap resource's contents are undefined until written, in Metal too); a linear image over a buffer of the runtime's own memory (PREINITIALIZED), whose first move FAST-PATHS records as a one-line known gap. ShadowedTexture (shadowed-texture) now also covers read-only padded textures. Also: a staged shadow's copy back merges rows that lie one after another into one region (a packed 1080p surface takes one region, not 1080), and two new counters size what a shadow kept across a command buffer's passes could save: WorkCounts::shadow_attachment_passes and shadow_attachment_textures. Docs: docs/FAST-PATHS.md (the shadow bullet with its costs, the known gaps), docs/API.md (section 1's texture paragraph, the shadowed-texture and dont-care-stand-in entries, the retired code), docs/HOWTO.md section 6, the runtime README, linear_attachment.rs's module doc. Cost, as measured: on the Iris Xe a frame sampling four BGRA8Unorm tiles over no-copy pages took 3.2-5.3 ms as shadows against 3.0-6.1 ms as images (textures made once) and 3.4-7.1 against 4.6-8.6 ms (made each frame). On the UHD 770 (ANV, release, alternated), one Load/Store pass into the guest's 1080p surface took 1.89-1.97 ms as a shadow against 2.56-3.09 ms as the linear alias, whose draws ran slowly in host memory; 12 passes 20.9-21.1 ms against 27.4-27.8 ms, at about 40 us more CPU a pass. Verified, as the commits state: - runtime_lane::first_use_writes (new: another thread writes bytes of a texture over host pages that its first use does not read, from 2 ms before to 2 ms after the commit; every write stays) passes on the RTX 3090, the Radeon 780M and the UHD 770. - runtime_lane::pitched_surfaces asserts a shadow for every surface (counted, vk_image None), including the CPU write beside a padded texture during its first use and the new counters; no_copy_textures asserts a shadow and no modifier queries; the keep, pitch-refusal and shared-image tests go with what they tested. - The lanes restated for the shadows pass whole: dma_buf_imports 13, resource_ids 38, rotated_textures 7 and linear_attachments 20 on the RX 7900 XTX and the 780M (RADV), the UHD 770 (ANV, with row_copies 2) and the RTX 3090. - linear_attachments renders over a Shared buffer of the runtime's memory, so the linear attachment paths stay covered, each test asserting the way its passes took; 21 pass on the RTX 3090, the 780M, the RX 7900 XTX and the UHD 770. - Runtime and validation nextest without a device, 2306 passed; the translator's fast_paths, api_surface, published_crates, refusal and driver_facts tests, 34 passed; clippy in every configuration and Rustdoc -D warnings. |
||
|
|
7db879f242 |
Release idle pointer imports on RADV 26.2.4, and say which RADV host stack loses GPU writes
On the Radeon 780M with RADV (Mesa 26.2.4), idle pointer imports are released where they follow their address, as on the other measured drivers; docs/HOWTO.md says which RADV host stack loses GPU writes under memory churn. Folds in: - Release idle pointer imports on RADV 26.2.4 on the Radeon 780M, where they follow their address - Say which RADV host stack loses GPU writes under memory churn Verified by each folded change's own checks; the tree this series ends on is the one verified at the tip on six GPUs, the CPU suites and lint (see the tables commit). |
||
|
|
3bb4722d9f |
Release idle pointer imports where they follow their address, keep deallocator timing Metal's across rebinds and detaches, and cut host-import work
No-copy buffers and host imports now cost the kernel and the encoding thread less, and their deallocators run in the call Metal runs them in, including when a detach races a commit. What changes: - Idle pointer imports. A no-copy buffer's own pointer import is releasable, as its dma-buf import was: while only blits read it and no pending command buffer holds it, the residency thread releases it after its idle window (2 s, doubling at each import again up to 64 s), and the next blit imports it again at the same pointer. Only where the new measured fact DriverFact::PointerImportsFollowTheirAddress holds (ANV 26.2.4 on the Iris Xe; lavapipe 26.0.8 to 26.2.4): there a pointer import reads the pages mapped at its address at each submission, so an import again reads what the kept one would. A refused re-import fails the blit's call, typed. - Deallocator timing. A released import hands its keep-alive and deallocators to the objects a command buffer still holds, so they run as that memory is freed (or parked and announced, as a kept import's). A committed but unsubmitted command buffer holds a blit's import objects weakly, so a rebind or detach before its first submission runs the deallocator in its call, as Metal does. A detach racing a commit on another thread runs the deallocator in one of the two calls: a let-go mark on the pages and the commit's hold count, both sequentially consistent, make each side see the other, and a commit that sees the mark replays its own command buffer at once. The live list re-reads a buffer's pages where a detach moved them meanwhile. HostDeallocatorDelayed is no longer announced for these races. - Fewer kernel queries. A no-copy buffer asks the kernel about its mappings (PROCMAP_QUERY) only where it makes its own import; a rebind onto a live buffer's bytes lies in that buffer's import and asks nothing; /proc/self/maps stays open for the queries (reopened in a forked process). Three blit paths that read the caller's buffer as a read apart now read it as blits, so their imports stay releasable. - Fewer rewrites and lookups. A rebind or detach rewrites only the heap slots of textures over the bytes it moved; host-page alias lookups visit only the length classes that hold ranges and keep each range's overlapping ranges; a binding and a descriptor each read where a no-copy buffer lies once. - Counters (WorkCounts): host_imports_used and host_imports_read_apart (with its six reasons), host_imports_kept_for_fds and kept imports by cause (of_heap, rebound, pointer, no_stand_in), heap_slots_rewritten, host_mappings_queried (Linux; 0 elsewhere), host_range_lookups, host_remaps_reported, host_remaps_over_imports, host_imports_remapped, host_pointer_imports_made and _bytes_made, no_copy_lies_read, host_imports_rebound_unlisted, host_rebind_imports_made and _covered. - Docs: docs/HOWTO.md on both kinds of release, the RLIMIT_NOFILE soft limit a program raises itself and the new gauges; a FAST-PATHS known gap that a buffer made before a remap reads the new pages on drivers whose pointer imports follow their address, where Metal keeps the old ones (HostMemory::new's contract forbids such a remap); the rustdoc of host_range_remapped. Why: ANV over i915 lists every VkDeviceMemory in every execbuffer, and a pointer import costs about 0.19 us an execbuffer; the consumer's guest keeps hundreds of no-copy buffers live and uses few in a frame. Its swap thread spent 1.54 ms of kernel time a frame querying mappings of a buffer that joined a live import. And a released import's deallocator unmapped pages under a live userptr, losing the device. Verified: - Iris Xe, a guest-shaped lane of 520 pointer imports and 43 command buffers a frame, the idle ones released: objects per execbuffer 536 -> 51, ioctl 4.24-4.31 -> 0.85-1.09 ms a frame, scheduler CPU 4.96-5.05 -> 1.33-1.74 ms a frame, frame p50 5.27-5.43 -> 2.70-3.11 ms. - The fact, probed outside the runtime on the Iris Xe and through tests::pointer_residency on it and lavapipe: a kept import read the pages a remap put at its address. - The detach race on the Iris Xe and RTX 5080 under the validation layer: without the fix 3 of 3 runs failed (deallocators late or on another thread); with it 12 of 12 runs, 15,360 races, each deallocator in the detach or the commit, never late. - A second no-copy buffer over 2040 scattered mappings: 415-418 us -> 0.3-0.6 us. A rebind with 1024 other live textures: 4766 -> 49 us. Alias lookups: a draw -5.3% instructions on host-page frames (RX 7900 XTX). - Device and unit tests: freed_memory, pointer_residency, host_residency, blit_holds, encoder_holds, host_import_counts, host_aliases (up to 45 passed per run); lanes rebinds, rebind_reach, detach, detach_textures, host_memory, no_copy_heaps, dma_buf_imports, draw_work (74 passed on lavapipe, 30 on the Iris Xe for the deallocator fixes). clippy -D warnings (plain, m2v_gpu, m2v_cpu_icd) and rustdoc. |
||
|
|
d485925af2 |
Keep the commit path off the GPU's wake and the scheduler's lock: cached uploads, timestamps at completion, primaries begun ahead
A command buffer's encoding, commit and property reads now make no call that waits for a powered-down GPU or for the scheduler's submission, as Metal's return at once. What changes: - Upload arenas (argument, handle and root tables, constant blobs, neutral buffers, status words) take host-cached, host-coherent system memory (MemoryClass::Shared) instead of write-combined memory, which preferred device-local memory on a discrete GPU. Unified-memory devices are unchanged; a device with no host-cached coherent memory keeps its device-local type. No flush is needed: Vulkan defines coherent memory as needing none, and a submission orders the host's earlier writes. New WorkCounts::upload_chunks_in_device_memory. - The calibration pair that places GPU times on the host clock (vkGetCalibratedTimestampsKHR) is read by the completion turn, not at commit. The placement and its pair cache are unchanged; UncalibratedGpuTimes now says the calibration failed as the command buffer completed. - A completed command buffer's settled spare pool begins one primary ahead on the completing thread, with the spares' lock released and only where no thread waits on the command buffer's gate, so the next command buffer's first encoder records into it instead of beginning one. The pool passes between threads under the spares' lock, which is all vkBeginCommandBuffer's external synchronization asks. WorkCounts primaries_begun_ahead and encoder_primaries_begun_ahead. - A timed command buffer's timestamp slot is reset on the host (vkResetQueryPool, a Vulkan 1.2 required feature the runtime enables) as it takes the slot, so no command buffer the GPU runs resets a query; an adopted device keeps the command resets. WorkCounts timestamp_slots_reset_on_host. - kernelStartTime and kernelEndTime are two atomics beside the command buffer's state, and status and error an atomic and a once-set error published at each transition, so a read waits for no replay or submission and a commit takes no new lock. An Error status always finds its error. - WorkCounts counts the command buffers begun by what they were begun for (encoders, segments, continuations, secondaries, batch work and barriers, kept barriers, internal), printed by frame_costs. - docs/HOWTO.md notes NVIDIA's runtime D3 wake (about 1 s after about 15 s idle) and how a host that wants none keeps the GPU powered; never required. Why: on an RTX 5080 laptop GPU in runtime D3, the first write into device-local host-visible memory after 20 s idle waited 977 ms for the wake, and so did the commit's timestamp read (a commit took 973-977 ms; Metal's returns at once). On ANV a begin clears the command state, 8 to 20 us each, 0.80 ms of the Iris guest's 17 ms frame. And the scheduler holds the state lock through a batch's replay and submission, so a status or kernel-time read waited 60-65 ms behind 131,072 fills. Verified: - RX 7900 XTX, release A/B: encoding-thread CPU 5.27 -> 4.79 ms a frame with cached uploads, the vertex-heavy GPU time unchanged (28.18 -> 28.19 ms); draws_setting_bytes_write_no_device_local_memory fails without the change on the XTX, RTX 3090 and RTX 5080. - RTX 5080 laptop: a frame's commit after 20 s idle 973-977 ms -> 0.02-0.03 ms; the wake is now in the wait, as Metal's commit-and-wait shows it. gpu_times and degrade_notices 27 passed on it and on lavapipe. Host-reset slots saved about 1-2 us of GPU time a command buffer there; neutral on the Iris Xe. - Iris Xe: encoding-thread CPU 4.96 -> 4.62 ms a frame and a pass open 5.71 -> 2.77 us with primaries begun ahead; 95.85 of 97 encoders a frame took one. - runtime_lane::property_reads on the RX 7900 XTX and Radeon 780M fails without the change (reads of 60.3-65.1 ms) and passes with it (longest read 0.022-0.097 ms); on the M3 Max under MoltenVK it passed with 0 slow reads and the commit allocation bound held at 4.00. A new test checks status reads Completed in the completed handler, after the wait and in a deallocator. - Unit tests: spares, gate, exit_guard, gpu_time, completion, command_buffer (up to 218 passed per run); clippy -D warnings (plain, m2v_gpu, m2v_cpu_icd) and rustdoc. |
||
|
|
6b322fb50f |
Cut the cold making of half-heavy shaders on ANV and RADV: controlled half rounding and the device's half widening
On Intel's ANV, CoreAnimation's A2Xghfc fragment shader (313k words) took
about 14 s to make cold, for each of three states. The consumer's x86 macOS
guest stalled with "no completion in 10 s" on its first boot. Native Metal
makes it in 0.48-0.56 s on the M3. brw (Mesa's Intel backend) spends that
time in its register allocator. Its interference build is quadratic in
instruction count, it spills, and it retries several scheduling modes. Most
of its input was our half arithmetic. Two cuts, each the cheaper form, are
taken on ANV and RADV.
1. A half result computed in float rounds through the device's conversion
pair under the float controls (QuantizeForm::Controlled). It replaces
OpQuantizeToF16 plus a denormal arm, about 11 NIR operations per lane.
- The form: an OpFConvert to 16 bits and back, each decorated
NoContraction, in an entry that declares RoundingModeRTE,
DenormPreserve and SignedZeroInfNanPreserve for 16 bits, plus the
modes the device's independence ties to them (ANV: RTE for 32 and 64
bits; RADV: RTE and DenormPreserve for 64 bits). The modes are
declared post-lowering (new ExecMode kinds), and the requirements
carry the FloatControl properties.
- Exact by the Vulkan spec under either HalfRoundingPolicy: conversions
are correctly rounded, and NoContraction forbids folding the pair. No
fact, no note.
- A new DriverWorkaround, HalfConversionPairFolded, keyed on NVIDIA's
proprietary driver, keeps NVIDIA on its previous forms. NVIDIA
615.71.09 on the RTX 3090 folds the pair even under NoContraction and
every mode combination, and the PackHalf2x16 and u16-bitcast forms
fold the same way: 2,231,288,832 of 2^32 narrowings unrounded. A
plain-Vulkan repro gives 16,775,680 of 2^24 unrounded on the 3090 and
0 on ANV.
2. A half read from its bits (a load, a reinterpretation, a texel's bits) is
the device's widening under NanMinMaxPolicy::Native, the default: each
u32 lane is bitcast to f16x2 and converted to 32 bits, in place of a
12-op integer decode. A half texel takes that conversion's NaN (no keep).
- Every non-NaN half is exact by the spec: DenormPreserve covers
"values obtained via unpacking an integer into a vector of values
with smaller bit width".
- A NaN's bits are the device's, recorded as NativeNanEncoding
(native-nan-encoding), now also announced on ANV and RADV pipelines
that decode halves. A half stored back unchanged keeps its bits.
- NanMinMaxPolicy::Exact keeps the integer decode and the keep. There,
every half widened to float answers Metal's 0x7fc00000 for a NaN, as
the M3 does over every pattern from memory, constant memory, selects
and texels.
Where brw's time went, measured on A2X (a2x-s96): after cut 1, 49.6k NIR
operations, of which the rounding pairs were about 10.7k, half decodes from
memory 8.6k and texel NaN keeps 2.6k. The rest was below 5% each.
Exactness probes:
- Cut 1 (candidate half(x) over all 2^32 f32, and half + - * over every
pair): 0 non-NaN mismatches on ANV Iris Xe (Mesa 26.2.4), RADV 780M
(Mesa 26.2.4), and the 780M and RX 7900 XTX (Mesa 26.0.8).
- Cut 2 (every half pattern): 0 non-NaN differences on ANV and RADV.
- The M3 confirms Metal equals the integer reference everywhere.
Cold making (A2X, base against each cut):
- ANV Iris Xe: 13.6-14.3 s, then 5.75-6.16 s, then 4.06-4.36 s. Peak RSS
1.28 GB, then 0.50, then 0.35. GPU time per draw 4.62 -> 4.48 ms.
- RADV 780M: 0.80-0.84 s, then 0.53-0.55 s, then 0.38-0.47 s. GPU time per
draw 4.05 -> 3.43 ms after cut 1, then within its clock states' spread.
In the consumer's cold boots on ms01 (Iris Xe), A2X went from 14 s per
state, plus two 38 s remakes, to 4.0-4.3 s. The suite's pipeline making went
from 126 s to 16.7 s, with no stall. Repeat boots show metalwin unaffected:
its frame rate follows other GPU work at session start, not this change.
Tests:
- engine_native_half: the controlled conversion, and a half read from memory
under both NaN settings, NaNs stored back.
- device::tests::profile::nvidia_carries_the_folded_half_conversion_pair.
- lower::arith::tests: narrow, round_texel, half_texel, texel_round.
- spirv::requirements; spirv::builder::ops.
- Updated expectations: engine_arith half rounding, engine_spirv_cross_forms
fma, engine_metal_routines frexp (the device's NaN under the default,
Metal's under Exact).
- The validation lanes driver_deviations and native_maths expect the
controlled form.
Docs: the FAST-PATHS half-rounding row (scope) and a new row for the
widening; the NativeHalfConversion and NativeNanEncoding entries in API.md and
their rustdoc; HalfRoundingPolicy and NanMinMaxPolicy rustdoc; HOWTO's driver
note; REFUSALS regenerated. A known gap is added to the texel-NaN row: on
ANV a 16-bit float NaN texel kept as half reads back 0xFE00 from ANV's image
decode, even under Exact (announced as device-nan-encoding). SEMANTICS_VERSION
1759, runtime pin recomputed, RUNTIME_VERSION unchanged.
Tables: the golden hashes, 274-389 cells on each ANV and RADV column across
both cuts, and NVIDIA's profile fingerprints, whose words are unchanged. The
authored compile census: artifact hashes on the 780M and RPL-P ANV columns,
with no status change. No MoltenVK, lavapipe or floor cell moves.
Verified on development-fast (batches f18-f24): every lane green on the RTX
3090, ANV Iris Xe, RX 7900 XTX, both 780Ms, lavapipe and the M3 Max, plus the
CPU suites, case qualification, clippy in every configuration, docs and
packaging. Not run on the RTX 5080 Laptop (host offline; whether its driver
keeps the pair is unmeasured).
|
||
|
|
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. |
||
|
|
dd5a19aea1 |
Alias a padded texture that only reads by default, the shadow behind PaddedReadsPolicy::Shadow
The padded-reads work packet (the owner's choice): a padded texture that is only read aliases the
buffer by default, under the same documented first-move gap as tight aliases, checked per driver;
the exact shadow stays behind PaddedReadsPolicy::Shadow, which exact_answers() selects.
What: a 2D texture (or array) over a buffer whose rows or slices lie with bytes between them, and
whose usage as Metal reports it holds no RenderTarget, ShaderWrite, ShaderAtomic or block writes
(Unknown reads as 0x17, so it stays a shadow; a swizzled texture reports ShaderRead |
PixelFormatView and reads), is now an image over the buffer's bytes at Metal's row pitch, as a
texture of packed rows is: the device's own linear image (PREINITIALIZED over ordinary memory, for
host allocations over a no-copy buffer), a DRM_FORMAT_MOD_LINEAR image at that pitch, or one over
a dma-buf of the pages. Its subresources may hold the bytes between its rows and its last row's
padding (to row_pitch x rows); a driver whose image reaches past that is refused as for packed rows
(lavapipe's height rounded up to 4). A render target or a texture a shader writes stays a shadow.
The rebind remakes the image under the same rule (AliasKind::Linear keeps it).
The switch: DevicePolicy.padded_reads, PaddedReadsPolicy::{Alias (default), Shadow};
DevicePolicy::exact_answers() selects Shadow, the runtime's shadow copied in before each use. It
is the runtime's alone: no ProfileFields carries it, so no profile fingerprint moves
(tests::fast_paths::the_runtime_s_padded_reads_choice_keys_no_profile) and SEMANTICS_VERSION
stays. The owner's ruling (relayed by reims-vgpu-orchestrator, 2026-10-14 15:55): "I'll take 1 &
2", (2) being this, "exact to the same standard as tight aliases", under 30c8b4bff8's first-move
known gap extended to the padding bytes, checked by the same per-driver lane check.
Why it is the same standard: the first move is the only layout transition a runtime image takes.
- Every image memory barrier the runtime records is a first move (texture/first_move.rs
FirstMove::barrier), a new image's own (storage_form.rs, host_copy.rs; never an alias), or a
caller-wrapped image's Transition (submit.rs via texture/wrapped.rs).
- The tracker's barriers are VkMemoryBarriers (tracker.rs Barrier::record), which transition no
layout.
- Blits into a texture copy in GENERAL: blit_texture.rs's vkCmdCopyBufferToImage and
vkCmdCopyImage. VUID-vkCmdCopyBufferToImage-dstImageLayout-01396 and
VUID-vkCmdCopyImage-dstImageLayout-01395 allow GENERAL; GENERAL "supports all types of device
access".
- "Each source region specified by pRegions is copied from the source buffer to the destination
region of the destination image". The Memory Model: "A memory operation must not affect memory
at a memory location not within its set of memory locations".
- Every descriptor names GENERAL (binding.rs, heap_sets.rs).
- A texture over a buffer has one level (linear_plan's MipmapLevelCount), so generate_mipmaps
leaves it, and optimize_contents_for_gpu_access records nothing.
- A texture without RenderTarget usage has no COLOR_ATTACHMENT usage. A pass renders it through a
stand-in, copied in GENERAL, so no load or store operation reaches its image.
How:
- linear_plan's padding() becomes holding(layout, usage, policy) -> Result<Holds, String>, with
Holds::{Texels, Padding}, Holds::fits (texels_alone, or the new padded_alone) and only_reads.
- aliases() takes the Holds. So do alias_image, dma_buf_alias_image (DmaBufTexels.alone),
host_alias_unbound, host_pitched_image, and the pointer and dma-buf rebinds.
- storage_over_buffer decides it once, from texture_usage (the effective usage), so the shadow's
reason no longer reads the raw descriptor's RenderTarget bit. The reason of a read-only texture
shadowed under the switch names PaddedReadsPolicy::Shadow.
- RUNTIME_VERSION 1211 (renumbered at compose); the runtime-sources pin is recomputed at this tree.
Docs:
- FAST-PATHS.md: a fast-defaults row (padded_reads = PaddedReadsPolicy::Alias/Shadow, ANV's 0.63
ms copy in per tile use and 135 vs 41 us making).
- FAST-PATHS.md: the padded-row shadow row now covers textures that render or that a shader
writes.
- FAST-PATHS.md: the first-move gap row now covers the bytes between rows, with the GENERAL anchors
in prose and the M3 Max probe's point (Metal never writes padding, even under concurrent CPU
writes).
- API.md's shadowed-texture entry, ShadowedTexture's rustdoc, HOWTO.md, interop.rs and dma_buf.rs.
- The refusal surface is unchanged (refusal_surface.py --check).
Verified so far:
- clippy -D warnings, all targets, all features, --cfg m2v_cpu_icd: clean (um780, Rust 1.98.1).
- cargo fmt --check: clean.
The unit and lane runs follow with the lane checks' commit.
Check per driver that a padded texture that only reads keeps every byte of its pages:
What: three lane tests in runtime_lane::pitched_surfaces, under PaddedReadsPolicy::Alias (the lane's
own devices take exact_answers, so Shadow), each over no-copy buffers of anonymous pages:
- a_texture_that_only_reads_keeps_every_byte_of_its_pages: a ShaderRead texture over each of the
11 layouts. Its first use is a fragment function's read through its image, before anything else
touches the pages: it must read the pages' texels, and every byte of the pages, the bytes between
the rows among them, must be unchanged. That is the image's first move, the known gap
|
||
|
|
30c8b4bff8 |
Shadow a padded texture over a buffer exactly, and cut the shadow's cost
The padded-texture work packet. A texture over a buffer whose image would hold bytes that are not its texels is drawn through a shadow image with exact copies, since a render pass or a layout transition may write those bytes. Then the shadow's cost is cut, exactly: no copies for a pass that reaches no tile, a copy back bounded by the draws' scissors, and cost lines that show each part. Shadow a texture over a buffer whose image would hold bytes that are not its texels: A texture over a buffer is a linear (or DRM_FORMAT_MOD_LINEAR) image over the buffer's bytes only where every byte of the image's subresources is one of its texels: its rows lie one after another (or it has one), its slices likewise, and its last subresource ends at its texels' last byte or before. Anything else is the shadow, whose copies address the buffer's texels alone. The Metal texture over an MTLBuffer (MoltenVK) is exempt: every write through it is Metal's own. Why: Vulkan lets a render pass's load and store operations "read and write back any memory locations within the image subresource bound for that attachment" (renderpass.adoc, Load and Store Operations), and VkSubresourceLayout's size "includes any extra memory that is required based on rowPitch", so the bytes between padded rows lie inside the subresource. Metal leaves them as the program writes them. No query promises otherwise, so no image may alias padded rows. Bytes past every subresource stay allowed: Memory Aliasing bounds the bytes a write through an image affects to "those overlapped by the image subresources that were written". Measured on lavapipe (Mesa 26.2.4 llvmpipe, gem10) at the round's base: pitched_surfaces' 657x128/5312 RGBA16Float tile took lavapipe's own linear image (its pitch 660 texels rounded to 64 bytes is the lane's 5312), and a clear-blend-store pass rewrote 13 padding bytes in 13 rows (row 3 byte 5265 0x7c -> 0x7e: texels 657..659 of its 4-texel blocks read and written back, signaling NaNs quieted). The reliance predates |
||
|
|
0307fb8c9d |
Run every Linux CI step in the gate's container, and fix what the gate caught
The Linux gate's work packet: CI's Linux steps now run in the gate's own container, and the failures that run found are fixed: depth and stencil formats over a DRM_FORMAT_MOD_LINEAR image, test IR that LLVM 21 rejects, and a frame-cost check that allocated. Run every Linux step of ci.yml in the Linux gate's container: What: scripts/linux-gate-ci gains the three steps ci.yml's Linux job runs and it did not: "Clippy under each feature alone" (metal2vulkan with no feature and with serde, ash and cli each alone; metal2vulkan-runtime; metal2vulkan-air with no feature and with serde), "Build the new API's consumer reference" (scripts/api-docs) and "Package the published crates". Its "Test metal2vulkan" step now tests the packages ci.yml's does (metal2vulkan, -air, -runtime and -devtools), where it tested metal2vulkan alone. The steps run in ci.yml's order, each with the container's build share. Why: the script's header says every Linux run: step of ci.yml has one step here, and docs/VALIDATION.md presents the container as ci.yml's Linux job; a change that broke only a feature-alone build, the reference, packaging, or the AIR front end's, runtime's or dev tools' tests passed the container and failed CI. Verified: bash -n; the steps compared one by one with ci.yml at |
||
|
|
1cf79a9617 |
Make textures over surface buffers cheaper, laid at Metal's row pitch where drivers allow
A shadow of a texture over a buffer starts as the buffer's memory lies, instead of zeros that the copy-in then overwrites, and a format's linear-modifier features are asked of the driver once. A no-copy texture is laid at Metal's row pitch as a linear image over the buffer wherever the driver takes that explicit pitch, and a driver's refusal is remembered per exact image (up to 256). The lanes check textures at a browser's padded row pitches and say which pitches each driver takes. RUNTIME_VERSION 1186. Gain: a surface texture's shadow on ANV 1048 -> 135 us, RADV 484 -> 90 us. With the pitched images, every padded surface aliases on ANV with no shadow: a tile 1048 -> 41 us. Verified on the original branches: the runtime lanes on RADV, ANV and NVIDIA. Known open: pitched_surfaces::a_half_float_tile_reads_writes_and_renders_as_metal fails on lavapipe (a clear-blend-store pass writes a few padding bytes past the row), as it did on the original branch. This squashed commit was not re-tested on its own. |
||
|
|
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. |
||
|
|
13b279df1b |
Squash 11203 commits of translator, runtime, and validation work
Rolls up everything since
|
||
|
|
43c46ac8a2 |
Squash 680 commits of translator, validation, and corpus work
Rolls up everything since
|
||
|
|
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 |
||
|
|
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. |
||
|
|
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. |
||
|
|
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. |
||
|
|
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. |
||
|
|
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. |
||
|
|
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. |
||
|
|
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. |