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.
a_large_texture_over_a_private_buffer_lies_as_its_one_row_does_and_reads_right replaces the
pooled bound's test. A compositor's texture, 3840x2400 BGRA8Unorm that renders and samples at
rows of 15,616 bytes (37 MB) over a tracked Private buffer that declares its padding unobserved,
must take the placement its first row alone takes at the same pitch: the DRM_FORMAT_MOD_LINEAR
image in place wherever the device makes one, whatever the texture's bytes. Two frames each
upload texels into the buffer, read them through the texture, clear it through a pass and read
the buffer back; it prints the shadow texels copied in and back a frame (LARGE-POOLED) and, in
place, asserts none. With the 48 KiB bound still in the runtime it fails (the texture answers
Shadow(LinearCost), its row NotHostPages): the next commit removes the bound.
The 15 shapes of a guest boot's 1001 LinearCost shadows on an RTX 2080 (textures over Private
buffers that declare their padding unobserved), each weighed by how many it made: where the
placement query puts each alone over its bytes (the pooled bound read) and beside a one-row
texture made over them first (the image at Metal's pitch at any size where the device makes it).
Report only, ignored, run by name.
One texture over a Private buffer, BGRA8Unorm and RGBA16Float, 16 KiB to 4 MiB to its pitch and
the guest's 723x625 shape, in place at its pitch (a one-row texture made over the bytes first, so
the measured one takes the DRM_FORMAT_MOD_LINEAR image at any size) against a shadow, each frame
a compositor-like draw that samples it whole, the texture changing every frame or every 60th by a
render pass or by a blit into its buffer. Report only, ignored, run by name in release: the
numbers decide the bound on each device.
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.
The commits before this one. A texture over host pages made before its in-place verdicts is a shadow;
when the verdicts pass, Prepared::move_in moves it in place and ShadowAfterMove frees the shadow's image
and views once the committing command buffer completes. The move did not bump DeviceShared::views_epoch,
so the render encoders' bind memo (kept on the device, views keyed by texture address) still held the
shadow's view, and a later encoder's bind pushed a freed VkImageView. move_in now calls views_go on the
shadow, under its views lock, before the flag that lets the shadow be freed; the pooled-memory moves take
the same path. On every device.
Found by reims's per-draw repro in pages mode: SIGSEGV on the RTX 3090 about 70 s in (the original core:
the pushed combined image sampler's view was freed memory, its sampler intact; gdb m3-max-19818, 19829).
Test: tests::first_host_texture::a_surface_moved_in_place_is_drawn_through_its_image_once_its_shadow_went,
RTX 3090 (m3-max-19897): without the fix the later draw worked out 0 views and read wrong rows; with it
1 view, the new texels, pass. lavapipe (m3-max-19891) 29/29 of the touched files; lint three ways
(m3-max-19908, 19909).
A texture over host pages made before its pages' in-place verdicts is a shadow;
once they pass, a commit moves it in place (TextureShared::moved) and the shadow's
VkImage, views and memory go when that command buffer completes
(ShadowAfterMove). Render encoders' bind memo (binding::BindMemo) keeps each
texture slot's VkImageView by the texture's address, current while the device's
views epoch holds; the move changed the image the texture presents without
moving the epoch. A later encoder's draw then took the shadow's view from the
memo and pushed it after it was destroyed: on the RTX 3090 (NVIDIA 620.70.06) a
consumer's per-draw run with surfaces over host pages died with SIGSEGV in
vkCmdPushDescriptorSet (push_set <- Recording::record <- draw_resident; the
pushed combined image sampler's view object was freed memory). Before the
shadow went, the same draw read the shadow instead of the image in place.
The move now counts as the shadow letting its views go, under the shadow's
views lock, before the flag that lets ShadowAfterMove free it: every kept view
is dropped at the next bind, which works out the view of the image in place.
The pooled-memory moves take the same path. Docs of the epoch, the memo, the
counter and the storage-form module say so.
Verified: cargo fmt; the device runs are in the report.
A ShaderRead BGRA8 surface of tight rows over a no-copy buffer, made on a new
device before its in-place verdict, is drawn through its shadow; once the check
settles, the next commit moves it in place and its shadow's image and views go
when that command buffer completes. A later render encoder starts from the bind
memo the first encoder left its device: its draw must work out the texture's
view again (bind_views_worked_out) and read the texels the CPU wrote into the
pages after the move. Without a fix the memo hands it the shadow's view, which
was destroyed: on NVIDIA 620.70.06 (RTX 3090) vkCmdPushDescriptorSet faults on
it, as a consumer's per-draw run over host pages did (SIGSEGV in push_set,
binding 3, a combined image sampler whose VkImageView object was freed).
The draw and the blit helpers are shared with the odd-width test, which reads
as before.
Verified: cargo fmt; device runs follow in the fix's commit.
What: a_fill_is_recorded_at_its_call waits for the device's queue-switch check
(settle_queue_switch_check, 120 s) after making its command queue and before it counts, as the
other tests that read commands_recorded do (fill_waits, fill_queue, draw_again).
Why: the test's expectation went stale at RUNTIME_VERSION 2089 (24f233db8b). The check's rounds
now open their gate on the GPU with a vkCmdFillBuffer of the check's scratch buffer, recorded on
the check's thread, and WorkCounts::commands_recorded counts every command of the device whatever
the thread (its contract). The test counts all of the device's fills, so a check whose opening was
recorded between the test's fill and its commit read as "the fill recorded again": the RTX 5080's
runtime suite at pin 45 (m3-max-19738) saw 1 at the call and 2 after the commit.
Verified on the RTX 5080 Laptop GPU (NVIDIA 615.71.09), b5080 batch m3-max-19866, with a scratch
probe that counts the device's fills from before its first command queue until its check settled,
the program recording none: 0 at pin 44 (bf442ceb9e + the probe) and 1 at development 9768c1b352
(+ the probe), the check's verdict Idles at both. In that batch this commit's test passed (fills 1
at the call, 1 after the commit). The failure itself needs the check's recording to land inside
the test's window (it did under the suite's load); the unsettled test passed alone in the batch,
as it did in the other devices' suites.
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.
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.
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.
The commits before this one. A batch on another VkQueue waited on the GPU for every batch that did new
resources' first work (image first moves, staged texel copies, fills at a batch's start) until it
completed. Each such batch is now kept with what owns the memory its work wrote, and a batch waits for
it only where its commands may reach that memory (its uses name it or make it resident; a command
reaches unnamed memory, the root table or work recorded on the GPU alone; or the owner is unknown, the
device's own resources) or where the first work it took lies in that memory. Internal submissions still
wait for every one. On every device. Counted: WorkCounts::first_work_waits and first_work_waits_unused
(the conformance cost SUBMISSION group lists first_work_waits).
Measured, RTX 3090, release, one run (m3-max-19766), a compositor's frame p50 beside an app on another
queue:
- app making two 1024x1024 Private textures per command buffer: 17.07 -> 2.06 ms (2.10 with nothing
made); waits on unused first work per 4 s 247 -> 0;
- making buffers and textures: 12.07 -> 2.00 ms;
- a device with no fill queue: buffers 16.51 -> 2.12 ms (unused 231 -> 0), textures 17.07 -> 2.06 ms.
Test: tests::fill_waits::a_batch_that_reaches_no_new_texture_waits_for_none_of_its_first_work saw 16
unused waits before (fail), 0 after. The zero-read test now holds a heap texture and a plain Private
texture whose moves are taken behind a long load on another queue: both read what was written. 23/23
zeroed_start / fill_queue / first_move tests on the 3090 (19766), lavapipe 26/26 touched (19767), lint
19732. Not run: the 5080, RADV, Intel, MoltenVK.
Job m3-max-19766, one before/after on the RTX 3090 (before: c76b6d619a's code, every batch waiting for all of it; after: 22064bea33). tests::fill_waits_bench, the compositor's frame p50: app making textures 17.07 -> 2.06 ms (247 -> 0 unused waits in 4 s), buffers and textures 12.07 -> 2.00 ms; on the device made with no fill queue, buffers 16.51 -> 2.12 ms (231 -> 0), textures 17.07 -> 2.06 ms. tests::fill_waits::a_batch_that_reaches_no_new_texture_waits_for_none_of_its_first_work: 16 unused waits before (fails), 0 after (passes); zeroed_start, fill_queue, first_moves and first_move: 23/23 after.
A batch on another VkQueue waited on the GPU for every batch that did new resources' first work until it completed, whatever it used: on the RTX 3090 a compositor's one-dispatch frame took 17 ms (p50) beside an app making two 1024x1024 Private textures per command buffer, against 2.1 ms with nothing made (tests::fill_waits_bench, job m3-max-19457), and so for new buffers' fills at a batch's start on a device without a fill queue. Now it waits for those whose work wrote memory its encoders' uses name or make resident, every one where a command may reach memory no use names or where the work's owner is unknown, and those whose memory its own first work lies in, which comes after theirs. Internal submissions still wait for every one. Evidence to follow in the next commits' jobs.
Each batch that did new resources' first work (images' moves, staged copies into them, fills at its start) is now kept until it completed with what owns the memory that work wrote: the owner under the image's key, the staged copy's image key or the fill's key (used_resources::owner_of), learned at the take on every device (FillTake::Owned where the device has no fill queue). WorkCounts::first_work_waits and first_work_waits_unused count the batches that waited for such work, and those whose commands and own first work reach none of it. Every batch still waits for all of it; the narrowing follows. tests::fill_waits gains a_batch_that_reaches_no_new_texture_waits_for_none_of_its_first_work (fails on unused until the narrowing), and the zero-reach test's textures are moved behind a long run of kernels on another queue.
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.
The commit before this one. When a command queue went long, its one move (queue_share.rs settle)
took the least recently used idle VkQueue whoever held it, so it could land on the VkQueue a
compositor had just moved to. Seen on the RTX 5080 (nv5080reg's run at 66942365f6):
a_compositor_beside_a_queue_waiting_on_the_gpu_for_long_work_keeps_its_latency failed with p99
21.52 ms, 128 stalls of 9467: at 37.0 ms the compositor left VkQueue 1 for idle VkQueue 2, at 37.2 ms
the waiter's move picked VkQueue 2 too, and the compositor sat behind its 30 ms waits until 103.3 ms.
settle now takes an idle VkQueue no command queue holds where one is, else the one the fewest hold,
least recently used among equals: the rule 2084 gave placement and unshared queues.
Test: a_long_queue_settles_on_an_idle_vk_queue_no_command_queue_holds_before_a_held_one fails on the
old rule (m3-max-19728: left Some(2), right Some(3)); queue_share pure tests 9/9 (19727); clippy plain
(19752) and m2v_gpu (19753). Not run with the fix: the device test on the 5080 or the 3090.
Also landed (no behaviour change): examples/queue_plan_cost.rs gains --rooms, --runtime-rooms,
--runtime-fill and --overlap, and made_within_resources' doc says why a refused device takes its least
plan at once. Stepping down (18, 11, 7, 3 VkQueues) was measured against it: on the RTX 2080 eGPU it
made one device of 11 queues instead of 3 and two more devices refused (12 vs 14 made; 19615/19616);
on the 3090 it changed nothing and added 0.42 s to the device that took 3 (19620/19622).
A long queue's one move (settle) took the least recently used idle VkQueue no long or unshared
queue held, whoever else held it. On the RTX 5080 Laptop GPU (nv5080reg's run of
a_compositor_beside_a_queue_waiting_on_the_gpu_for_long_work_keeps_its_latency at 66942365f6) the
waiter queue went long on VkQueue 1, the compositor left VkQueue 1 for idle VkQueue 2 at 37.0 ms,
and the waiter settled on VkQueue 2 at 37.2 ms: the compositor sat behind its 30 ms waits again
until 103.3 ms, 128 samples over 10 ms in the 2 s window, p99 21.52 ms. settle now takes, of the
idle VkQueues no long or unshared queue holds, one no command queue holds where one is (else the
one the fewest hold), least recently used among equals, as placement and unshared queues do
since 2084.
Test: a_long_queue_settles_on_an_idle_vk_queue_no_command_queue_holds_before_a_held_one (the
compositor's VkQueue used longer ago than an empty one: the old rule took the compositor's).
Verified: cargo fmt; tests and the device repro in the following jobs.
made_within_resources now says why it takes the least plan at once rather than plans between: on a
GPU out of channels, what one refused device takes the next is refused. Measured with
queue_plan_cost --runtime-fill (one runtime device per process) at RUNTIME_VERSION 2084 against a
step-down branch (steelbrain/queuestep a595a24225: round robin halved on each refusal, 18 then
11, 7 and 3 VkQueues):
- RTX 2080 (Thunderbolt, 620.70.06): least at once 11 plan + 3 least devices, the 15th refused
(m3-max-19615); stepping down 11 plan + one of 11, the 13th refused (19616).
- RTX 3090 (620.70.06): 58 plan + the 59th least either way; stepping down added 0.42 s to the
59th (1111 vs 688 ms) and 0.21 s to the refused 60th (612 vs 398 ms) (19620, 19622).
- Refused vkCreateDevice of 7 to 15 VkQueues beside 12 runtime devices on the RTX 2080: 237 to
270 ms each (19639, --runtime-rooms).
The example's overlap phase docs no longer speak of steps.
Verified: cargo fmt; the numbers are the jobs named.
For the plan's shape and each step a refused device takes (16+2, 9+2, 5+2, 1+2 on NVIDIA), K
processes make one device each at the same moment: each vkCreateDevice's time and the time until
all K were made, as when every device of a GPU is made again at once after a device loss. Asked
for by the orchestrator alongside the step-down measurements.
Verified: cargo fmt; built and run in the next jobs.
Device::system_default_with returns the live device of equal options, so the runtime fill child
made one device per process and held five more handles of it (job m3-max-19562, on the RTX 2080:
0 ms for each after the first). Each device of a child now takes a shader cache directory of its
own. The runtime rooms phase holds N runtime devices and probes which bare queue counts the driver
still makes beside them: on the RTX 2080 a runtime device holds more than a bare device of its
queues (66 bare devices of 3 queues left room for 18; the 12th runtime device was refused 18).
Verified: cargo fmt; built and run in the next jobs.
The rooms phase holds K devices of the plan's shape and N of the least
plan's, then asks for a device of every graphics-family count from the
plan's down to one, timing each vkCreateDevice: which queue counts the
driver accepts beside what is held, and what a refusal costs. The
runtime fill phase fills the GPU with the runtime's own devices, each
printing its make time and the VkQueues it took. Both measure the step
down from a refused queue plan; neither runs unless asked.
Verified: cargo fmt; built in the next job.
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.
The commits before this one. On a device with a fill queue (NVIDIA, 2074), every other submission
waited on the GPU for the fill queue's last fill until the host saw it complete, fills it never
touched included. A batch now takes and waits for only the fills of memory its commands may reach:
memory its uses name or make resident; everything where a command reaches memory no use names, or
where it took a move in another resource's memory or a staged copy; and the device's own buffers.
Internal submissions still wait for the fill queue's last submission; other devices take every fill
as before. Counted: WorkCounts::fill_queue_waits and fill_queue_waits_unused.
Measured (release; a compositor's one-dispatch frame while an app on another queue makes two 4 MiB
Private buffers per command buffer):
- RTX 3090: p50 9.0 -> 2.10 ms (2.10 ms with nothing made); frames that waited for fills they never
use, per 4 s, 424-429 -> 0 (m3-max-19457).
- RTX 5080 Laptop: p50 13.2 / 7.5 -> 1.18 ms (1.18-1.36 with nothing made); unused waits 288 / 430 ->
0 (b5080 fillq-ab-233804, batch m3-max-19646).
Shared texture makings wait for no queued fill: p50 <= 0.011 ms, max 1.33 ms, both GPUs.
Test: tests::fill_waits::a_batch_that_reaches_no_new_memory_waits_for_none_of_its_fills saw 8 unused
waits and failed before the fix, 0 after (3090 19457, 5080 19646); zero-reads passes (19739);
zeroed_start / fill_queue / first_move tests 22/22 on both GPUs; lavapipe 24/24 touched (19668);
lint 19638, rustdoc 19732. Not run: RADV, Intel, MoltenVK (no fill queue there).
State::reaches_unnamed is set by root tables, work recorded on the GPU alone and records resolved by host steps; a render encoder's handle-table reads set only that encoder's own flag (linear attachments). What a handle reaches is what Metal asks the program to make resident (useResource, useHeap), which the uses' check reads (used_resources::names_any). Docs only.
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).
ob2_loaded_pointer stores tid | 0xb0000000 into the words its indices 8 to 15 name. They named words 8 to 15 of the new buffer, which the copies on the other queues read in no order with that kernel, so the test failed 6 of 10 runs on the RTX 3090 with the code before the narrowed take and 9 of 10 with it (job m3-max-19536): a race in the test, not the runtime's zeros. The copies now read the first half alone, and the stores go to the second.
On the RTX 3090 the code before the narrowed fill take (8c8dbec6b5) failed this test at its first batch's read (job m3-max-19457); the message now says which reads saw what, so a failure tells a late fill from another writer.
The app makes, by phase, nothing, two 4 MiB Private buffers, two 1024 x 1024 Private textures, or
both, before each command buffer; each phase ends with ten 1024 x 1024 Shared textures made while
the app's work and its fills are queued, their makings' host times printed. Texture moves are the
other first work a batch takes whatever it names, and a Shared texture's making is to wait for no
queued fill: the phases measure both.
Verified: cargo fmt. Runs follow as potluck jobs.
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.
Every batch and internal submission waits on the GPU for the fill queue's last submission until
the host saw it complete (device/staging.rs), and a batch takes every fill waiting, whichever
buffers its commands name. Neither is counted: nothing says how often a batch waits for fills its
commands never use.
What: each fill notes what owns the memory it writes (Filled::owner: the program's buffer, kept
by its key among the device's owners, or the heap a buffer is placed in or whose own buffer it is;
None for the runtime's own buffers), each fill-queue submission keeps them until the host saw it
complete, and a batch that waited on the GPU for its own fills or another's is counted
(WorkCounts::fill_queue_waits), and counted again where its commands reach none of that memory:
no resource its encoders' uses name owns it and none of its commands may reach memory no use names
(WorkCounts::fill_queue_waits_unused, State::parts_reach). No wait changes here.
Tests: fill_waits (a compositor's batches beside an app that makes a new buffer each round, and
new memory read by name, through a loaded pointer and as a heap's texture) and the release bench
fill_waits_bench. fill_waits' count assertion fails on a device with a fill queue until the next
commit narrows the waits: it is the negative control.
Verified: cargo fmt; api_signatures.tsv blessed. Builds and device runs follow as potluck jobs.
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.
A state of a NaN lodBias failed the debug check that a stage table brought
in place reads as the table read whole (argument_table.rs check_reading):
the bound sampler carried the state's descriptor with its NaN bias, which
== takes for unequal to itself. The M3 MoltenVK run of
runtime_lane::lod_bias panicked there (potluck job m3-max-19703).
The state samples every level as with no bias (Metal's answer on Apple9,
measured on the M3 Max, macOS 27.0.1), so taken_descriptor now gives the
descriptor a state samples with a bias of 0. Every bound sampler, bind memo
and kept execution then compares as for an unbiased state; the SamplerKey
still keys by the request's bias, so a state of another bias stays another
state. same_as_printed compares the bias as it prints, like the clamps, and
the field-list guard in tests/argument_table.rs names lod_bias.
Tests: tests::sampler takes ten biases (signed zero, ±16, 100, MAX, NaN,
the infinities) to the unbiased taken descriptor, normalized and pixel;
tests::argument_table pairs biases of opposite zero signs, NaN payloads
and NaN against 0. Device runs follow.
The runtime lane test for a sampler's lodBias called new_library_with_air
without the AirLibrary trait in scope, so the validation crate's test build
under --cfg m2v_gpu failed with E0599 (potluck job m3-max-19692). Import it
as the sibling mip_levels and kernel_lod modules do.
Verified: the M3 gpucfg build failed with exactly this error; the rebuild
follows.
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.
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.
The commits before this one. On the RTX 5080 a guest's Shared no-copy buffer is a copied host buffer
(NVIDIA imports no such pages), and reims attaches no dirty log, so every commit compared the whole
copy: a copy-in with no base ran on one thread (a 256 MiB kernel-read pass spent 27-31 ms committing
against 10 ms of GPU time), and the merge back after a kernel's writes on at most four. A copy-in with
no base now splits across threads as one with a base does, a block that differs is stored whole,
splitting starts at 4 MiB (was 16), and the cap is eight threads (was four).
Measured (RTX 5080 Laptop, release, b5080 entry nvcopybw-nvcopybw-5080-ab-234252, batch m3-max-19706),
a kernel reading a 256 MiB copied buffer: 6.5 -> 12.3 GB/s at four threads (commit 30.8 -> 11.2 ms),
14.1 GB/s at eight; 64 MiB 7.1 -> 11.2 GB/s; CPU writes then a read of 256 MiB 2.0 -> 6.6 GB/s (9.0 at
eight). A guest benchmark read 4.4 GB/s here before; the Metal oracle (Radeon Pro 5300M) reads 6.1.
Kernel writes unchanged at 4.8 GB/s at four threads. The 3090 before/after is m3-max-19454.
Test: tests::copied::a_copy_in_with_no_base_splits_across_threads_and_answers_as_one_thread_does fails
at 28bce80c63 and passes after (m3-max-19343). Bench: tests::copied_bandwidth_bench (ignored).
Lint and lavapipe at the branch tip (m3-max-19729) ride the checks after landing.
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).
27c4a1ae46 made store_masked sixteen byte stores, each not set aimed at the
stack, to take no branch on the mask. On the RTX 5080 Laptop GPU's host (a Core
Ultra 9 275HX, no AVX-512) it made the merge back slower, not faster: a 256 MiB
kernel-write pass's merge back took 65.3 ms against 38.1 ms with the branchy
stores, 64 MiB 21.1 against 9.3 ms, 16 MiB 10.5 against 4.4 ms
(copied_bandwidth_bench, two rounds interleaved with 28bce80c63 and d33e19bc70,
b5080 entry nvcopybw-nvcopybw-5080-ab-234252, batch m3-max-19706). On the
i9-13900H (ms01, m3-max-19305) it was 63.9-68.7 ms against 58.9-60.5 ms.
This restores the fewest stores of 8, 4, 2 and 1 bytes that write the set bytes
alone, and the docs that describe them. A host with AVX-512BW and AVX-512VL
never ran either form (its masked store).
Tests: the merge tests (a_merge_stores_each_byte_it_writes_and_no_other,
copied_comparisons_answer_as_byte_by_byte) cover it; run after the next commit.
The CPU-side counterpart of copied_bandwidth_bench's copied-t8 rows: bench_256
with copied::SPLIT_THREADS_FROM at 8, to measure on the hosts without a GPU
hold whether a copy's comparisons scale past the runtime's four threads.
A test-only switch, copied::SPLIT_THREADS_FROM, sets the most threads a
comparison runs on in place of SPLIT_THREADS (4) where not zero; split_threads()
keeps the host's count in its OnceLock and applies the switch on each call. The
bench adds a copied-t8 subject (a copy with no log, its comparisons on up to
eight threads) beside copied, copied-logged and own-shared, to measure whether
the merge back of a rewritten copy scales past four threads on the hosts of the
RTX 5080 Laptop GPU and the RTX 3090. Not run yet.
96009744c0 made each comparison prefetch the block a page ahead. On a Core i9-
13900H (homelab-ms01-1, job m3-max-19305: tests::copied_bench::copied_256_bench,
three rounds interleaved with the commits before it) the merge back of a 256 MiB
copy whose every float the GPU rewrote took 76.1 and 76.9 ms with it, against
63.1-68.7 ms without it and 58.9-62.4 ms before 27c4a1ae46; the copy in of an
unchanged copy did not move beyond the rounds' spread. Sixteen prefetches a block
on each side compete with the comparison's own reads for the line fill buffers,
and the host's prefetchers already follow the comparison's runs.
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.