The owner, through reims: zero copy, in place where possible, shadow copies a fallback and never
a first option. A tracked texture over a Private buffer of the runtime's pooled memory whose rows
the device's own linear image lays out otherwise was a shadow past 48 KiB to its pitch
(TextureShadowReason::LinearCost), a speed choice measured on an Iris Xe alone that shadowed 1001
of an RTX 2080 guest boot's 1366 textures. It now takes its DRM_FORMAT_MOD_LINEAR image at Metal's
pitch at any size, wherever the device makes one and its check of the pooled memory passed, as a
texture over a Shared buffer already did; it is a shadow only where the device makes no such
image (its format, usage, pitch or limits), its policy is HostPageTexturePolicy::Shadow, or the
check failed or is pending (a pending one still moves in place once it passes).
Removed with the bound: in_place::POOLED_PITCHED_BYTES, ShadowCause::LinearCost and the public
TextureShadowReason::LinearCost (a breaking change of metal2vulkan-runtime's surface:
api_signatures.tsv loses its variant), texture_spans.rs (the runs of bytes textures were made
over, which only the bound read) and the moves it fed (MoveAfter::Aliases, LoneShadow, the
buffer's note and wait), Texels::only_commands_write (the bound's alone), the bench behind the
bound (runtime_lane::pooled_draw_costs, its crossover additions included) and
aliased_surfaces' cost bench. aliased_surfaces' first check now asserts every texture over one
surface's bytes takes the image at Metal's pitch, the first included, and a read copies nothing;
its one-after-another check, about the first texture's shadow, is gone. storage_over_buffer is
one function again (REFUSALS.md regenerated for the name). API.md, HOWTO.md, FAST-PATHS.md (the
in-place row) say "at any size".
RUNTIME_VERSION is not bumped here: the landing bumps it and re-pins the runtime sources.
The ledger's copied-buffer rows (FAST-PATHS) and copied.rs's Cost bullet quote
the copied_bench and copied_pass_bench figures measured while a comparison ran
on up to four threads; it now runs on up to eight, so they say so, in the past
tense, rather than read as the eight-thread cost. The two FAST-PATHS rows are
rewrapped to 100 columns (one line ran to 130).
No behaviour change; no figure is new.
tests::fill_waits_bench on the RTX 3090 (job m3-max-19457): beside an app making two 4 MiB Private buffers per command buffer, the compositor's frame p50 went from 8.96-9.01 ms (every batch waiting for the fill queue's last submission, 424-429 unused waits in 4 s) to 2.10 ms (0 unused), as with nothing made (2.08-2.12 ms).
On a device with a fill queue (NVIDIA's copy engine), a batch took every fill waiting, whichever
buffers its commands name, and every submission of the device's waited on the GPU for the fill
queue's last submission until the host saw it complete. A fill-queue submission waits for the
batches before its batch on that batch's VkQueue, so a compositor's frame that named only old
buffers waited for an app's new buffer's zeros behind the app's kernels, or made them itself and
waited for its own queue's last batch first.
What, on such a device:
- A batch takes the fills of memory its commands may reach (FillTake::Reached): memory a resource
its encoders' uses name owns (used_resources::owner_of over Owners and HeapKeys: the buffer, or
the heap it lies in); every fill where a command of it may reach memory no use names
(State::reaches_unnamed, State::parts_reach) or where it takes a move of an image in memory
another resource owns or a staged copy (Taken::every_fill), which come after every fill of that
memory; and the fills of the device's own buffers, which no use names. The rest stay waiting, in
their order, for a batch that may reach them or an internal submission, which takes every one.
A fill's key is noted as it is registered (Filled::key), and its owner as it is taken, so a
buffer's fills share their turn.
- A batch waits on the GPU for the last fill-queue submission the host may not have seen complete
whose fills it may reach (Device::fill_queue_wait_for), where its VkQueue did not already.
Internal submissions still wait for the fill queue's last.
- A command buffer that needs no GPU work goes with no submission where nothing waits but fills of
the program's memory (FirstMoves::none_waiting_but).
Other devices take every fill, as before.
Tests: first_move::a_batch_takes_the_fills_of_memory_it_reaches (pure); fill_waits (device) holds
fill_queue_waits_unused at 0, where the commit before counts the compositor's waits.
Docs: device/staging.rs and texture/first_move.rs module docs, the runtime README, FAST-PATHS'
fill-queue row.
Verified: cargo fmt. Builds, device runs and numbers follow as potluck jobs.
SamplerDescriptor gains `lod_bias: f32` (MTLSamplerDescriptor.lodBias,
default 0, serde default), so a guest's bias is carried rather than
having no field to land in.
What Metal does with it, measured on the M3 Max (Apple9, macOS 27.0.1
26A434) with a throwaway Swift probe of runtime-compiled MSL (jobs
m3-max-19665/19666): level L of a 7-level texture held L, so every
sample read its own level of detail. Across 136 row groups no sample
changed with the sampler's bias: fragment implicit, shader bias(),
level(), gradient2d(), min_lod_clamp() and bias+min_lod_clamp; kernel
default, level, gradient and bias; linear and nearest mip filters on
float textures, both on uint ones; a NotMipmapped sampler's min/mag
choice; clamps [1,3], [1.5,MAX], [0,2]; biases -1000 to 1000, 15.99,
16, 16.5, 17, NaN, +-inf. The probe saw levels move with the shader
bias, the clamps, explicit levels and the NotMipmapped filter switch.
With MTL_DEBUG_LAYER=1 every value made a sampler with no assertion and
read back as set. Apple's tables list the bias under Apple10, which no
runtime device claims.
So the Vulkan sampler's mipLodBias stays 0 whatever the descriptor
holds: no bias is past maxSamplerLodBias, and none needs a portability
subset's samplerMipLodBias. The binding shape and the sampler word do
not carry it either. The runtime's state key does: on the M3 (job
m3-max-19683, with and without validation) biases 0 and 1, 1 and
1.0001, and 20 and 30 gave two states each, while 0 and -0, and two
NaNs of one encoding, gave one. The key takes the bits of `bias + 0.0`.
The Apple10 family row stays a gap, its reason now that the biased
level of Apple10 is not built. The conformance suite's SamplerSpec
states the bias too (tag 8, a word only where it is not 0, so no
recording's fingerprint moves), and both legs set it. METAL-COVERAGE
lists lodBias as implemented; CONFORMANCE-COVERAGE and the API
signature table are regenerated.
Tests: metal::sampler::a_lod_bias_makes_the_unbiased_sampler covers
every committed profile, every mip filter, three filter pairs and four
uses plus the unnormalized one, and 15 biases: the Vulkan sampler and
the binding shape are the zero bias's. That includes MoltenVK, which
withholds samplerMipLodBias, and biases past every device's limit.
runtime_lane::lod_bias::a_sampler_s_lod_bias_reads_the_unbiased_level
runs a kernel's biased samples through runtime sampler states of ten
biases, under linear and nearest mip filters, and compares them bit for
bit with the unbiased state's. It also checks the state-sharing rule.
A copy's comparison of 4 MiB or more (a commit's copy in with no base, whose
pages carry no log, and a comparison with a base) ran on up to four threads, the
calling one among them. On the RTX 5080 Laptop GPU's host (a Core Ultra 9
275HX) eight cut the commit of a kernel-read pass over 256 MiB from 11.2 to
8.4 ms (12.3 to 14.1 GB/s), 64 MiB from 2.9 to 2.2 ms, a copy in after the CPU
rewrote every float of 256 MiB from 30.3 to 17.0 ms (6.6 to 9.0 GB/s), and the
merge back of a 256 MiB kernel-write from 65 to 41 ms with the stores of
27c4a1ae46 (copied_bandwidth_bench's copied-t8 rows at 31333d4bf4, b5080
entry nvcopybw-nvcopybw-5080-ab-234252); on the RTX 3090's host (a Ryzen 7
7840HS) the 256 MiB kernel-read commit from 14.0 to 11.9 ms and the 64 MiB
kernel-write merge back from 11.2 to 8.8 ms (m3-max-19454). A host that runs
fewer threads at once runs that many.
SPLIT_THREADS is now 8, so a device's comparisons (one at a time under its
copies' lock) hold at most seven more threads at once. The bandwidth bench's
contrast row is now four threads (copied-t4); copied_256_bench_eight_threads,
which measured what is now the default, is gone. Docs say eight.
Tests: run after this commit (copied tests on a host without AVX-512, lavapipe).
SPLIT_BYTES, the fewest bytes each thread of a split comparison takes, goes
from 8 MiB to 2 MiB. A merge back runs about 1.75 GB/s a thread on the RTX 5080
Laptop GPU's host (copied_bandwidth_bench, b5080 entry nvcopybw-bw-before-222944),
so a 16 MiB copy the GPU rewrote merged back on two threads in 4.2-4.5 ms of a
5.4-6.4 ms pass (2.6-3.1 GB/s); a run of 2 MiB takes about a millisecond a
thread, against tens of microseconds to start one. The thread count stays at
most four.
Docs: HOWTO, API and FAST-PATHS said a comparison of a copy with a base of 16 MiB
or more splits; now 4 MiB or more, with a base or without (the copy in with no
base splits since d33e19bc70).
Tests: the split tests take 4 x SPLIT_BYTES (a_comparison_split_across_threads_...,
a_copy_in_with_no_base_splits_...), now 8 MiB. Not run yet.
On the RTX 3090 (NVIDIA 620.70.06), eight processes of the extra-queues test at once, 6 rounds
(m3-max-19109, the bound built in): 5 of 48 processes' checks met a submission that had not
completed at 10 s, each announced, its verdicts Unchecked, and every process ended (95 of 96 exit
0; the one exit 101 is the process of an Xid 32, whose own wait on its extra compute queue's fence
failed). Every other process's longest wait for a check submission was 1.3 to 12.0 ms; lavapipe's
0.05 ms (m3-max-19057). The same run logged Xid 13 (a compute class c7c0 exception) in one more
process, with no channel-ID allocation failure in the kernel log around it.
On an RTX 3090 behind a Thunderbolt 3 bridge (NVIDIA 620.70.06, Linux 7.3.3), six processes of
tests::video_interop::extra_queues_are_made_or_reported_and_the_video_features_enabled at once
(job m3-max-18786) met Xid 69 (class c797, offset 0x1b0c SET_REPORT_SEMAPHORE_D, ErrorCode 0xc,
data 0x2001c00d, itself a valid method header: the GPU read the method stream one word short) in
one process and Xid 32 (intr0 0x40000, PBENTRY) twice in another, 37 ms apart; two copies' empty
submission on the extra compute queue failed its fence wait, and one copy's submission checks
waited on their fence with no end. No PCIe error was logged then. The faulting processes of the
first report (um870, m3-max-18368) were video_interop tests too.
What was ruled out: every runtime VkQueue use holds that queue's lock (the queues audit), and a
probe that tracked each thread inside vkQueueSubmit, vkQueueWaitIdle, vkQueueBindSparse and
vkDeviceWaitIdle per VkQueue saw no two threads on one queue in 240 processes of the same shape
(m3-max-18977: 10 variants x 4 rounds x 6 copies: checks off, merge off, import tax off, no extra
queues, no video extensions, the test's submissions off, the validation layer). None of those
240 met the Xid either, so the variants decide nothing; 1 of the 18 earlier processes did.
Recorded as a host note (HOWTO.md), and the four tests run alone on Linux (.config/nextest.toml),
so no other process makes a device beside theirs.
Not run: a check that running alone avoids the error (it is too rare to show in a short run).
The submission checks' thread waited for each of its fences in 100 ms slices with no end. On the
RTX 3090, with six processes making their devices at once, the kernel logged a pushbuffer error
(Xid 69, Xid 32) and one process's checks waited on their fence for good, its device's teardown
behind them (SubmitChecks::stop waits for the thread). An accuracy-free self-check must not end
a program's work (AGENTS.md rule 2).
Now a wait past STALL (10 s) takes the device as lost for the checks: nothing is submitted again,
what had not answered is Unchecked for the device's life, nothing is recorded, and the sink hears
metal2vulkan-submit-check-stalled. The stalled submission's fence and command pool stay pending,
so the thread leaves them to the teardown, which waits up to STALL more and releases them once the
fence signalled; where it still has not, the teardown leaves the device and its instance to the
process's end (as the exit path does) instead of a vkDeviceWaitIdle that would never return. A
step held whole lets go of the loader word without waiting for the relay mark of a stalled use.
The checks' report now gives their longest wait.
Test: a_submission_that_never_completes_stalls_the_checks_and_the_teardown_returns injects a
submission whose first info waits on a timeline semaphore nothing signals, with a 2 s bound; the
checks settle at the bound, the sink hears it once, nothing is recorded, and the device's drop
returns after the bound with its VkDevice still live; then the test signals the semaphore.
Not yet verified: build, lint, the test runs (to come in the following jobs).
A commit copies into each copied host buffer the bytes the CPU changed in
its pages, before any of the command buffer's work is submitted. A batch
that waits for an event runs its commands only once the event reaches
the value, and on Metal those commands read the pages as they stand
then. So a CPU write made after the commit and before the host's signal
(or before a later command buffer's signal) never reached the copy, and
the waiting command buffer read the bytes from before it.
The commit now notes, before its copy in, the batches that wait for an
event value not yet reached (CopiesAgain::unreached, from each event's
timeline). When the scheduler submits such a batch, which it does only
once the wait is met, submit_batch first copies in again
(copy_in_again): the copies the command buffer reaches, as at the
commit, take the CPU's changes since. This runs with no lock of the
command buffer held, since a copy over logged pages waits for the log's
publication. A batch with no wait, or whose every wait was already
reached at the commit, copies nothing more. The new counter is
WorkCounts::copied_copy_ins_after_waits.
The same mechanism serves a reader held by an event across queues: the
signal of a batch submitted while a copy is live is seen only at its
completion turn, after the merge back. The FAST-PATHS gap that listed
event-ordered reads across queues as stale now says the held reader
copies in again; that case is expected from the code and not run.
Docs: copied.rs (Coherence, the two-memories bullet, copy_in),
dirty_pages.rs (stamps), HOWTO (copied host buffers), FAST-PATHS (cost
row and gap), api_signatures.tsv (the new field).
Verified: waited_reads in the jobs named in the report. The copied leg
fails at cae2e24b4d and passes here; the no-wait copied leg makes 0
copies in again.
RUNTIME_VERSION 2083 made a buffer bound inside its pages' import hold the import, so a no-copy
buffer's deallocator given no keep-alive waits for that buffer to go, and docs/API.md's catalogue
entry said so in its cost. The kind's announced cost (Degradation::HostDeallocatorDelayed's) did
not, and tests::degradation_catalogue::a_runtime_kind_s_entry_states_the_cost_it_announces failed
on every device that runs it (pin 44: Iris, m3-max-19132, and the 780M).
The announced cost now carries the same clause, worded 'every buffer bound inside their import
goes' in both, and the kind's own docs list the case beside the others it waits for.
Verified: the degradation_catalogue tests on lavapipe (see the landing report).
On NVIDIA's driver each VkQueue is a channel and a runtime device of
the queue plan takes 18. An RTX 2080 held 10 such devices at once
(job m3-max-18774), so a 16-thread host's default 16 test processes
ask it for 288 VkQueues and the driver refuses the rest; the 3090 and
the 5080 Laptop GPU held 61 (jobs m3-max-18776, m3-max-18775).
--profile few-channels runs three at a time, as the consumer's own
profile does. docs/VALIDATION.md says when to pass it.
vkCreateDevice's answer where the device-specific resources a logical
device needs run out is VK_ERROR_TOO_MANY_OBJECTS (the Vulkan spec,
vkCreateDevice), and a driver short of host memory for the plan's
VkQueues may make a device of fewer: both now take the least plan, as
VK_ERROR_INITIALIZATION_FAILED (NVIDIA's channels) and
VK_ERROR_OUT_OF_DEVICE_MEMORY did. A device refused with both plans
is refused naming each attempt, as before.
Asked for by a device test on an RTX 2080 under parallel test load
(job m3-max-18589) that got OutOfMemory(Host) from
Device::system_default_with, where the least plan's three queues would
have fit: the 2080 held 10 devices of the plan's 18 VkQueues at once,
and 68 of the least plan's 3 (job m3-max-18774).
The pure test of made_within_resources takes each of the four codes.
A new command queue took the round robin's VkQueue by a creation counter (made modulo the
round robin), which never reuses a slot: a guest makes about 340 queues past NVIDIA's 14 in a
250 s walk, so live queues landed together while other VkQueues stood empty. An unshared
queue (a compositor's) got a VkQueue of its own only where the device shares (an Adaptive
verdict of Idles); under PerQueue, on MoltenVK, and on a device that answers GPU times from
the host (reims-vgpu's, Unchecked) it took the round robin's next, so app queues made later
landed on it every 14th make. Guest walks (reims's logs, read in place): unshared command
buffers behind another queue's batch 1062 in one 3090 walk (39 over 16 ms, longest 33.8 ms),
5 in the next on the same build; 511 on a 2080; 2048 on the M3 (437 over 16 ms).
Now, under every policy and verdict, a command queue takes, as it is made, the round robin's
VkQueue the fewest live command queues hold of those no unshared queue holds, the first in
turn from the counter among equals (queue_share.rs fewest_held, Device::take_round_robin):
one pass over the round robin's VkQueues' counts, atomics alone, at creation only; nothing
scans the command queues. Its claim is made before it reads the unshared count, as an
unshared queue's is made before it reads the live count, both sequentially consistent, so the
two never both succeed. An unshared queue takes one no command queue holds where one is free
(the existing unshared_order, now ungated), else the one the fewest hold.
Counts: WorkCounts::command_queues_live_most (the most command queues the program held at
once: what a walk needs to size the plan by) and unshared_queues_sharing_a_vk_queue (an
unshared queue that found no VkQueue free of other queues). queues_sharing_a_vk_queue keeps
its meaning, the queues made past the round robin's VkQueues; unshared queues now count among
them under every verdict, as they did where the device did not share. QueueLimits notes keep
theirs, an unshared queue's included.
Tests: tests::queue_share's pure churn shaped like a walk (354 made over 14 VkQueues, at most
12 live, an unshared one kept): no queue placed beside a live one while one stood empty and
the unshared one never shared, against a positive count by the old rule; device test
over_a_churn_queues_take_the_least_held_vk_queue_and_unshared_ones_an_empty_one under
Adaptive, PerQueue and untimed Adaptive. The helpers that share a VkQueue on purpose (beside,
the lane's queue_where) keep the queues they make until one lands there.
Docs: QueueSharingPolicy, new_command_queue_unshared, new_command_queue_for_presenting,
queue.rs and queue_share.rs module docs, docs/API.md, the runtime README, FAST-PATHS's queue
sharing row and its known gaps.
Not yet built or run: potluck jobs follow.
The release order RV 2073 brought, in the docs a consumer reads. A no-copy buffer made over part
of a live one's bytes, or over the same bytes as memory of another class, is bound inside the
live one's import (one live import of a page: VK_EXT_external_memory_host leaves a host allocation
imported twice into one device undefined) and holds it, so the live one's keep-alive is dropped
only once both are released and the import is freed. With a keep-alive its deallocator still runs
at its release, as Metal's; given none, the deallocator waits for the free, announced as
host-deallocator-delayed.
- API.md: the host-deallocator-delayed entry names the cause and its cost; section 10 (Heaps and
memory) records the keep-alive's later drop as an accepted difference, with
WorkCounts::host_releases_held_inside.
- HOWTO, "Unmapping host memory": the order for a buffer over part of another's bytes.
- The runtime README's no-copy paragraph and KeepAlive's doc name it.
The straddle copy (f083e9c806) and the held-back chunk (c55501db1b) each read only finished
state: an object's check read made chunk imports alone (chunks_hold_any), and a chunk's check
read noted object imports alone (the alias registry). So an object made while a chunk's import
was in flight, or a chunk imported while an object's own import was between its checks and its
note, imported the same pages twice. Both tests of 1d77522508 showed it on lavapipe, 3 runs of
3 each (m3-max-18881): imports_inside_live 1.
Each RAM the device uses now keeps the claims of objects' own imports in flight. An object's
making and a rebind claim their window's RAM pages (Device::claim_ram_pages) where no chunk binds
them, and hold the claim through their import until it is noted: where a chunk's import, made or
in flight, holds some of the pages, nothing is claimed and the object is a copy
(CopiedBecause::OverRamChunk, as for a made one). A chunk's import is marked in flight only under
the RAM's claims (RamOnDevice::chunk takes them before the chunk's lock, as a claim does, and
looks at the chunk again), and is held back where a claim meets its pages (held_back), as where a
noted import does. Whichever starts first, the other never imports the same page.
Docs: host_ram.rs's one-import bullet; the OverRamChunk cause, copied_over_live_imports and
docs/API.md's copied-host-pages entry say made or in flight.
A no-copy object whose pages cross the end of a guest RAM's chunk, the chunks on both sides
imported, is bound in neither: route_runs answers Runs, and the object took the gate's path
and imported its own pages, the same host addresses as the two live chunk imports
(VK_EXT_external_memory_host leaves that undefined; imports_inside_live counted it). The
consumer's walks hit it at boot on the 2080 and the 3090: a 2 MiB heap from 0x3f22000 into a
64 MiB chunk, 0xde000 bytes in the first chunk and 0x122000 in the next.
Such an object, and one over a live chunk's pages that no resolver routed, is now a copy of its
pages (CopiedBecause::OverRamChunk, counted in copied_over_live_imports, announced as
copied-host-pages, the gate not asked), at its making and at a heap's rebind. Chosen over:
- aligning chunk imports to objects: the chunks are imported ahead, before the objects over
them exist, and objects lie anywhere;
- one import over both chunks: each chunk's import already binds objects when the straddling
one comes, and swapping it would move every bound object;
- a sparse binding of both chunks' memory: heaps place resources at any offset, and not every
device binds sparse buffers.
A copy costs one copy of the object's pages per commit, the rare edge object alone (one per
chunk end an object crosses).
Test: a_heap_across_two_imported_chunks_is_a_copy_and_imports_nothing (the consumer's shape:
both chunks imported by a buffer each, then a 2 MiB heap from 0xde000 before the first chunk's
end): one copy, no pointer import, imports_inside_live 0, the gate not asked; a buffer placed
across the chunks' end reads the RAM's bytes and a fill through it reaches them.
reims's pin 42 walks on the RTX 2080 counted imports_inside_live = 1 at boot, once in each of
two walks, in the second the device's thread imported its first chunks ahead (with a 2 MiB
pointer import and host_imports_kept_of_heap in the same second). A no-copy heap made over the
RAM's pages before use_host_ram (or with no run resolver) imports its own pages outside the
RAM's routing, and the thread's import of the chunk holding them then imported those pages a
second time, which VK_EXT_external_memory_host leaves undefined (issue 6).
Now RamOnDevice::chunk holds the chunk back while HostAliases::within finds a live import over
its span (RamOnDevice::held_back): no import, the device's thread marks it tried, an object
over it falls back to the paths of memory no RAM holds (its own import, inside the live
import, or a copy), and copy_take sends copies over it through the CPU. Once every such import
over the chunk went, the next object over it imports it. Counted:
WorkCounts::host_ram_chunks_held_back (api_signatures updated).
Docs: host_ram.rs's module doc no longer describes pointer chunks' runs imported alone (the
2073 fix made those dma-buf-only); it states the held-back chunk. host_aliases.rs,
churn_counts.rs's imports_inside_live and HOWTO's guest RAM paragraph say the same.
Test: host_ram_device::a_chunk_a_live_import_made_before_the_use_holds_waits_for_it_to_go
(a heap over the first chunk made before the use; the thread and a buffer's take hold the
chunk back, the buffer imports its own pages and reads the RAM's bytes, no import inside a
live one; once both went, the next buffer is bound in the chunk).
87b0acd6d5 tried every type the host does not map before every type it maps. On an Iris Xe
(ANV, Mesa 26.2.x, m3-max-18804) that moved Shared, WriteCombined and Managed imports of a
udmabuf and of a device-local dma-buf from type 2 (DEVICE_LOCAL|HOST_VISIBLE|COHERENT|CACHED,
the class's first) to type 0 (DEVICE_LOCAL alone). On a unified-memory GPU the host's flags on
a device-local type may choose how the GPU caches its accesses to the pages, so that move is
not shown to be harmless.
Now only the system-memory types the host maps (HOST_VISIBLE without DEVICE_LOCAL) go last;
device-local types keep their class's order. NVIDIA's udmabuf types (0: no flag, 4: host-visible
coherent cached system memory) still order 0 before 4, so the 3090's result stands. ANV's types
are all device-local, RADV's for a udmabuf all host-mapped system memory, lavapipe's one: the
class's order as before.
Unit test: dma_buf_imports_try_the_system_memory_types_the_host_maps_last (renamed), with an
ANV-like set (all device-local, unified) and a GTT-like set (all host-mapped system memory)
whose orders and forms stand. FAST-PATHS's NVIDIA dma-buf gap says the same.
NVIDIA's 620.70.06 lists a udmabuf of host pages as its type 0 (system memory, no property
flag) and its type 4 (host-visible, coherent and cached, the Shared class's first), refuses
every import as type 4 with ERROR_OUT_OF_DEVICE_MEMORY, and imports it as type 0. Measured on
an RTX 3090 (tests::export_after_dma_buf, raw vkAllocateMemory answers on fresh devices): once
it refused an import as type 4, it answers ERROR_OUT_OF_DEVICE_MEMORY to every allocation of
its device-local type 1 exportable as an opaque fd or a dma-buf (with the device-address flag
or without), at 12,441,600 bytes and at 64 MiB, for the device's life; plain and
device-address-only allocations are still made. After a successful import as type 0, every
chain is made. Whether the import was dedicated does not matter. The runtime's first Shared
dma-buf import tried type 4 first, so every later Private exportable buffer overflowed into
system memory (type 0, DeviceMemoryOverflow).
The runtime never maps a dma-buf import (the CPU reaches the pages through the caller's own
mapping), so a type the host does not map serves it as well. dma_buf_candidates now orders the
types the host does not map first, then those it maps, each in the class's order
(dma_buf_class_order, the order before), and dma_buf_attempts tries every form (dedicated to
nothing, then to the buffer) of the first group before any form of the second. On NVIDIA the
import ends as type 0, as before, without the refused attempt. A driver that lists only
host-mapped types for a dma-buf keeps the class's order.
Tests:
- memory::dma_buf_imports_try_the_types_the_host_does_not_map_first (unit): both orders, and the
attempts' order, for NVIDIA's types and for a set whose listed types are all host-mapped.
- export_after_dma_buf::a_private_exportable_buffer_after_a_dma_buf_import_lies_in_device_local_memory
(renamed): asserts each export lies in a DEVICE_LOCAL type with the control's flags and no
overflow counted. It failed on the RTX 3090 before this change (type 0, one overflow each).
- export_after_dma_buf::the_driver_s_answers_after_each_kind_of_dma_buf_import: kept as the
driver's evidence, printed and not asserted.
- export_after_dma_buf::the_type_each_class_s_dma_buf_import_takes_against_the_class_s_order:
prints, per class, the type the runtime's import takes and the type the class's order took,
for a udmabuf and for a dma-buf of the device's own device-local memory; asserts they agree
where both orders are the same.
docs/FAST-PATHS.md's NVIDIA dma-buf gap records the driver's refusal and the order.
The quiet-commit definition, where a shadow made before its verdicts (or a pooled texture's
shadow of its linear cost) moves in place, named only the uncommitted command buffers, events
and textures bound by ID. The commit also takes the move only where every batch before it was
submitted, every encoder of it may run, and none of its work is left to record after the commit
(command_buffer/storage_form.rs takes_storage_forms; Device::storage_form_switch). Found on
lavapipe: a diagnostic run (m3-max-18654, scratch prints, never landed) showed four compute-only
commits declining the move, each with recorded segments, and a blit's commit taking it
(moved 1, freed 1, the next read copying nothing).
A guest's window server makes dozens of textures over each of its large Private surfaces (other
formats of the same bytes, and a new texture each frame), and past the pooled bound each was a
shadow of its linear cost of its own (216 on a Radeon 780M at a login, 1022 in 13 s on an Iris Xe).
storage_over_buffer decided each texture alone: pooled_pitched_image answered LinearCost for any
tracked texture over a Private buffer past 48 KiB, so every texture over the same bytes made a
full image of its own, copied every texel in at its first use, copied in again after a write
through any other (which lets go of its standing) and copied back whole after a kernel's write.
The shadow log names the buffer's object, not the texture's, so one object's two lines 22 ms apart
are two textures over the same surface, a frame apart.
The bound weighed one texture over the bytes. A buffer now notes the runs of bytes textures were
made over (texture_spans.rs, at most 8 runs, joined where they meet), whether those textures
still live: a texture over bytes another texture was made over takes the DRM_FORMAT_MOD_LINEAR
image at Metal's pitch at any size, as over CPU-visible memory, and the first texture's shadow of
its linear cost moves to that image once another texture is made over its bytes, through the
existing pooled move (wait_to_move_in_place: at the next quiet commit, with no copy). Both forms
give Metal's answer; the textures alias the bytes as Metal's do. The bound has no FAST-PATHS row:
it chooses between two exact speeds (6717cac4ea). API.md, HOWTO and the LinearCost docs say so.
Verified: cargo fmt; builds and device runs follow as potluck jobs.
What: a usage or attached-read shadow whose truth is a tracked Private or Memoryless image the
runtime made in memory of its own (not shareable, its VkImage never handed out) now stands
across command buffers, as a shadow of a Private buffer's bytes already did
(Backing::PrivateImage, StandingAcross::over_image). A standing also keeps the rectangle its
image is stale in when the command buffer ended with it current there alone, and the next
command buffer's gated copy in moves only those texels (Standings::standing,
GatedCopyIn::standing_copy). The first render pass instance of a pass now bounds its loaded
colors' writes by its draws' scissors as later instances did, so a draw that samples the
texture its pass renders leaves that texture's shadow stale inside the drawn rectangle alone.
Why: on the 780M a 2618x1024 texture read through such a shadow was copied in whole once per
frame although its texels changed only every 4th frame: 2,680,832 texels a frame, about
200-370 us of GPU time, for a draw beyond the texture's usage and for one that samples it in
the pass that renders it through a 64x64 scissor. An image truth never stood (stands_across
took bytes alone), and a one-instance pass's attachment writes were never bounded, so the
shadow lost the truth whole. The copy an attached read takes before any barrier stays: read in
place through the feedback loop it would race the pass's own writes, which Vulkan forbids
(attached_reads.rs now names it).
New WorkCounts fields: shadow_texels_first_copied_in_private_images,
shadow_texels_unskipped_stale_within.
Tests: unchanged_truth_copies now asserts that a frame that changed nothing moves no texel the
shadow holds (0 beyond usage, the scissor's 4096 for the small attached read); image_standing
checks the stale-rectangle copy's texels and counts, the let-go after another write, and the
mip chain (clear level 0, render level 1 sampling the whole texture, then level 2, then sample
every level) with and without a usage shadow, its passes apart and in one command buffer. Run on
lavapipe and RADV PHOENIX after this commit (job ids in the report to main).
A compute state whose descriptor requires no threadgroup size predicts no
VkPipeline at its creation: the local size and the threadgroup memory
lengths are the dispatch's own calls, so its creation's record made none of
its dispatches' pipelines on a later warm pass, and each was a cold driver
compile at the program's first dispatch of its shape (the 12.7.6 kernels'
case in FAST-PATHS).
Now, where the device hands records over, a compute state's direct dispatch
(dispatchThreadgroups: or dispatchThreads:) whose regions' pipelines were not
all made hands the hook one more record: the creation's descriptor, as its
own record holds it, and the dispatch (its threadgroup, a dispatchThreads:
grid reduced to one whole threadgroup and its ragged edge per axis, and the
encoder's threadgroup memory lengths). Each such dispatch once per state, at
most 16 a state (pipeline/dispatch_record.rs). A warm pass that creates such a
record's state then plans the dispatch as a creation's prediction plans its
first one (nothing bound but the default samplers), with the recorded
lengths, settles its variant as a dispatch does, and makes each region's
VkPipeline on the pass's thread, so their driver data lands in the records
under the names the program's dispatch of that shape asks for.
WarmStatistics::dispatch_pipelines_warmed counts them. Indirect dispatches,
dispatches of a threadgroup range and tile dispatches record nothing.
Records are immutable, one per dispatch shape, so a consumer keeps each once
and needs no rule for which supersedes which. The record format moves to 7:
a compute record's bytes now end in its dispatch list (count, then each
dispatch), so a format-6 record reads as none. The codec bounds the list at
16 dispatches and 31 lengths each, both when writing and when reading.
Tests: warm_record round-trips a compute record with a dispatchThreadgroups:
and a ragged dispatchThreads: carrying two threadgroup lengths, and bounds the
list (more than 16 is unwritable; bytes claiming 17, resealed, are no record;
16 read back). The device test
a_warm_pass_makes_the_pipelines_of_the_dispatches_its_records_name records a
state's creation and first dispatch, checks that the same dispatch again and a
grid of the same edge make and record nothing, warms both records on a
device over the same directory (dispatch_pipelines_warmed equals the regions
the recording dispatch made), and checks that the program's first dispatch
there hands each of its makings the driver cache the pass filled
(caches_shared) and translates nothing. A control device warmed with the
creation's record alone makes no dispatch pipeline and shares no cache.
Verification is in the report to main (potluck lint and lavapipe jobs).
Docs: the runtime README, HOWTO and FAST-PATHS ("Made again before the
program asks") describe the dispatch records; api_signatures gains the
WarmStatistics field.
At the tip the RTX 3090's 1 MiB frame alone took 0.93 times as long through
the fill queue (18358), against 1.04 in the two runs before (17900, 18199),
and the RTX 2080's 64 MiB one 1.04 times (18309, against 1.00 in 18167): the
trade sentence names both, and the swept size from which the fill queue was
within 1% alone in every run is 256 MiB, not 64 MiB. The tip's runs, whose
two devices both copy at the batch's start under 1 MiB, put them 0.31 to
1.85 times apart there (RTX 2080 18309, RTX 3090 18358, RX 7900 XTX 18310);
64 MiB beside the kernels at the batch's start took up to 49.4 ms, and the
other queue's share moved -11 to +8 points on the RTX 3090 and RTX 2080.
Verified: cargo fmt.
The ledger bullet and staging.rs's fill-queue docs take the ranges of all
the runs: 1 MiB beside another queue's kernels 1.80-1.84 against
3.53-3.60 ms on the RTX 3090 and RTX 2080 (18199, 18167, 18309), 64 MiB
35.9-37.8 against 40.6-48.9 ms, and on the RTX 5080 Laptop GPU 3.31-3.39
against 5.90-5.92 ms (18316, 18108). Under 1 MiB the fill queue's frames
took 0.51-2.03 times the batch's start's, but at the tip, where both of
the bench's devices copy at the batch's start under 1 MiB, the same bench
put them 0.31-1.39 times apart (18309): the sub-1 MiB differences are not
past the bench's spread, which the docs now say instead of a 2.0x loss.
Verified: cargo fmt.
At 1 MiB alone the RTX 3090's frame took 1.04 times as long through the fill
queue (jobs 17900 and 18199), and beside another queue's kernels half as
long; the swept size from which it is within 1% alone on all three NVIDIA
GPUs is 64 MiB. The owner's coordinator kept 1 MiB; the bullet says the trade.
Verified: cargo fmt.
The fill queue's own submission and the batch's wait for it cost small
copies more than the copy engine saves them. The sweep of
managed_copies_bench (a Managed buffer's copy in each frame, the fill queue
against the batch's start, p50) placed the crossover:
- RTX 2080 (18167): 128 KiB 1.04x alone and 1.11x beside another queue's
kernels; 256 KiB 2.03x alone (0.94 against 0.46 ms), 1.09x beside;
512 KiB 1.31x alone; from 1 MiB up 0.98-1.00x alone and 0.51-0.91x
beside (1 MiB 1.81 against 3.57 ms).
- RTX 3090 (18199): faster or within 4% everywhere; 1 MiB alone 1.04x
(reproduced, 17900), beside 0.51x (1.80 against 3.53 ms).
- RTX 5080 Laptop GPU (18108, before the sweep): 64 KiB 1.44x alone and
1.06x beside; from 1 MiB up 0.93-0.99x alone and 0.56-0.96x beside.
So FILL_QUEUE_LEAST is 1 MiB, the smallest swept size from which the fill
queue is no slower beside the kernels on any of the three and at most 1.04
times as long alone: Taken::take_fills takes the batch's fills only where
they write that many bytes in all (copies and zeros), and fewer stay at the
batch's start, as on a device without a fill queue. Decided from bytes, not
from the device.
The fill-queue test gains a last command buffer whose fills (a new Managed
buffer's zeros and its copy in, under half the least each) make no
fill-queue submission and read back exactly. The ledger's costs of
matching Metal gain the fill queue's bullet; the staging, create, bench and
README docs say the least and the measured numbers (the create.rs 82% came
from the raw example and is gone).
Verified: cargo fmt; device runs, lavapipe and lint follow.
device/staging.rs documents the fill queue: why (a copy through the graphics family runs on the
engine the kernels run on; the 3090 and 5080 numbers so far), why not the staging queue, what it
waits for, what waits for it (with the spec's semaphore and sharing text), what it holds, and what
stays where it was. first_move.rs and managed_copy.rs say where a batch's fills go. Queue counts:
the plan takes 18 queues on NVIDIA now, so the measured 17- and 2-queue devices are named by their
queues, and the least plan keeps the fill queue as it keeps the staging queue.
API.md's copied-host-pages entry gains the over-a-live-import cause
(copied_over_live_imports, announced once per device as the others are).
HOWTO's listed-plan paragraph described its runs alone "as above", text
the previous commit removed: it now says what a listed RAM's run import is
(a dma-buf), what it costs, how it orders, and that MoltenVK and ANV import
the chunk instead.
An object over a chunk not imported yet, and a copy over one, was bound in
an import of its own run alone, made by the run's host pointer while the
device's thread imported the whole chunk by its pointer: two live imports
of the same host addresses, the run's freed while the chunk's lived.
VK_EXT_external_memory_host leaves the same host allocation imported twice
undefined (issue 6). Runs are now imported alone only on a listed plan,
whose chunks and runs are dma-bufs of the RAM's source, and a run's import
never falls back to its pointer. Elsewhere every object and copy over a
chunk lies in its one import, made or waited for, as on MoltenVK and ANV.
The price is a making that waits for a chunk the window has not reached.
imports_inside_live now counts every import made over host addresses a
live import holds: a no-copy object's own import over another's (heaps
included) or over a live chunk import at the same addresses, and a
chunk's import over a live no-copy import, on the making and rebind
paths. A new evidence counter, imports_over_ram_chunk_pages, counts a
view's own import whose guest RAM pages a live chunk import holds at the
RAM's addresses. host_ab prints both and buffers_bound_in_import.
Not yet verified: built and tested next on lavapipe.
The known gap on the cold making of a 200,000-word compositing module ended "Nothing is built
around it", which was not true. It now names what is:
- the driver records across boots (`shader_cache/driver.rs`), named by the driver's identity, so a
driver update, another device or a removed content directory makes every making cold again, and
no machine's records serve another's;
- pipeline records and `Device::warm`, which remake a previous process's creations on a thread of
their own below every other making, and what they do not cover today (a compute state that
states no required threadgroup size predicts nothing, so its dispatches' pipelines are made at
their first dispatch);
- `PipelineWaitPolicy::Bounded` at creation and at commit, and dispatches that hand their making
to the pool;
- the consumer's creation of guest states on a compile thread off the guest's command path.
It adds the compute case: a convolution kernel's 12 variants at a macOS 12.7.6 login, one SIMD8
program each of 6,222 to 8,925 instructions with 70 to 221 spills, and the host-load
sensitivity that made the same login's makings 2 to 13 times slower than alone.
Measured on the Iris Xe (Mesa 26.2.6), the dumped modules made by a scratch harness with
the logged specialization, one module of its own per making, the driver's disk cache off:
- the 23,108-word variant alone 0.27 to 0.34 s (jobs 18284, 18292); 11 at once 0.31 to 0.53 s
each, 0.50 to 0.53 s for all (18293); device robustness on or off alike (18292);
- the 138,047-word fragment module alone 2.03 to 2.42 s, two at once 2.42 to 2.53 s each, four
at once 2.69 to 3.33 s each (18284);
- under 20 and 30 busy threads on the 20-CPU host, that fragment making 6.27 and 7.94 s, and 11
kernel makings at once under 20 busy threads 0.78 to 1.44 s each (18293);
- the program counts from INTEL_DEBUG=cs (18226).
The login's own numbers (4.87 s; 1.5 to 4.2 s, 10 or 11 at once; the guest's 1 to 197 command
buffers a second during the making) are the consumer's cold-login log at the 12.7.6 capture; the
3.1 ms warm making is the consumer's warm boot.
Docs only.
The catalogue entry and the variant's rustdoc name the new case: a ?: arm, the right side of a && or ||, or a selection's arm, where the call's value is read once (spirv::helper_branches).
A compute pipeline's line in METAL2VULKAN_LOG_PIPELINES named the kernel's function, its SPIR-V
hash and length, its specialization constants and notes, but not what the kernel was made from:
a cold boot's slow compute creations could not be made again off the device, because the
function's Metal constant values were nowhere in the log, and METAL2VULKAN_DUMP_PIPELINES wrote
render modules only.
The compute line now ends with `; descriptor: ` and the same naming a render state's first line
gives each function (its name, the SHA-256 of its bitcode, the constant values by index and by
name with their types and bytes), from one helper both share (`render::logged_function`). With
the dump directory set, the line's module is written there as `<hash>.spv` (`dump_modules`, the
render dump's writer, now over any modules), and a failed write is named in the line as a render
line names it. Nothing is kept or measured while the variables are unset: the descriptor's text
is made only where the log is on (`compute_kernel`).
The creation log's module doc also names the record words the split prints since the record
naming change (`record's cache shared`, `found in cache`, `compiled`).
Test: `opencl_data::the_pipeline_creation_log_names_a_compute_pipeline_and_its_notes` now runs
its child with the dump directory set, and asserts the line's descriptor (the kernel's name,
`air`, `constants {`), no dump failure, and a SPIR-V module (its magic) at the hash the line
names. It and the creation_log unit tests, and lint, run on this commit as jobs after it is made
(the report names them); a failure is fixed forward.
Records, as a known gap, what is left of the Iris Xe's cold login
creations after the records stopped naming attachment formats: the one
compile of the compositing fragment module (203,016 words, macOS
26.7.2) that every state over another format then finds in its record.
Measured with a scratch harness making the module's fragment shader
library cold, the driver's disk cache off:
- ANV, Iris Xe, Mesa 26.2.6: 3.3 to 3.7 s at load ~16 (m3-max-17871);
its program is 29,101 SIMD8 instructions, 34 spills, 10,585 non-SSA
registers.
- RADV, Radeon 780M: 1.3 to 3.0 s (m3-max-17958, -18098).
- RTX 3090, 620.70.06: 4.5 to 7.4 s (m3-max-17957, -18097).
Why no translator change: spirv-opt -O (186,314 words) and -O with
frozen specialization constants (180,402) leave ANV's NIR within 0.2%
(27,347 to 27,393 instructions) and its program within 9 instructions,
and their creations are no faster than the original's within the
run's noise (m3-max-18022, -18034, -18127). Holding half values in 16
bits across moves, phis and selects (a scratch pass on the -O module)
makes it 29,719 instructions with 103 spills. So the words the
translator emits do not drive ANV's time; the shader's own work does
(NIR: 4,163 fmul, 2,868 fadd, 1,689 ffma, 1,835 csel, ~290 samples,
30 loops).
VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT: ANV builds the same
program in the same time and the 3090 the same time; RADV takes 0.9
to 1.0 s (m3-max-18098), at a draw cost not measured. Nothing is
built around it. Doc only.
The known gap the frees' pacing answers in part: tests::import_free_hold_bench on an RTX 3090
(NVIDIA 620.70.06, quiet host, two runs) put a fill's commit to completion at 0.13-0.14 ms beside
no free, 0.46-0.54 ms beside runs of 512 KiB pointer or dma-buf imports freed one after another
(each free 0.26-0.39 ms), 2.6-2.9 ms beside 64 MiB imports (2.2-2.4 ms each), 1.2-1.6 ms beside
512 KiB plain host-visible allocations (1.1-1.2 ms) and 70-79 ms beside 64 MiB ones (28-30 ms);
paced, 0.10-0.32 ms beside every kind. An RTX 2080 on a loaded host showed pacing lower the median
beside every kind too. What stays open: a program's own release of a no-copy buffer frees its
import there (Metal's contract), unpaced, as does a completed command buffer's handler that frees
the imports its blits held last; one free still holds a submission that meets it.
submit_per_surface on the RX 7900 XTX, three runs at the tip: 128 surfaces list
256 dma-bufs (108 to 109 us in the ioctl) while in use and 128 after their idle
window (59 to 70 us). Text only.
The idle-release bullet says a texture in place over a no-copy buffer leaves
the buffer's import to the release (its blit reads the buffer as any blit), with
the 780M lane's counts (submit_per_surface, three runs: 128 surfaces list 256
dma-bufs while in use, 128 after the idle window). A known-gap entry records the
per-entry cost the raw probe measured on the 780M and the XTX (0.43 to 0.44 us
per dma-buf import per kernel submission), what Vulkan offers that does not
change it (memory priority, no device address, no pageable extension listed),
that separate submission calls list every import again, and that each in-place
texture's own image import stays listed for its life (RADV requires a dedicated
allocation of such an image).
The host_residency module doc and HOWTO section 6 told what a guest surface
listed before the in-place texture stopped pinning its buffer's import; docs
say what is true now. Text only.
RADV lists every imported VkDeviceMemory in every kernel submission, about
0.43 us each on the Radeon 780M and the RX 7900 XTX (a from-scratch Vulkan
probe, Mesa 26.2.6, Linux 7.3.3: 64, 256 and 512 dma-bufs held cost 31.5,
111 and 229 us an empty vkQueueSubmit against 7.2 with none). A consumer's
guest surface is a no-copy buffer over its pages and a texture in place over
the buffer: on RADV the texture is a DRM_FORMAT_MOD_LINEAR image in a
dedicated import of a dma-buf of its own pages, and making it read the
buffer's import apart (ReadApart::Texture), which kept the buffer's import
for good. So each surface listed two imports in every kernel submission for
its whole life.
The image asks the buffer's source for its own pages and binds none of the
buffer's memory, so its making now reads the buffer's dma-buf pages as a
blit does (HostImport::blit_pages: imported again where released, left
releasable), and the in-place watch a rebind reads takes the texels' offset
from the buffer's place in its host pages (Buffer::offset_in_host_pages),
not from their import. The buffer's import is then released after its idle
window like any blit-only one; the texture's image keeps its own import.
Pointer-imported pages, shadows and texel views still read the import apart:
they bind or read the buffer's memory.
Test: tests/host_residency.rs
a_texture_in_place_over_a_dma_buf_import_leaves_it_releasable: the buffer
under an in-place texture is released (its chunks leave
dma_buf_memories_live, the image's import stays), the texture reads the
CPU's writes made meanwhile without importing anything, and the buffer's
next blit imports it again. Without the change the release never comes.
Docs: host_residency.rs, HostMemory::with_dma_buf, HOWTO.md.
A render making's record of the driver's data, and the libraries of its
pre-rasterization and fragment shader parts, were named by the pass
shape whole, formats included. A program that makes one state against
passes that differ only in a colour attachment's format (RGBA8Unorm,
RGBA16Float, BGRA8Unorm) so got one VkPipelineCache per format, and the
driver compiled the same fragment module once in each: on the Iris Xe
(ANV, Mesa 26.2.6) 3.3 to 3.7 s per compile for one large module, three
times over at a cold start.
No stage's conversion reads an attachment's format through the pass: a
format the translation reads is in the stage's own words and constants,
which name the part's record too. So a part's record now names the pass
by PassShape::without_formats (which attachments it has, its samples,
fetch inputs, unread inputs, storage attachments, view mask and
locations), and the depth bias is left out of it as before. The library
names the runtime keys its own library objects by keep the formats (the
libraries are made against VkRenderPasses, which must be compatible);
only the driver cache record is shared. A driver that does key a stage
by format keys that entry apart in the one cache: a compile, never a
wrong pipeline.
The record-naming version (shader_cache/driver.rs VERSION) goes to 3.
METAL2VULKAN_LOG_PIPELINES now says, per library, whether its record
was loaded, missed or its cache shared with an earlier making, and
whether the driver found it in that cache or compiled it (from
VK_EXT_pipeline_creation_feedback).
Measured before the change (a harness making the module's fragment
library against three passes on the Iris Xe, MESA_SHADER_CACHE_DISABLE):
a cache per format, 3.5 s, 3.7 s, 3.3 s; one shared cache, 3.5 s then
0.0 ms and 0.0 ms, the second and third APPLICATION_PIPELINE_CACHE_HIT.
Tests: record_pass_formats (a pass's record name drops formats, keeps
presence, samples, fetch inputs and view mask);
driver_pipeline_compile::creations_over_colour_formats_take_the_first_s_records
(two makings over BGRA8Unorm and RGBA16Float share the first's record,
caches_shared grows by the makings, one fragment library compiled,
while a constant that changes the module keeps its own record);
creation_log's text test.
The logic-operation lane on an RTX 3090 (driver 620.70.06, job
m3-max-17707, at bdb59d55de): every out-of-range integer channel
(RGBA8Uint, RGBA8Sint, R16Uint, RG16Sint under xor and and) stores Metal's
saturated code through Vulkan's logicOp and through the fragment
function's operation, as on lavapipe. The FAST-PATHS known-gap row and
the private_state docs name both measured devices. No note: the spec
leaves the value undefined, and neither device differs from Metal.
A half fadd, fsub or fmul on the device's 16-bit arithmetic (ArithStrategy::F16:
MoltenVK, measured, and the float-controls profiles) was always kept apart: a
sum or difference decorated NoContraction and a product as Fma(a, b, -0.0)
decorated NoContraction, whatever the AIR's flags allowed. That holds Metal's
exact half bits at the cost of every fusion the flags allow (AGENTS.md rule 1:
the device's native arithmetic). It now decides as float does (contraction()):
an operation whose flags carry both contract and reassoc is undecorated, its
product a plain OpFMul, and the device's compiler groups and fuses it; any
other keeps today's form.
Notes mirror float's: note_rewrites already records FastMathRewrites where a
neighbour can be rewritten. On MoltenVK, Metal's fast compile folds an
undecorated 16-bit operation's conversions away and answers the float result
unrounded (the MetalHalfArithmetic measurement), so there a fast operation
records FastMathRewrites, whose doc (and docs/API.md's catalogue entry and the
FAST-PATHS device-gap row) now says so, and requires no MetalHalfArithmetic,
which the kept form still requires.
On an owned proxy (hnq_half_layer_composite) on the Iris Xe, the step-1
prototype of this form cut the SIMD8 cycle estimate from 58584 to 33092.
Tests: f16_binary's rounded-result and one-instruction tests under both
contractions; half_arithmetic_on_the_device_takes_the_airs_contraction
compiles fast, contract-only and flagless half + - * on every profile that
computes them in 16 bits and checks the instruction, its decoration, the note,
the requirement and the interpreted answers.
The 256 MiB bench at the two-pass comparison's tip (gem10, job 17674, load 6-7) took
5.9-6.1 ms each way where nothing changed, 26.1-26.4 ms in and 26.7-27.3 ms back where
every byte changed, and 25.9-27.5 ms (47.4 without masked stores) for the GPU's rewrite of
every float, the snapshot 15.4-15.8, 146-152, 206-215 and 280-289 ms beside it: the ranges
in FAST-PATHS and copied.rs's module docs now cover both runs. And a module-doc line past
100 columns is wrapped.
FAST-PATHS' base bullet gives the host's uncached reads of a device base (9-16 us a block
awake, 170-206 us idle on the RTX 5080 Laptop GPU's host), the blocks kept on the host, the
read back of 32 blocks or more on the staging queue with the crossover bench's figures on
the 5080 and the RX 7900 XTX, the GPU's wake from power-down a copy may wait for, and the
first and later merges back of a 256 MiB copy both sides wrote whole. Its cost bullet gives
the quiet gem10 run's figures (job 17408), and its kernel bullet the 5080's pass figures
(job 17417). HOWTO and API.md name copied_base_host_blocks and
copied_base_blocks_read_back.
Earlier commits 4af4a8665b and 7a93903404 carried doc edits with their code (the split's
sentence in API.md and HOWTO, copied.rs's cost bullet).
The merge back compares each block the GPU changed with the pages' own bytes where
their tag agrees, so a CPU write in such a block that the tag missed (at most 2^-64
a block a comparison) is undone where the GPU did not change its byte. A byte the CPU
writes while the merge runs keeps the CPU's or the GPU's.
The pull loop's while-let held the lock of the runs' iterator through each run's work,
so the threads took their runs one after another. The lock is now let go before the
work, as a let statement drops its temporaries.