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.
A compute creation whose descriptor requires a threadgroup size of more threads than its
kernel's own [[max_total_threads_per_threadgroup(n)]] is now refused,
RequiredThreadsProblem::OverKernelMax, as Metal's first compile of the kernel refuses it. The
runtime made such a state and answered the kernel's maximum.
Measured on the M3 Max under macOS 27.0.1, compute_pipeline_limits.m with a salt
(m3-max-17580), each case a first compile and the same again in its salt:
required-128-attribute-64 is refused both times, code 3, "requested required threads per
threadgroup 128,1,1 but 'count64' expects max threads per threadgroup 64";
required-32-attribute-64 is made answering 32. After a compile of the kernel with no size,
Metal makes the 128 state and answers 64. The runtime answers as the first compile, every time,
as it already does for the other history-dependent answers (docs/API.md, accepted differences).
How: the check runs after the compile (additions::check_kernel_maximum, called from
of_kernel), not in the translator's compile: the required size is no part of the compiled
pipeline's key, so a pipeline of the kernel found in the memo, an archive or the disk cache
would skip a check there. It reads the kernel's maximum through a new public accessor,
CompiledFunction::max_total_threads_attribute. A tile function's own maximum beside a
required size is unmeasured and not checked.
Also: the probe header records the salted answers and the descriptor-validation stops of
m3-max-17549; docs/API.md's accepted difference and the additions.rs module docs name the
refusal; docs/REFUSALS.md regenerated; api_signatures.tsv blessed (two additions: the variant
and the accessor).
Test: runtime_lane::compute_threadgroups::
a_required_size_past_the_kernels_own_maximum_is_refused_every_time refuses 128x1x1 and 16x8x1
beside 64 before and after a state of the kernel is made (the second finds the pipeline
compiled), makes 32x1x1 (32) and 8x8x1 (64), and makes 128x1x1 for the kernel without a
maximum.
Verified: nothing yet; the lavapipe run of the test and the lint follow.
Post-merge evidence m3-max-17539 (msi, lavapipe lane at 0103821834) failed
the_logic_operation_over_a_signed_channel_s_lowest_code: Vulkan's logicOp
over an RGBA8Snorm channel holding 0x80 stored the operation of the raw
code (xor of 0xe0 gives 0x60, equivalence 0x9f) where Metal reads 0x80 as
0x81 and stores 0x61 and 0x9e, through a pipeline that recorded no note.
The Vulkan specification's logical operations take "the color attachment's
R, G, B or A component value", the stored code itself, so this is the
device's native form (rule 1): it stays, and is recorded.
lower::fragment::logic::vulkan_differs replaces widens as the test
note_vulkan_codes applies: a 10-bit unorm format, or any signed normalized
one. Docs: PrecisionNote and Degradation docs, API.md catalogue, the
FAST-PATHS known-gap row (now also citing the spec's "undefined" for
integer outputs past the channel's range, which lavapipe saturates as
Metal does, so no note), private_state and logic module docs, the
conformance replay bullet.
The unwritten-channel half of the item (masked channels, and no-op, which
draws unwritten, keep 0x80 where Metal stores 0x81, in both lavapipe forms)
is the existing snorm-minimum-kept notice: Metal's pass writes each tile
back through its values. The lane now accepts a kept lowest code only
where the device announced snorm-minimum-kept, and the integer test fails
any non-Metal answer that comes through no NativeLogicOperation pipeline.
Tests: the translator unit test
vulkan_s_operation_differs_on_10_bit_and_signed_codes_alone, the engine
test's lavapipe assertions (RGBA8Snorm and R16Snorm xor noted). Evidence
jobs follow on lavapipe (both forms) and the translator suite.
A consumer acts on a refused import, a failed one and a move apart, and rule 2
says each degradation is announced; the kind-level once let a gate's refusal
silence a later failed import on the same device. Device::degrade_copied_pages
keys copied-host-pages by its CopiedBecause cause (and a buffer lying in
another's live copy as a reason of its own) with a bit per reason in the
device's Announced record. Device::degrade keeps its rule for every other
kind; both share degrade_where (lowering refusal, replay, announce_each,
placement), so only this kind's record changes.
Test: copies_of_two_causes_on_one_device_are_each_announced, a refused copy
then a failed one (fail_next_host_imports) both heard with their reasons, a
second refused copy not. docs/API.md states the rule and the entry.
exit destroys the exiting thread's thread-locals before it runs the exit handlers (macOS, the
GNU C library), and LocalKey::with on a destroyed one panics, which in a handler aborts the
process. The exits lane case an_exit_handler_s_common_calls_answer_as_on_any_thread aborted
there on both: "cannot access a Thread Local Storage value during or after destruction" in
calls_at_exit on the M3, and on lavapipe at warm::pass::warming from PipelineMemo::compute,
in the handler's new_compute_pipeline_state.
Every runtime thread-local whose type needs dropping that a program's call reaches is now read
with try_with, with what the thread does once it can keep nothing:
- the making budget's turn (pipeline/budget.rs): program_turn takes none there, holds_turn is
false, and a turn's give-back and lend read the note with try_with;
- the driver facts' expectation (driver_facts.rs): expecting runs the call alone, its messages
relayed;
- the creation log's split (pipeline/creation_log.rs): none noted;
- the warm pass (warm/pass.rs): none;
- a relayed compile's held sink messages (device/compiles.rs): the call alone, its messages
delivered as raised;
- a lowering's refusal (render/deferral.rs): lowering::refusing is false there, so a notice of
a kind the device refuses while lowering is announced, as anywhere else;
- the debug-build checks of kept resident uses (binding.rs) and of slot rebinds (the
translator's bind/graphics.rs): skipped.
dirty_pages, shards, resource_ids and contexts already read theirs with try_with; the rest hold
Copy values with no destructor. docs/API.md's accepted differences under "Process exit" say what
an exit handler's calls keep no state for.
Metal's private logic operation into RGB10A2Unorm and BGR10A2Unorm widens each channel's codes to
16 bits, operates and narrows back (probe logic_operation, M3 Max). A device with Vulkan's
logicOp draws with Vulkan's operation, the device's native form (rule 1), which works on the
10-bit codes themselves and can store another code (lavapipe's xor: green 938 where Metal's rule
gives 937). docs/FAST-PATHS.md's known-gap row ended "No note records it".
DeviceColorConversion could not carry it: every device that has logicOp (lavapipe, RADV, ANV,
NVIDIA) already records that note for any float write into a unorm attachment, so it would
neither tell this difference apart nor be absent where the fragment function computes Metal's
rule. So a new note, NativeLogicOperation (degrade code native-logic-operation, a native note):
the render pipeline's fragment stage records it exactly where Vulkan's logicOp operates on an
attachment whose codes Metal widens (lower::fragment::logic_widens, structural on the channels'
write rules: the 10-bit unorm formats), that a first output writes (GraphicsState::color_outputs)
with a channel its write mask keeps. The runtime announces it through the stage's notes, as every
note. The fragment function's operation records none.
Docs: FAST-PATHS's known-gap row names the note; API.md's catalogue gains the entry; the
conformance suite's NATIVE_NOTES and the validation comparison's allowance (unbounded) class it;
api_signatures.tsv re-blessed. REFUSALS unchanged (refusal_surface.py --check passes).
Tests: engine_private_render_state's logic test asserts the note on lavapipe's Vulkan xor into
RGB10A2Unorm and BGR10A2Unorm, and its absence for RGBA8Unorm, RGBA8Snorm, R16Unorm and
RGBA16Float, under copy, with an empty write mask, at an attachment no output writes, on MoltenVK
(the function's operation) and on lavapipe without logicOp; logic::tests the widened formats; the
lane runtime_lane::logic_ops asserts the note on each draw it counts as the 10-bit codes' own and
that the device announced native-logic-operation exactly where it has logicOp.
Verified: cargo fmt; scripts/api-signatures --bless; refusal_surface.py --check. Builds and
tests follow as potluck jobs.
Under UnsharedIsolationPolicy::Bounded, another queue's batch on an unshared
queue's VkQueue is held until its room comes, keeping its place in the order.
A pass that came only after the room came (the scheduler's thread, or a
waiting thread's pass, run late by a loaded host) found that batch and the
unshared queue's command buffer ready together and sent them in commit order:
the whole held batch, about 30 ms in the pin 39 round's 5080 runtime leg, went
ahead of the unshared one, which the hold exists to keep from waiting.
Order::next now takes `first`: the heads it puts first are asked before the
others, each still behind any earlier batch it conflicts with that keeps its
place (is_behind), so tracked order across queues stays commit order. Both
passes (the thread's and a committing or waiting thread's) put first an
unshared queue's head on a VkQueue that holds other queues' work back for it
(CommandBufferShared::goes_ahead_of_held_work); under Off, and for every other
queue, the order is unchanged.
Tests: a_late_pass_sends_an_unshared_queue_s_command_buffer_before_work_let_go_with_it
(the device test from the commit before, which fails without this), and
a_head_put_first_goes_before_the_ready_heads_committed_before_it (Order alone).
docs/FAST-PATHS.md's NVIDIA dma-buf stall bullet adds the result of the form and type order with a
kind's first imports one at a time on 615.71.09: 6 of 6 four- and eight-thread probe runs ended on
the RTX 5080 Laptop GPU, in 8 to 9 s each (potluck m3-max-17361, three runs of each probe, at
branch steelbrain/nv5080fails-serialform, which carries this branch's code on the earlier base).
Before it, with the type order alone, both probes stalled in their first run (m3-max-17118); with
every import serialized and the type order alone, 2 of 4 runs failed (m3-max-17296).
The stall stays open for a kind's first imports, which still try a refused form or type.
On the RTX 5080 Laptop GPU (NVIDIA 615.71.09) the four- and eight-thread leak probes still
stalled with the type order alone. A failed import there can spin inside vkAllocateMemory while
holding the driver's lock. With every failed import printed (potluck m3-max-17206, a scratch
commit that also tried no host-visible type), 4346 of the probe's 6000 imports failed first: type
0, dedicated to nothing, ERROR_OUT_OF_DEVICE_MEMORY, for udmabufs of scattered pages from 16 KiB
to 63 MiB. Each then succeeded dedicated to its buffer. The type order cannot remove these,
because they are a refusal of the form, not of the type. Locking every import alone did not stop
the stall either: 2 of 4 runs still stalled, every import failing twice before it succeeded
(m3-max-17296).
The order extends from type to form and type. Each kind remembers the form (dedicated to its
buffer or not) and the type its last import succeeded as (Memory::dma_buf_imported_as), and
tries that pair first. Every other pair is still tried after it, in today's order. worked_first is
generic over what it orders. On 615.71.09 a no-copy buffer's imports then go dedicated first and
no longer fail in steady state. On 620.70.06 the pair is (dedicated to nothing, type 0), as
before. The import's third value now says whether the memory is dedicated to its buffer, made so
now or because an earlier import of its kind found that form
(WorkCounts::dma_buf_buffer_imports_dedicated counts the same imports). The dedicated-allocation
info is renamed so that it no longer shadows the attempt's form.
docs/FAST-PATHS.md records 615.71.09's refusal of the form, the order, the first-import lock, and
the stall's runs on 615.71.09.
Test: memory::a_dma_buf_import_tries_the_form_and_type_its_kind_last_imported_as_first covers
the pairs: a buffer's attempts with the dedicated form put first, and with the undedicated form
put first; a shared import, which has no dedicated form; and the type cases as before.
Verified at this change's sources (branch steelbrain/nv5080fails-serialform, which carries the
same code on the earlier base):
- CPU: 31 of 31 tests pass (potluck m3-max-17327).
- RTX 2080: 31 of 31 touched tests pass (m3-max-17331), including host_ram_dma_buf x12 and
no_pointer_import x2, which cover the dedicated retry. The probes ran in 28.8 s (four threads),
56.8 s (eight threads) and 16.8 s (one thread).
- RTX 3090: 31 of 31 pass (m3-max-17358). The probes ran in 41.7 s, 69.2 s and 18.0 s.
Job m3-max-17323: under lavapipe's logicOp the lane's xor and equivalence draws into
RGB10A2Unorm (blended and not) store exactly the per-channel texel, 4 draws, where Metal's
rule widens the codes to 16 bits.
The probe (job m3-max-17294 on the M3 Max) confirms Metal's rule for the 10-bit unorm formats at
all 12,800 texels of its formats and masks cases: each stored code widened to 16 bits
(round(d * 65535 / max)), the operation on it and the output's 16-bit code, the result narrowed
back to the channel's code. The fragment function's operation now computes it as a 16-bit
channel's (logic::channels answers 16 for a 10-bit or 2-bit unorm channel), the device's write
narrowing the result, so these formats are no longer refused under the function's operation.
Vulkan's logicOp, which a device that has it draws with, operates on the 10-bit codes
themselves: recorded as a known gap in FAST-PATHS. The lane now checks Metal's rule for
RGB10A2Unorm and counts apart the draws that store exactly the per-channel rule's texel under
Vulkan's operation. Translator tests: RGB10A2Unorm compiles under the function's operation on
MoltenVK and on lavapipe without logicOp; B5G6R5Unorm is refused there.
Not yet built or run.
docs/REFUSALS.md regenerated: PrivateRenderState's reach names the three features of the
operation's refusal on a device that orders fetch in neither form. The signature table gains
LoweringInputs::logic_operation and RuntimeInput::LogicOperation. The probe's header states
what it measured on the M3 Max.
The per-lane loop zips the format's channels instead of indexing them (clippy's
indexing_slicing in lower). FAST-PATHS's known gap now names what the function's operation
still refuses, and API.md's DeviceColorConversion entry names the operation's conversion.
The accepted difference said the work that needed such a making fails; what
that work's command buffer then answers was not run. It now says what was run:
the making answers that the process is exiting.
Verified: docs only.
An exit handler a program registers once its device is made (the consumer's exit
gate) commits work at exit and waits for it, as Metal's exit runs it. The runtime
registers its hook again after every pipeline making, for the destructors the
driver's compiler registered in it (the 5080's SIGSEGV in libnvidia-glvkspirv.so,
lavapipe's LLVM destructors), so with any making after the handler the hook ran
first, closed the guard, and the handler's wait answered Exiting: the exits
lane's handler_work_exit failed 3 of 3 on the 3090 (m3-max-17079).
Each registration now carries what it follows (exit_guard::After: the argument
of on_exit on glibc, of __cxa_atexit elsewhere), and its run ends what the
destructors registered just before it may break:
- after a making (pipelines_made, the 2 ms registrar): the run ends the makings
(Guard::end_makings) and waits for those in progress in sections, at most
MAKING_BOUND, as the close did; no making begins after, on any thread
(driver_making answers None, and the makings' callers WaitWouldDeadlock of
DeadlockCause::Exiting). The guard stays open, so the program's handlers
registered before that making run with the runtime's threads.
- after a device, an instance or a section's first call: the full close, as
before.
- beside a live CPU device (lavapipe, SwiftShader), whose queues compile as they
run their work, a making's run is a device's (the close): measured before, a
queue's compile beside the exit's destructors ended 5 of 300 lavapipe exits.
handler_work_exit expects that there (hook_ran=1, Exiting), and docs/API.md
records it as an accepted difference, with the making a handler begins.
Tests (runtime, exit_guard): a_making_s_run_of_the_hook_leaves_the_program_s_
handler_the_guard_open, the_device_s_run_of_the_hook_closes_the_guard_after_a_
making_s_run, a_making_s_run_of_the_hook_closes_the_guard_beside_a_cpu_device,
the_makings_end_once_those_in_progress_ended_and_none_starts_after,
a_making_s_run_ends_the_makings_alone_in_its_own_process; the makings' earlier
tests keep their meaning (a_pipeline_making_that_returned_registers_the_hook_
again now sees the makings ended and the guard open). The exits lane's
handler_work_exit is the contract test.
Verified: cargo fmt only locally; build, lint and runs are potluck jobs.
METAL2VULKAN_LOG_MEMORY's registry entry and docs/API.md now name the line
the log writes where a placement takes a kept empty dedicated block, which
allocates nothing (memory.rs's place_kept_dedicated).
dma_buf_leak_4_threads ended in SIGABRT and dma_buf_leak_8_threads in a GPU recovery
(GpuRecoveryVictim) on the RTX 5080 Laptop GPU (NVIDIA 615.71.09, round job m3-max-16620 at
600b535875). On the RTX 3090 (620.70.06, round job m3-max-16728) dma_buf_leak_8_threads ended on
Rust's I/O safety check, with "owned fd already closed" in import_dma_buf's drop of its clone.
The cause is the driver's handling of a failed import. NVIDIA lists a udmabuf of host pages as
two memory types, 0 and 4 (host-visible, coherent, cached), and refuses every import as type 4
as out of device memory. The runtime ranked type 4 first. strace -f -k under the eight-thread
probe on the RTX 2080 (620.70.06, potluck m3-max-16817) showed that every failed import closed
the descriptor it was handed. Vulkan gives the descriptor to the driver only on success. In 3
of 10 failed imports the driver closed the same number twice within the one call, with two
more opens of /dev/nvidiactl between the closes. The kernel gives a new descriptor the lowest
free number, so between the two closes another thread's new udmabuf took the number, and the
second close closed it. That thread then imported a third thread's dma-buf under the number,
and the process aborted on the I/O safety check.
- handed_descriptor.rs: an import hands the driver a clone at a number kept for imports in
flight. The range is the 64 numbers below min(soft RLIMIT_NOFILE, 65536). The clone is taken
with fcntl(F_DUPFD_CLOEXEC, n) and kept only where it landed on n itself, never by dup2, and
no two imports in flight hold the same number. So a number the driver closes stays free until
the import returns, and a second close reaches nothing. After a failure, the number is still
the import's alone, so whether the driver left it open is read without a race and, where it
did, it is closed. That also ends the leak of one descriptor per failed import on a driver
that leaves it open. Where the limit is under 256, the process holds the range itself, or
more than 64 imports are in flight, the clone is an ordinary one: correct, but unprotected,
and a failed import lets it go rather than close a number that may be another's by then.
- memory.rs: each kind of import (what it backs, and its memory class) remembers the type it
last imported as, and the next import of that kind tries that type first (worked_first). Every
other type is still tried after it, in today's order. In steady state this avoids the import
the driver refuses, along with its closes and the stall below.
- docs/FAST-PATHS.md, known gaps: the type listing and refusal, the closes, the kept numbers and
their fallback, and the stall. A failed import can spin inside vkAllocateMemory holding the
driver's lock: 3 of 7 four-thread runs on the RTX 2080 alone, and one on the RTX 3090. It
stays open for the first imports of each kind, which still try type 4.
- tests/dma_buf_fds.rs (device test): what a driver does with the handed descriptor, for each
type, size and form. It checks that no number the driver let go of is closed again later. A
let-go number is taken by F_DUPFD_CLOEXEC and watched only where the clone landed on it.
Tests: handed_descriptor (CPU) drives Handed with stand-in imports. One driver closes the
number twice with another thread's open between the closes. Another leaves the clone open on a
failure. Imports in flight each hold a number of their own. A test covers the range for low,
high and unlimited limits. Two cover the fallback: the clone with no number kept, and a range
the process holds itself. memory::a_dma_buf_import_tries_the_type_its_kind_last_imported_as_first
covers the ordering.
Verified:
- The handed_descriptor tests fail with ordinary clones (potluck m3-max-17034, a scratch commit)
and pass with the kept numbers on CPU (m3-max-16978) and in the RTX 3090 (m3-max-17024) and
RTX 2080 (m3-max-17076) runs, NVIDIA 620.70.06. Each of those runs passed 15 of 15 touched
tests. dma_buf_leak_4_threads ran its five rounds in 39.6 s on the 3090 and 31.2 s on the 2080,
and dma_buf_leak_8_threads in 64.9 s and 58.2 s. dma_buf_fds on the 2080 took 12 numbers the
driver let go of: none was taken by another descriptor first, and none was closed again.
- The stall, with the type order: eight four-thread runs in a row ended 8 of 8 on the RTX 2080
(m3-max-17077) and 8 of 8 on the RTX 3090 (m3-max-17065). Without it, 3 of 7 stalled on the
2080, and the 3090 stalled in m3-max-16941. The kernel logged 28 and 30 refusals of the
host-visible import over the eight runs (3 to 4 a run): the first imports of each kind.
- Lint: clippy with all features, with --cfg m2v_gpu and with --cfg m2v_cpu_icd, and Rustdoc,
all clean (m3-max-17066).
FAST-PATHS's row for unshared_isolation, API.md's bullet, the policy's Bounded doc and
unshared_hold.rs's costs now say that a batch of a queue with no run seen holds the others back
until it completes, and give the owned workload's numbers (queue_share frames --unshared, Off
against Bounded): the Iris Xe (m3-max-16880, -16885) and the Radeon 780M (m3-max-16900), the
compositor's median and worst waits, the application's rate and GPU idle on a quiet host, and the
loss under host CPU load (the hold's 2 ms of slack against Off's queued batches). Bounded stays the
default on every one-graphics-queue driver.
FAST-PATHS: unshared_isolation's two values under the switches whose default is Metal's (not an
accuracy choice: it trades other queues' submission ahead for the unshared queue's wait); the
known gap now says what stays true under Bounded: a submitted batch runs to its end, so a
compositor still waits for the whole of a long one, and neither a second VkDevice nor splitting is
built. API.md section 5's policy list, the runtime README's unshared queue entry and
new_command_queue_unshared's rustdoc say the same.
Separate depth and stencil textures loaded DontCare and stored. The pass renders them through a
scratch image whose aspect loaded DONT_CARE, and the copy back wrote the scratch's undefined bytes
over the render area. Metal (M3 Max, macOS 27.0.1) leaves the same as in one combined texture,
each aspect apart: its texels in a pass whose draws reach no tile, the clear value in the 32x32
tiles a writing draw touches, its texels elsewhere. Such an aspect now takes the single texture's
answer in the scratch image (`clear_reach::dont_care_loads`): it is copied in, and the tiles the
draws' viewports and scissors reach are cleared on the scratch image after the copy
(`ReachClears` over the render area). The copies are now planned after the reach clears' loads.
An aspect that cannot be copied in (`depth_stencil_scratch::copies_in`: a multisampled one copied
by draws, whose copy in needs a sampled texture and draws its store does not) clears over the
render area and announces dont-care-load-tiles.
A DontCare load's clear depth. Metal clamps one outside [0, 1] and stores a NaN as 0x7fc00000
(32-bit float) or 0 (Depth16Unorm); its API validation stops such a pass. The runtime clamped at
begin, but a NaN reached VkClearDepthStencilValue wherever a DontCare load turned into a clear
(single textures since RUNTIME_VERSION 2045). Now a Depth16Unorm clears to 0, Metal's answer, and
a 32-bit float depth to 1.0, the value Metal's test orders a NaN nearest, announced
signed-depth-test, as nan_clear does where it cannot write the word. A Depth16Unorm cleared so at
a depth the device may round above Metal's truncation announces unorm-depth-rounding, as a Clear
load's does.
Docs: clear_reach, depth_stencil_scratch and nan_clear module docs; the dont-care-load-tiles and
signed-depth-test rustdoc and docs/API.md catalogue entries. docs/FAST-PATHS.md's known gaps
gains one measured in the same probe: a draw that neither tests nor writes the depth and stencil
leaves Metal's texels in the tiles it touches, where the runtime clears them, for one texture and
for separate ones alike.
Run: the previous commit's lane tests on lavapipe and the M3 Max, before and after this commit.
Metal's contents answers the last pointer across a detach (the caller's pointer of the last
replace), and the consumer's host library expects contents unchanged across detach and
replace; the runtime answered None. Buffer::contents now answers that pointer while a no-copy
buffer, a two-copy Managed buffer (either host copy route) or a no-copy heap's buffer is
detached. The runtime itself reads and writes nothing through it: every internal caller takes
the new crate-private mapped_contents, which keeps the old answer (None while detached), and
buffer::Detached keeps the old mapping's address only to answer contents.
Tests: tests::detached_contents (Shared and Managed no-copy buffers, and a no-copy heap's
buffer) maps the pages with no access while detached and runs a blit and a synchronize of the
buffer; managed_copy_device's detach legs and the validation detach lane assert the pointer.
Docs: Buffer::contents, detach.rs, docs/API.md, the runtime README.
Costs of matching Metal: a Managed no-copy buffer without unified memory holds device-local
memory of its size and copies across the bus (at the making, each rebind, each
did_modify_range's range, each synchronize). managed_bandwidth (release, 256 MiB read and 256
MiB written a command buffer): RX 7900 XTX (RADV) 11.3-11.4 GB/s in the pages before,
864.6-866.8 after; RTX 2080 2.7 before, 395.6-396.0 after; Shared no-copy (control) unchanged
at 11.3-11.4 and 2.7; Private 865.0-867.3 and 395.6-396.0.
Known gaps: read-only pages keep the GPU's writes until the writing command buffer completed
(the undo at completion); a synchronize encoded before a rebind copies to the old pages.
A rebind of a Managed no-copy buffer with a device copy makes a new host copy
of the new pages as the making does (an import made as HostCopy, never a
copied.rs copy, or the pages alone), in place of the old, which goes once
nothing holds it, and copies the pages in whole: a rebind whose import the
gate refuses no longer stacks a copied host buffer under the device copy.
Tests: a texture over a two-copy buffer follows its device copy (its GPU
reads after the making, did_modify_range and replace_region, and its
synchronize_resource).
Docs: the runtime's guide (the memory model, host memory without a copy,
host_backing, the recovery), docs/API.md (the two-copy paragraph beside the
Managed device-copy textures, which now reach only buffers that lie in their
pages, and device-memory-overflow), HOWTO (copied host buffers: a two-copy
buffer is never one; did_modify_range is the contract).
Bit 20 (0x100000) is an option no Metal header names, of unstated meaning,
which programs pass with their buffers' options (0x100010 for a Managed
no-copy buffer). ResourceOptions::from_raw refused it as undefined, so such
a buffer could not be made at all.
Measured with probes/resource_option_bit20.m on an M3 Max (macOS 27.0.1)
and a Radeon Pro 5300M (macOS 26.7.1), plain and under API validation:
buffers of a length, of bytes and over the caller's pages are made with it,
of every storage mode, and report their options without it; so do a heap
and a heap's buffer (API validation stops the heap's buffer); a texture
descriptor with it ends Metal's process.
So from_raw takes it (ResourceOptions::BIT_20), every buffer and heap maker
drops it (own_memory_options, no_copy_options, take_options, a heap's
new_buffer), and texture_options refuses it as it refuses bit 24 there.
Nothing reads it. docs/API.md states both halves; api_signatures blessed.
Tests: values::bit_20_is_taken_and_dropped_apart, and the device test
option_bit_20 (buffers, no-copy, heaps and their buffers report without
it; a texture descriptor with it is Invalid). Not yet run.
A tiled texture's copy taken at use is taken by the first use encoded after
its mark; a recording that never runs must hand its take on or give it back.
Three paths lost it:
- A rebind that encodes an encoder again re-recorded the encoder's segments
(a render pass recorded on the GPU alone, its shadowed textures' copies
in the segment) into cores that asked the mark, which the first
recording had cleared: the pass read a copy nothing made. The same held
for work on the GPU alone a rebind records again without encoding its
encoder again.
- A host step whose recording failed, and a vkQueueSubmit that failed,
failed the command buffer outside fail_part: the takes of the batch and
the later ones were never given back, so the next use read stale levels.
How:
- shadow.rs: one way to decide. ShadowSync::again (take nothing unmet,
note nothing) is gone; every recording in place of others is
ShadowSync::over a shared Replaced pool: a use that meets a decision of
the replaced recordings keeps its take, any other asks the mark. The
cores recorded during one turn share the pool, so each decision is met
once, in order.
- State::replaced_takes (was step_takes and replaying_takes) holds the
pool while a host step, a rebind's encoding again (the first encoding's
takes and its segments' recordings' takes, State::takes_of) or a
rebind's recording again on the GPU alone records. segment_raw hands it
to every core. A spliced encoding again or segment gives back the takes
of the first recordings it did not meet (Takes::give_back_unheld); a
refused one gives back its own takes the first did not hold. The
encoder's record keeps the encoding again's takes.
- State::place joins a placed segment's takes into its encoder's record,
and CommandBufferShared::never_runs_from (State::give_back_from) gives
back the takes of every part from the failed batch on, called beside
each of the scheduler's three failed() calls.
- docs/FAST-PATHS.md, known gaps: a predicated loop's run again records
its work apart as a new recording that asks the mark, so a
did_modify_data during the loop is taken mid-loop and the next use
after it takes nothing. Keeping the first run's takes (over) would copy
in again at every run, so it stays a recorded gap.
- docs/API.md and the shadow.rs and reencode.rs module docs say the
above.
Verified: see the next report (lavapipe before/after, the 780M, lint).
The consumer re-measured (their job m3-max-16759): Apple's OpenCL on Metal makes one Managed
no-copy buffer per cl_mem and synchronizes it as Metal requires; its Shared buffers are
staging. So no OpenCL buffer must stay Shared on a discrete GPU; the Shared bus cost stands
as measured.
runtime_lane::far_vertex_fetches::far_reach_costs on lavapipe (Mesa 26.2.4, LLVM 23.1.1, msi;
jobs m3-max-16602 and m3-max-16705): under Exact one pipeline more (the pulled variant, made at
the first uint-indexed draw), and a pass of one draw of 65,536 uint-indexed points 2.3 to 2.8
times as long (medians 0.94 against 2.41 ms beside two builds; 3.5 to 4.8 against 9.7 to 12.0 ms
at a load average of 59 on 24 threads). Not free, so the switch stays opt-in.
The defect's doc names the second lavapipe release measured and the 780M's Mesa.
lavapipe's fixed-function vertex input takes an element's displacement modulo 2^32: the
conformance case vertex-fetch-past-4gib-small-buffer reads the wrapped words in 24 elements
where Metal reads zero. Vulkan places the attribute at the whole displacement (28.4 Vertex Input
Address Calculation) and robustBufferAccess2 makes a read past the bound range zero, so the
wrap is the driver's defect: a new RuntimeDriverDefect::VertexFetchWrapsPast4GiB, listed for
MESA_LLVMPIPE alone.
On a listed driver the render lowering names the fixed-function layouts a draw may fetch past
2^32 bytes of their bind offset in a new BindState/BindShape field, far_vertex_buffers, and the
binder pulls them (the existing pulled-vertex-buffer variant, whose fetch reads past 2^32 as
zero). The reach is the existing furthest_element: a draw's last vertex, 65535 plus the base
vertex for ushort indices, the base instance plus the last instance over the rate. Those are
pulled by default. A per-vertex layout of a uint-indexed draw, and an indirect draw's, has its
reach stated by GPU memory; pulling it costs a variant for every such draw, so it is behind a
new runtime-only DevicePolicy switch, vertex_reach (VertexReachPolicy::Bounded by default,
Exact in exact_answers()). Under Bounded such a draw keeps fixed function and is announced
vertex-fetch-may-wrap (Precision). The draw-again paths (rebound, restated) compare the pulled
set; the host-step precompile names none; the GPU replay derives it from its indirect draw.
WorkCounts::far_vertex_fetch_pulled_draws counts the pulled draws.
The conformance case's known-gaps row is removed: replay runs under Exact. FAST-PATHS gets the
switch's row (its lavapipe cost is measured next, in a later commit). New tests: the binder
pulls a named layout; far_layouts under both policies; runtime_lane::far_vertex_fetches
measures the defect on every device under both values, and far_reach_costs (ignored) measures
the exact form's cost.
SEMANTICS_VERSION is unchanged: an empty far_vertex_buffers, every existing shape's, plans as
before, so no output changes under an unchanged key.
Verified so far: api_signatures blessed (signatures.py), refusal_surface --check, the
conformance and Metal coverage checks; builds and tests follow as potluck jobs.
A pass whose depth and stencil attachments are two textures renders through a scratch image of
the combined format (depth_stencil_scratch.rs), and clear_reach::dont_care_loads skipped it: an
aspect loaded DontCare and not stored took the scratch's DONT_CARE load under every policy, with
no notice. So under exact_answers() its draws read what the new scratch image held (on MoltenVK
a stencil of 0 and a depth of 1.0, Metal's defaults for a load that names no clear value), where
Metal's read the pass's clear value: measured on the M3 Max under macOS 27.0.1 by the lane's
passes through Metal itself (job m3-max-16522), each aspect apart, whether the other aspect is so
loaded or loaded and stored.
Now such an aspect takes the answer of any attachment so loaded, each aspect apart: in a pass
whose draws reach a tile, the scratch's Clear to the aspect's clear value under
UnstoredDontCarePolicy::Cleared and on a driver with DriverFact::UnstoredClearNoSlower (the
scratch image is a combined depth/stencil attachment, the shape the fact measured), else its
DONT_CARE, announced dont-care-unstored-load naming the aspect. Nothing is copied into the
aspect before the pass (only Load aspects are), so no earlier bytes reach it. An aspect the pass
stores keeps the scratch's DONT_CARE load as before.
Docs: clear_reach.rs records Metal's answer for separate textures and the rule; the scratch
module, the notice's rustdoc and catalogue entry, UnstoredDontCarePolicy's rustdoc, API.md's
section and the FAST-PATHS row name separate textures; the known gap is removed.
Measured by the consumer on the RTX 5080 Laptop GPU and a Radeon Pro 5300M (their jobs
16447, 16453, 16455, 16554): Shared no-copy 5.3 GB/s against Private 328 GB/s on the 5080;
6.1 against 96.1 on the 5300M. Apple's OpenCL on Metal synchronizes its Managed buffers on
its map path only, so a second copy would go stale; its buffers stay Shared on a discrete
GPU, a cost recorded here.