efcb6851ce89f690b599dcbdf6ac3faa384b41d9
1193
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
efcb6851ce |
The encoder trail: name the encoder a stalled GPU stopped in, and the last one that completed
A GPU hang (a CTX SWITCH TIMEOUT on an RTX 3090) left the runtime with no way to say which encoder never completed: encoders share batches and grouped submissions, and neither METAL2VULKAN_LOG_PASSES nor METAL2VULKAN_QUEUE_TIMES logs anything at a stall. METAL2VULKAN_ENCODER_TRAIL (env_vars.rs), or DeviceOptions::encoder_trail for one device, is a default-off diagnostic (encoder_trail.rs): - Each encoder, and each part of one a host step splits off, ends its batch (Batches::alone), and no batch waits in a group, so each goes in a vkQueueSubmit of its own that signals its queue's timeline. When work goes to the driver changes; what it computes does not. - Each encoder notes what it was: its kind, its command buffer's object ID, its place, a render pass's area, samples, attachments' formats and sizes, instances and rate map, its indirect command executions, and the label hash of each state it bound (the first 8 bytes of a SHA-256 of the state's label and its functions' names; no name, no shader text). A host step adds the states its indirect commands named, as the GPU and the CPU left the records. - Once no work of the device advanced for 2 s with some pending, completion.rs's stall path logs one Info line (id name metal2vulkan-encoder-trail) for each VkQueue whose oldest batch is pending: that batch's encoders and the last batch the queue completed, with how long before; once a stall. - A submission a host step makes and waits for itself (a rasterization-rate map's fan-out probe, a predicated loop's check run again) signals no timeline; once it ran 2 s, one line names it, the encoder whose step made it and the states its commands named. Off, a device reads the switch once and notes nothing. Verified on msi (lavapipe, --cfg m2v_cpu_icd), at the branch tip this commit's tree equals: - tests::stall::the_encoder_trail_names_the_stuck_encoder_and_the_last_one_completed: a cb stuck on an event wait before two blit fills; the line names the stuck cb's encoder 0 (not its encoder 1) and the earlier completed cb's encoder 0: "VkQueue 0's oldest pending batch: Blit encoder 0 of command buffer 3, states []; the last batch it completed: Blit encoder 0 of command buffer 2, states [] (2.106823047s before)". - tests::rate_mapped_fan_out::the_encoder_trail_fans_out_the_same_pixels: with the trail on, probes/flagged/fanned [1, 1, 6] as without, no texel differs from the encoder's own draws. - The host-step families (rate_mapped_fan_out, rate_mapped_pieces, indirect_command_buffer_device, host_step_neutrals, ycbcr_in_place_loop) with METAL2VULKAN_ENCODER_TRAIL=1: 11 passed. - encoder_trail's unit test (one state's hash pinned: a reader of the pipeline creation log computes it again); the runtime suite 1504 passed; api_ tests 16 passed; clippy all features and the runtime under m2v_gpu and m2v_cpu_icd; rustdoc of the runtime and metal2vulkan. The runtime-sources pin moves (not re-pinned here). |
||
|
|
d4ab197556 |
Metal's command-buffer watchdog: a front batch 20.2 s without its timeline advancing fails as Metal's timeout
reims's 3090 boot after an Xid 109 (CTX SWITCH TIMEOUT) had its graphics queue's batch never
complete while the copy engine ran on: the staging probe completed 23 times in under a
millisecond, so the stall rule found the GPU running and nothing failed. The probe stays; beside
it each queue's front batch now has its own clock (stall::Clock::front_held), which runs while
its waiter's waits run out with it pending and stops whenever its queue's timeline advances,
whatever the probe answers. Past stall::WATCHDOG (20.2 s, the x86 AMD Mac's measured bound and the
largest of Metal's) the front fails as Metal's timed-out command buffer (GpuHang, code 2, named
exactly: its queue is known, no inference), the rest in flight as GpuRecoveryVictim, and the
generation is marked stopped (Stop::Watchdog), parked and recovered from as a wedge; the notice
says the watchdog stopped it. Counted: WorkCounts::watchdog_timeouts (wedges_declared keeps the
unanswered probe's stops).
Measured on the M3 Max (macOS 27.0.1, a Swift probe): a command buffer waiting for an event no one
signalled, shared or plain, failed with MTLCommandBufferErrorTimeout ('Caused GPU Timeout Error
(00000002:kIOGPUCommandBufferCallbackErrorTimeout)') 5.00 s after its commit, nothing of it run;
two such on one queue revoked it (the next fill failed AccessRevoked 0.24 ms after its commit,
a new queue ran). So the clock counts event waits, as Metal's does, and the watchdog's GpuHang
counts against its queue as any timeout (revocation.rs says so; the count is QueueCommon's and
carries over a recovery, as Metal's queue keeps it).
Tests (tests::stall): the stuck front with an answered probe fails at the hooks' 1 s bound, no
sooner, as GpuHang, parks the generation and runs the next command buffer; the answered leg
whose front advances within the hooks' 3 s fails nothing. Docs: stall.rs, revocation.rs,
docs/FAST-PATHS.md known gap, docs/API.md, the runtime README, WorkCounts, api_signatures.
|
||
|
|
4906f145e3 |
Pieces lane: each frame cold, then warm; the fan-out row's cold and warm costs
The lane's one frame mixed two costs at the host step: the GPU work, and on the first frame of a state the driver making the fan-out's probe and draw pipelines inside the step (82.1 of the RTX 3090's 88.6 ms cold fanned-out window). The frame now runs twice on the same device, cold, then warm, each printed and checked, and the line adds the host step's time (WorkCounts::host_step_nanos), the pipelines it made (host_step_pipelines_made) and the time creating render pipelines (render_pipeline_create_nanos). The lane's docs and the fan-out row's cost cell in docs/FAST-PATHS.md carry the three GPUs' cold and warm numbers after the probe spread, from one run each (m3-max-23899 RTX 3090, 23900 Iris Xe, 23901 Radeon 780M), command buffer GPU time FanOut against Exact: - Iris Xe: 110.4 ms cold, 40.3 ms warm, against 514.6 and 499.1 ms. - Radeon 780M: 84.3 and 34.7 ms against 299.5 and 231.7 ms. - RTX 3090: 88.6 and 6.0 ms against 61.9 and 63.0 ms. The guest-scale fanned-out figure, measured before the spread, is dropped; its region-by-region one stands. |
||
|
|
c7362776d0 |
Let carried textures' and pipeline states' parts go at the lost generation's rest
What: a recovery's carried textures and pipeline states let go of their parts on the lost generation once it comes to rest, as buffers already did, so the lost VkDevice goes while they live. - device/carry.rs: LetGo<T>, the let-go cell MadeOn was (MadeOn is now LetGo<Device>), and PartsCalls/CallHold, one guard generalised from the buffer's calls and HeldParts: a call outside command buffers' work counts itself, and a release at rest waits for the last call to end. Buffers use it unchanged in behaviour (Buffer::held_parts, LostBuffer, LostPlaced, LostHost). - Pipeline states: StateShared.program and ProgramLink.program are LetGo cells. The carry hands the lost generation a LostProgram, which drops the state's program there in place at rest (its variants' objects, plans, makings and its Device). reached() skips programs let go of. The state keeps its own copy of its label, so label()'s borrow outlives the program. Holds: the public state methods that reach the program, program(), Debug, and the argument encoder's and indirect commands' set paths. - Textures: TextureShared's per-generation parts (storage, moved, pending_move, usage_shadow(_making), faces, snapshot, kept_backings, render_shadow, facts, planes_in_place) move into Parts in a LetGo cell, read through Deref. The carry hands the lost generation a LostTexture. At rest it leaves the texture's slot in the lost generation's table and heap sets, hands the caller's range token to the parts on the next generation, and drops the parts in place. Parts with a handed-out VkImage (Texture::vk_image) stay until the texture goes. Texture::s() skips parts let go of. Holds: the public texture methods that reach parts, and vk_image; a view's hold holds its root texture too. slot_keeper names a texture buffer's generation by its texel views, not by the buffer's serving generation. - WorkCounts::lost_programs_released and lost_textures_released, counted on the line. - Public signatures: ComputePipelineState::device, RenderPipelineState::device, FunctionHandle::device and VisibleFunctionTable::device now answer an owned Device. The last two also borrowed from the state's program. Command-buffer paths use the crate-private borrowing generation(). api_signatures is blessed. - Docs: the carry module docs (device, pipeline, texture), docs/API.md's recovery entry, the runtime README's recovery paragraph, vk_image's doc. - Tests: the four recovery tests in 99dbc69666 also assert the counters. Why: a carried texture kept its images on the lost generation, and a carried state its program there, until the object went, so the lost VkDevice lived as long as any of them. A long-lived program kept it for good. Verified: cargo check of the workspace, all targets and features, under no cfg, m2v_gpu and m2v_cpu_icd, clean but for one validation call site fixed here (jobs m3-max-23824, 23852). The lavapipe lane (the tests of 99dbc69666 before and after), the suite, lint and the 780M run follow. |
||
|
|
cbe64ff91b |
warm: a failed creation is announced once per kind, naming the kind and nothing of the shader
What: a record whose creation fails on Device::warm is still counted and dropped, and the first
failure of each kind a device meets is now announced through its message sink (else stderr) as
the warning metal2vulkan-warm-record-failed, as the first unread record is. The kind
(warm::pass::failure_kind) is the runtime error's variant and, for a translator refusal, its
feature and what it needs, e.g. Compile(Unsupported{Lowering(Access); NotImplemented}); for an
input error, its class. Never a symbol, location or message, which can name the record's
shaders. Past 32 kinds a device counts later ones alone.
Why: pin 62's warm pass failed 124 of ms01's records and 90 of um870's and said nothing: the pass
counted them and dropped them, so the walk's summary line was the only trace, and naming the
class took a replay with a temporary print (all 124 on ms01 were
Unsupported{Lowering(Access); NotImplemented}, fixed by SEMANTICS_VERSION 2070). The next such
regression names its kind in the consumer's log.
Tests: a_failure_kind_names_nothing_of_the_shader (a refusal with a symbol and a function
location renders as its variant, feature and needs only), and the device test
a_failed_creation_is_announced_once_by_its_kind_and_the_pass_goes_on (two records Metal refuses
alike around a render record: 2 failed, 1 warmed, the warning heard once, naming the kind the
program's own creation meets and not the kernel's name). The runtime README and docs/HOWTO.md
say so.
|
||
|
|
0c6d7cc1c8 |
Pieces lane at a guest frame's scale, a GPU hazard; the RTX 3090's numbers
rate_mapped_pieces_guest_scale (FanOut) and _guest_scale_exact run the host step's frame at six times the commands (384 commands, 5,508,648 indices, about the 126 pieces a guest frame was recorded in on an RTX 3090), compiled only under m2v_gpu_hazards and ignored by default. Measured once on an RTX 3090 (NVIDIA 620.70.06), um870, each test its own process: at 64 commands Exact 54.4 ms in 20 pieces (longest 2.63 ms), FanOut 98.4 ms with a 14.0 ms probe; at guest scale Exact 332.3 ms in 117 pieces (longest 2.67 ms, mean 2.00 ms), FanOut 174.3 ms with a 74.4 ms probe. The numbers go in the lane's docs and the fan-out row's cost cell in docs/FAST-PATHS.md, where FanOut is slower than Exact at the small size on that device. Verified: clippy with --cfg m2v_gpu --cfg m2v_gpu_hazards over the runtime, the translator and validation, 0 messages; the five lanes passed on the RTX 3090 (job m3-max-23744), built from the same lane source. |
||
|
|
41337099f5 |
Time a rate-mapped pass's pieces on a device asked for host-clock GPU times
A device made with DeviceOptions::gpu_times_from_host wrote no timestamps at all, so a pass recorded in pieces read no piece time there (rate_map_pieces_timed 0): a guest frame on an RTX 3090 cut into 126 pieces gave no hint which piece or draw was long. The option only spares command buffers' own two timestamps; the piece timer and the host step's probe now write theirs on such a device. They still skip where the driver's timestamps wait for every queue's (FromHost::Driver, MoltenVK), since there a timestamp would serialize the device's queues. The option's docs, the gpu_time module's, the degrade notice's, the API catalogue's and the work counts' say so. Verified: the new runtime test a_device_answering_gpu_times_from_the_host_times_its_pieces passes on lavapipe (12 pieces past the first, 13 timed) and on an RTX 3090 (NVIDIA 620.70.06, the same counts), built at the branch's earlier commit with the same runtime source. |
||
|
|
5039015420 |
An import several no-copy buffers over the same bytes lie in stays releasable
A no-copy buffer made over exactly the bytes a live one covers lies in that
buffer's import (host_aliases.rs, "One memory, one import"). Until now its
making read the import apart (ReadApart::SecondBuffer), which keeps a
releasable import imported for good. Such a buffer reads the import the way
the first one does, through the import: its blits take the import's objects,
imported again where released, and any other read of it exposes the import
just as a read of the first buffer would. So the import now stays releasable
while every read of each buffer in it was a blit's, or there was none. A
buffer that is never read, made only to keep the bytes imported, keeps the
import no more than a buffer read only by blits does.
Why: on the RX 7900 XTX (RADV), a guest's 3D benchmark kept 1,000 to 1,330
dma-buf imports live. RADV lists every one of them in every kernel submission,
at 0.43 to 0.44 us each (docs/FAST-PATHS.md, known gaps). Of those imports,
1,262 were held for good, and every held one had a second buffer lying in it.
The consumer keeps a holder for each view of guest pages: a no-copy buffer
over the whole view that nothing reads, with the block's buffer lying in its
import. The frames named about 0.6 imports per command buffer, while the
scheduler thread spent 0.63 to 0.90 s of each second in vkQueueSubmit, at
0.835 ms per call. Our own blocks on that device are plain VRAM, which RADV
makes local and lists in no submission.
What still keeps such an import imported for good:
- a no-copy heap's own bytes lying in it: the heap's placed buffers'
addresses are the heap's, handed out without any read of the import noted;
- a rebound buffer lying in it, as a rebind's own import is kept;
- a buffer bound inside its memory with a VkBuffer of its own;
- a buffer made to share its buffer's range (BufferDescriptor::range_of),
which is handed that buffer's address.
Counters: the gauge host_imports_read_apart_second_buffer is split into
host_imports_read_apart_inside, _shared_range, _heap and _rebound. The new
host_imports_joined_releasable counts the buffers that came to lie in a
releasable import beside another and left it releasable; a walk shows the
path ran when it is non-zero. host_residency.rs ("Several buffers in one
import"), host_aliases.rs, the WorkCounts docs, docs/HOWTO.md and the API
signature table say so.
Test: tests::host_residency::an_import_two_buffers_lie_in_is_released_while_idle_and_read_right_again.
It makes a never-read holder and a second buffer over the same 4 pages of a
udmabuf-backed memfd. Joining keeps the import releasable (nothing held for
good, no read apart) and imports nothing new. Read by a blit, the import is
released. The file's writes made while it is released are read by the next
blit through the second buffer, imported again from the kept descriptors. It
is released again. Then a kernel binds the second buffer, makes the holder
resident (useResource:, as Metal reaches a no-copy buffer through an address
only once a command buffer used it) and loads the holder's Metal address from
set_bytes; the binding imports the import again for good. The words the kernel
reads through the address, and the words it writes through it, are checked
against the pages. The source is called once, and the import leaves the gauges
once its buffers go.
host_import_counts now expects a second buffer over the same bytes to read
nothing apart.
Verified (the runtime's debug test binary, --cfg m2v_gpu, not a release build):
- m3-max-23710 (msi-laptop): cargo clippy --workspace --all-targets
--all-features -D warnings, the runtime's clippy under --cfg m2v_gpu, and
the runtime's rustdoc with -D warnings: clean.
- m3-max-23713 (msi-laptop): the API signature tests, 16 passed; the
runtime's suite, 1502 passed, 6 skipped; on lavapipe (--cfg m2v_cpu_icd)
the host_import_counts, host_residency, pointer_residency and host_aliases
tests, 39 passed.
- m3-max-23761 (Radeon 780M, RADV PHOENIX): the host_residency and
host_import_counts device tests, 15 passed, the new test among them ("1
chunks of two buffers released twice, imported again twice"). The negative
control, the same binary with a joining buffer reading the import apart as
before, fails the new test at "the second buffer kept the import for good"
(held for good 1, expected 0).
The lint and suite jobs ran one commit before the test's last change (the
holder made resident before the kernel reads through its address), a
test-only change that the 780M run's binary carries.
|
||
|
|
c3a002b71c |
stall test: the stopped test drains the parked queue before the process exits
On NVIDIA (620.70.06; um870's RTX 3090 and um790's RTX 2080) the stopped test passed and its process never exited: under gdb (job 23736) the test reported ok in 21.5 s, and the main thread then spun in exit(), in an exit handler of libEGL_nvidia that tears down every VkDevice left and waits for its work. The parked VkDevice's batch waits for the event's semaphore, which the test never signalled. The test now keeps the stopping generation's functions and semaphore and signals the reserved counter on the parked VkDevice once it has checked the recovery, so its queue drains. It prints when the stuck command buffer failed and when the next one ran. docs/FAST-PATHS.md's known gap and stall.rs's module docs say a driver may wait for a parked VkDevice's work at the process's exit (NVIDIA's did, for that stand-in wait); a GPU that truly stopped is not measured there. Verified: cargo fmt. The NVIDIA runs follow with this commit's archive. |
||
|
|
64982ac827 |
A GPU that stops with no loss from the driver fails its work and is parked
On NVIDIA after an Xid 109 the device's queues stopped: no batch completed and every completion wait answered VK_TIMEOUT, never VK_ERROR_DEVICE_LOST, so the program's command buffers waited without end. The completion's waiters now keep a device-wide stall clock (command_buffer/stall.rs): it runs while a wait ran out with its front batch pending and stops whenever any queue's timeline advances. Past 10 s one waiter probes the staging queue (NVIDIA's copy engine) with a submission of nothing that waits for nothing, and for up to 2 s reads the probe's answer and the stuck front's fence (a wait of no time) and timeline (vkGetSemaphoreCounterValue); a loss either read answers takes the failed wait's path at once. One informational message, metal2vulkan-stall-probe, names the stall, the probe's answer and each read's last VkResult. A probe answered, or a front that advanced, fails nothing and restarts the clock, so a device that still makes progress is never failed whatever its work's length. A probe unanswered in 2 s stops the generation: Device::mark_wedged marks it stopped and lost, the wait fails as a lost device's (the oldest command buffer as GpuHang, the rest GpuRecoveryVictim), and the line recovers; the DeviceRecovered notice says the VkDevice stopped and was parked. Parked: release.rs's door leaves every object of a parked VkDevice, the device itself included; DeviceShared::queues_idle waits for none of its queues, and its teardown returns before vkDeviceWaitIdle, keeping the instance. New public query Device::is_parked(vk::Device) -> bool (no Metal counterpart), for a consumer that holds the stopped generation's handles. Counters: WorkCounts::stall_probes_sent, wedges_declared, longest_stall_nanos. A device without a staging queue sends no probe (FAST-PATHS known gap, with the leak and Metal's bounds: about 5 s on the M3 Max, 20.2 s and 16.1 s on x86 Macs' AMD and Intel GPUs). Tests (tests::stall, through the line's hooks: the clock's bound 200 ms, and no probe seen answered): a command buffer waiting on its VkQueue for a reserved event signal is pending; with the probe answered nothing fails and it completes once the host signals; with none answered it fails as GpuHang, the old VkDevice is parked, the new one is not, and a command buffer runs after. Verification follows on this commit. |
||
|
|
a52c30aff2 |
A recovery carries no-copy heaps and the textures placed in heaps
What: a heap over the caller's memory (new_heap_with_bytes_no_copy) is
carried as a no-copy buffer is: its own buffer made again over the same
pages (Buffer::carry_no_copy, now for a heap's own buffer too, kept among
no program resources; its pages keep what they were made of, a heap's own
included), its identity kept, the buffers placed in it carried at their
offsets (Buffer::carry_placed), their bytes as they are. The textures
placed in a carried heap, Private or no-copy, are made again there after
the heaps (Remake::Heap, Device::heap_texture_again): as the runtime's own
texture over the same range of the heap's bytes, through the making that
placed them (a texture buffer's buffer carried with carry_placed), sharing
the range's makeAliasable flag (HeapPlace::aliasable is an Arc), the range
handed to the newest image (HeapPlace::again, hand_range_to), so it is
given back once. A Private heap's texture reads as a new one, a no-copy
heap's reads the pages. The heap keeps its textures numbered as they were
(no forget_held); one the recovery leaves is forgotten (Numbered::forget,
Heap::forget_texture). A texture over a carried heap buffer is made again
over it, as over any carried buffer. Heap::carry answers what its bytes'
carry did with their contents and None where it was carried already, so
the notice counts no-copy heaps apart (", and N no-copy heaps with the M
buffers placed in them, over the same pages") and textures placed in
no-copy heaps apart ("N textures placed in the no-copy heaps carried"),
a Private heap's textures by storage mode. Docs: heap.rs, texture/carry.rs,
device/carry.rs, MadeBeforeRecovery, the device-recovered cost (degradation.rs,
API.md), the runtime README, and FAST-PATHS's known gap on lost texture
contents, which now names a Private heap's textures.
Why: reims's forced recoveries (3090 m3-max-23482, XTX m3-max-23547) left
44 no-copy heaps and 929 heaps' textures refused: 3424 refused texture
binds in one compositor's command buffers, 82 placements in those heaps
refused, the desktop mostly black after. Metal keeps a heap and what is
placed in it. The owner's call: a Private heap's textures are carried with
their contents lost, as new_texture's are.
Verified: a check of the runtime's lib and tests under plain and
m2v_cpu_icd was clean (m3-max-23688, on a probe commit of this change);
the lane that follows runs the tests.
|
||
|
|
257b77bc21 |
Fan a host step's rate-mapped draws out to the regions in one draw
A rate-mapped pass drew every draw once per region of the map's plan: an executed command's
triangles ran their vertex function 2074 times on a 3648 by 1734 screen's plan, and the command
buffer of a guest frame's shape took 514 ms of an Iris Xe's GPU and 462 ms of a Radeon 780M's.
At a host step, where the default `RateMapRegionPolicy::FanOut` holds and the device enables
`geometryShader`, `shaderClipDistance` and `vertexPipelineStoresAndAtomics`, the pass is now
probed first: each execution's commands, read once, are replayed in probe mode into a segment of
their own (one middle render pass per instance, the fan-out variant's geometry stage writing a
flag and a copy count per command and emitting nothing), submitted and waited for. A command
whose flag is clear (no triangle crosses w = 0 or touches more regions than the copies) is drawn
once through the fan-out variant over the whole target, its geometry stage emitting a copy per
region it touches; a flagged command, and every command after a barrier, after a draw that writes
memory or at a mesh or patch draw, is drawn region by region as before. A fan-out variant the
compile refuses falls back to region by region at the settle.
`RateMapRegionPolicy::Exact` (`DevicePolicy::exact_answers()`) keeps every draw region by
region. The FAST-PATHS row, the API.md bullet and a known gap (the encoder's own draws and the
draws commit records stay region by region) describe it; `WorkCounts` counts the probes, the
flagged and fanned-out draws and the probes' GPU time. `CommandBuffer::submit_waited` is the
loop check's waited submission, shared with the probe.
Verified (release, `--cfg m2v_gpu`, e55e6ebd01 before the rebase onto
|
||
|
|
e6124818d9 |
A recovery carries Private exportable buffers over their own memory
What: Buffer::carry takes a Private buffer in exportable memory (no host copy) to the new generation over its block's payload imported again (Device::buffer_in_carried_export, memory::place_carried_export): the lost block is exported once from the lost VkDevice (memory::carried_payload, vkGetMemoryFdKHR, which the spec lets a lost device answer) and that descriptor is kept on the block (Block::payload); the new VkDevice imports a clone of it (Handed) once for every buffer carried from the block, as memory of the block's own type and allocation size with the device-address flag of the device's blocks, dedicated to the buffer where the lost block was a dma-buf's dedicated allocation, and binds each buffer at its offset. The buffer is not cleared: another API's import (VA-API) reaches the same memory and may be writing it, so it keeps whatever the memory holds, counted among the buffers carried with their contents. Its exports after the recovery answer a clone of the kept descriptor, and so does the dma-buf a texture's image over it imports (ExportedTexels::payload), so textures over it carry as over any carried buffer. Left refused: Shared and Managed exportable buffers (their contents pointer is the lost mapping), and an opaque descriptor's dedicated allocation, a new kind in the notice (Left::DedicatedOpaqueFd: VUID-VkMemoryDedicatedAllocateInfo-buffer-01879 names a buffer identical to the payload's, which Vulkan does not define across devices). Docs: exported_memory.rs, device/carry.rs, buffer.rs, MadeBeforeRecovery, the device-recovered cost (degradation.rs, API.md) and the runtime README, with the exception to the Private-reads-zero rule. Why: reims's NV12/P010 device caches are Private exportable buffers (STORAGE_PRIVATE in surface_cache.rs and vaapi.rs, read-only check) that VA-API decodes into; a recovery left them refused, failing a video session's frames, where Metal keeps the buffer. Verified: the lane that follows runs the test before and after on lavapipe; REFUSALS.md regenerated (no change). |
||
|
|
30ba489080 |
A recovery carries sampler states
What: a sampler state's device is a LineDevice the state's own carry links (LineDevice::unkept, link_unkept). The recovery takes the generation's live sampler states (Carry::sampler_state, Taken::samplers) and, first after the handles, carries each (SamplerState::carry) where both generations compile alike: its handle linked to the new generation's under its cache's lock, the VkSamplers it kept forgotten, the state kept in the new generation's map of live states (an equal request gets it) and placed in its heap sets and sampler tables, then kept there for a later recovery. Its placement on the lost generation is taken out at that generation's rest (LostPlacement). SamplerState::vk_sampler takes the generation the bind writes for and makes the sampler there, cached for the state's latest generation alone; for any other generation it answers None, and the heap set, slot and argument-buffer writes take the neutral sampler. The recovery's notice counts the states carried (and any left, where the generations compile otherwise). Docs: MadeBeforeRecovery, the device-recovered cost (degradation.rs and API.md), the runtime README, device/carry.rs and sampler.rs. As main asked, Device::recover_for_test's doc and line.rs's module doc now point at device/carry.rs for the kinds carried instead of a stale list. Why: a sampler state kept its lost generation, so every bind of it after a recovery was refused (MadeBeforeRecovery) where Metal's goes on; and the argument buffers' listing of live states is line-wide, so a draw or dispatch of the new VkDevice made the listed state's VkSampler on the lost VkDevice and wrote it into a descriptor set of the new one, a handle of another device, which Vulkan does not allow. Verified: the lane that follows runs the test before and after on lavapipe; REFUSALS.md regenerated (no change). |
||
|
|
c4376d1042 |
canon::generic: a struct's generic pointers read through its address another thread object holds
What: canon::generic's cells (canon/generic/cells.rs) follow thread pointers through thread
memory. A slot of an alloca into which only the address of one alloca at one offset is stored
(a null among them or not), that no other write, copy, atomic or load at another offset or width
meets, of an alloca whose address no use but an access and address arithmetic takes, is
followed: a thread pointer loaded from it places what it addresses, and storing that address into
it is no escape. Places also derive through casts between the thread and the generic space, so
an object reached through a generic `this` is a cell too. The slots followed and the places they
lead to are found together, in rounds; a slot followed once and not after is never followed
again, and past the rounds' bound none is.
Why: macOS 27's MPS matmul and quantized matmul kernels keep their array_refs' generic pointers in
a thread struct and read them through a lambda that captures the struct by reference: the
lambda's object holds the struct's address, and its call operator, inlined, loads that address
and then the struct's fields. The fields' loads were from no place a cell knew, and the struct
was open because its address was stored into the lambda's object, so each was
GenericPointer(Memory).
The owned fixture generic_pointers gains generic_captured (a lambda capturing a `refs` by
reference, its call operator taking its object as a thread pointer) and generic_functor (a
functor holding `&r`, its out-of-line call operator taking the functor as a generic pointer), and
its Metal probe the same kernels. docs/FAST-PATHS.md's generic pointer gap says so.
Verified, one run each:
- Before, at development with the fixture: engine_generic_pointers refuses generic_captured
with GenericPointer(Memory) (m3-max-23363).
- The M3 Max (macOS 27.0.1) answers both new kernels as generic_slots: 100+t, 201+t, 1 for t<4
then 4, and t (m3-max-23383).
- engine_generic_pointers and the metal2vulkan-air suite pass, 561 tests (m3-max-23381).
- The metal2vulkan and metal2vulkan-air suites (m3-max-23401): 4060 of 4063 pass; the three
that fail are the golden tables, which development re-blesses: golden_hashes, the engine
inventory's two new rows (generic_captured and generic_functor, ok in every cell), and the
engine printout of generic_pointers.ll (tests/air_input/generic_pointers.txt, recorded under
LLVM 21).
- runtime_lane::generic_pointers on lavapipe, both tests, the five struct kernels among them
(m3-max-23413).
- fmt, clippy with all features and rustdoc (m3-max-23436, the same patch on development
|
||
|
|
56a8aa5283 |
did_modify_range: a commit takes the ranges of the buffers its command buffer uses, copied in on its queue
What: Modified::take_at_commit takes, at a commit, only the noted ranges of the buffers the
command buffer may use (CommandBuffer::may_use: its encoders' uses name the buffer or made it
resident, a command may reach memory no use names, its last encoder's end is still with the
lowering thread, or nothing owns the buffer's key); the rest stay noted, in their order, for a
commit that uses them (managed.rs's Noted). Their copies in, and every other upload into a
buffer the program may have read (Buffer::upload, copy_in_from), register as uploads
(FirstMoves::register_upload, FirstFill::reached_only): a batch takes one only where its
commands may reach the buffer, on a device with a fill queue or without one, never because it
takes every other fill; an internal submission takes it too, and a batch that needs no GPU work
leaves it waiting. FillTake::Owned carries the batch's reach for that. So the copy lands on the
user's queue, after the command buffers before it there, before the commands of the first that
uses it: Metal's shape. Docs: managed.rs, managed_copy.rs (the 'as on Metal' line now says what
holds: only two queues' unordered uses of the buffer race the copy), first_move.rs, API.md, the
runtime README and FAST-PATHS.md's managed row.
Why: any queue's commit took every noted range, and any queue's next submission took its copy in
(before
|
||
|
|
6b79a77730 |
A recovery carries drawing and mesh pipeline states
What: a drawing state (a mesh one, and a twin of a color group, a single-sample or a factor-scaling state among them) keeps a chain of programs per generation as a compute state does (pipeline/carry.rs): its StateShared Deref reaches the program of the generation whose command buffer's work the thread does, else the last; its ID, uniqueIdentifier, label and sampler numbers stay. Each state is kept by its generation's carry registry (GraphicsState::kept at the end of a render or mesh creation, with its color groups' twins); the recovery carries them after the compute states (pipeline/render/carry.rs): its base variant, and its large-buffer form's, made again from the pipelines its creation compiled or the live variants of them the new generation holds, no translation; then, under the new generation's reach (NoticesFor::of_generation), its neutrals, its predicted first draw's VkPipeline handed to the pool with nothing waiting for it (make_at_creation(false)), and its depth stand-in copies. Its descriptors, keys, label and twins are kept; its other variants, plans, settles and routings are made as its draws need them. A failed making is counted and refused where bound (RemadeAfterRecoveryFailed) through RenderPipelineState::bound_device, at set_render_pipeline_state (encoder, call checks, indirect command buffer) and an argument encoder's render word; a tile state's bind now answers its kernel's failed making the same way. A state is made again only where both generations compile alike (compiles_alike, the profile fingerprint the memo carry checked already); else its making is refused as failed. Docs: device/carry.rs, pipeline/carry.rs, MadeBeforeRecovery (render states no longer listed refused) and RemadeAfterRecoveryFailed, the DeviceRecovered cost (degradation.rs and API.md, equal), API.md's recovery entry, the runtime README; REFUSALS.md regenerated. Why: drawing states made before a recovery were refused where bound after it; Metal's go on. Verified: see the lane run reported with this sha (the test commit before it fails, this one passes), with the recovery's wall time for 0, 200 compute and 200 drawing states. |
||
|
|
11d87dec93 |
Make the region table a public submodule of bind, and pin the fan-out surface
bind::fan_out moves out of the rate map's module so the surface scan reads it; the surface table, the signatures and docs/REFUSALS.md name the fan-out's items and refusals. |
||
|
|
98db2b33e6 |
A recovery carries compute and tile pipeline states
What: a compute state (and so a tile state's kernel) keeps a chain of programs, one per generation (pipeline/carry.rs): the state object, its ID, uniqueIdentifier, label and sampler numbers stay, and its Deref reaches the program of the generation whose command buffer's work the thread does, else the last. Each state is kept by its generation's carry registry; the recovery, after the textures, makes its program again on the new generation: the base variant's objects from the pipeline its creation compiled (Variant::of with the compiled pipeline, or the live variant the new memo already holds), no translation, and the VkPipeline its creation predicted queued on the making pool with no wait (make_predicted with waited false). The lost generation's memo of compiled functions and pipelines is carried first where both generations' profile fingerprints match (PipelineMemo::carry_from), so later variants and creations translate nothing again. A state whose making there fails stays the lost generation's, is counted by the notice and refused where bound with the new RuntimeGap::RemadeAfterRecoveryFailed (compute encoder, argument encoder and indirect command buffer checks, through ComputePipelineState::bound_device). The notice says how many states were made again and how many failed. An indirect command buffer's depth/stencil check now matches the state by its line too, as the encoders' do since the regression fix. Docs: carry.rs, MadeBeforeRecovery, the new gap, the DeviceRecovered cost (degradation.rs and docs/API.md, equal), the runtime README; REFUSALS.md, reach.tsv and the API signature table regenerated. Why: compute and tile states made before a recovery were refused where bound after it; Metal's go on. Verified: see the lane run reported with this sha (the test commit before it fails, this one passes), with the recovery's wall time for 0 and 200 live states. |
||
|
|
85847d3941 |
A binary archive and a dynamic library go on past their device's recovery
What: a binary archive and a dynamic library hold their device as a LineDevice (device/carry.rs), as a fence or a library does: device() answers the generation handle of the generation they were made on, else of the one a recovery carried them to last, and the lost generation's handle goes at its rest. A creation's archive check matches an archive by its device's line (its root handle), so a creation of any generation lists an archive made before a recovery; each add makes its state on the generation that serves (Device::at_serving through the root handle), its used artifacts taken afresh for each run. Docs: both modules, carry.rs, MadeBeforeRecovery, the DeviceRecovered cost (degradation.rs and docs/API.md, equal), the runtime README. REFUSALS.md regenerated: unchanged. Why: an archive made before a recovery refused its adds there (its creation ran on the lost generation) and every creation that listed it (MadeBeforeRecovery), and both kinds held the lost VkDevice while they lived; Metal's go on. Verified: see the lane run reported with this sha (the test commit before it fails, this one passes). |
||
|
|
1fefc3d956 |
SEMANTICS_VERSION 2065, ARTIFACT_FORMAT_VERSION 510, RUNTIME_VERSION 2167: a one-row ragged dispatch of a simdgroup-only kernel runs flat in the call's threadgroups
The four commits before this one. A ragged dispatch of a kernel that uses simdgroups was split into a body and an edge variant, a second full compile of the same kernel (Blender's Cycles kernels on RADV: concurrent ~11 GiB compiles). The kernel partition now has three classes, decided from structure alone (barrier execution scope, fence and atomic scope, simd_/quad_ functions, is_uniform, the simdgroup size, the lane builtins): Oblivious, Simdgroups and Observed; air.all/any of a bool vector now counts as the thread's own (a BoolReduce false positive). New: KernelFacts::partition_simdgroups, LoweringInputs and VariantKey::call_threadgroups, RuntimeFact::CallThreadgroups (Variant mechanism, fact id 97). Under flat_grid + call_threadgroups invocations count by subgroup lane order in the flattened tiers, so workgroup w is Metal's threadgroup w with its simdgroups; the lane builtins are derived; lanes past the grid return before the body. The compile refuses the bit without flat_grid, with replay_bindings, or for a module that would hold a workgroup barrier. The runtime's flat_direct tries the plain flat variant first and, for a one-row grid in one-row threadgroups, then the call variant (its own refusal flag; None, unremembered, when the threadgroup size asks for emulated simdgroups). Indirect and replay paths still need an oblivious kernel; a kernel with a threadgroup barrier keeps the split. Verified (on the branch): m3-max-23184 (gem10, at 4c5d46f8d9) workspace clippy all features, clippy m2v_gpu on runtime and validation, rustdoc, 136/137 translator tests (the one a test's use of flat_rmw, fixed after), lavapipe 7/7 (FLAT-SIMDGROUPS VkPipelines [1, 2, 2, 2]; lavapipe's 8-lane subgroups emulate the sum, so it splits); m3-max-23193 (8a46347092) 10/10, a_flat_grid_of_the_call_s_threadgroups_admits_a_kernel_of_simdgroups over every committed profile; 780M RADV (m3-max-23200) 4/4, VkPipelines [1, 2, 2, 1]: the simdgroup barrier + simd_sum kernel runs flat in one VkPipeline, every thread's word matching Metal's partition, the partial last simdgroup's sum included; m3-max-23202 workspace and m2v_gpu runtime clippy clean. No guest kernel was dispatched through this path. |
||
|
|
fb41ed11d9 | Name the simdgroup kernels' one-row flat dispatch in the split-dispatch notice's entry | ||
|
|
9b308145e9 |
A texture buffer goes on over its carried texels; the notice counts lost textures by storage mode
What: Texture::carry makes a texture buffer of new_texture again over its texels' buffer where the recovery carried that buffer (texture_buffer_over, the runtime's own ID use), so a Shared one reads the bytes the buffer carry kept; where the buffer was left it is made new as before. Remade splits the textures whose contents were lost by storage mode (Shared, Managed, Private or memoryless), and the recovery's notice says those three counts. carry.rs says how kept bytes are read: Vulkan makes the content of external memory imported to a lost device undefined (vkspec 5.2.3), read as the hung work's writes possibly landing in part; once the lost import goes, the pages are only our or the caller's memory. Docs: texture/carry.rs, carry.rs, the DeviceRecovered cost (degradation.rs, docs/API.md, equal), the runtime README, and a known gap in docs/FAST-PATHS.md: a recovery loses the contents of textures whose only copy is device memory (new_texture of any storage mode), textures over carried pages keeping what their buffer keeps. Why: the consumer asked for Shared textures' contents kept across a reset. A texture of new_texture of any storage mode has no copy outside its image in the lost VkDevice's memory, so keeping it would need a CPU copy at a cost to every frame; decided against for now, and recorded as the known gap. Textures over carried pages already keep their bytes; texture buffers did not. Verified: see the lane run reported with this sha (the test commit before it fails, this one passes). |
||
|
|
b564fb7a91 |
A recovery carries textures, their views and those over carried buffers
What: a device's recovery now carries the program's textures made by a call it can make again (texture/carry.rs). That covers a texture of `Device::new_texture`, a texture over a buffer the recovery carried (`Buffer::new_texture` and its kin), and a view of either. - The call is made again on the new generation as the runtime's own texture, which takes no ID. That texture holds the program texture's parts there: `TextureShared::next`, with a `carried` flag. - `Texture::s` picks the parts the work at hand reaches. Inside a command buffer's work it answers that generation's parts (`NoticesFor::generation`); elsewhere, those of the generation the texture was carried to last. The buffer carry picks its parts the same way. - Every read of a per-generation field goes through it: `storage()` (the hub), facts, faces, usage shadows, storage forms, render shadows, snapshots, memoryless backings and planes in place. - The texture object keeps its `ObjectId`, resource ID, label, parent and handles, and its purgeable state is copied across. Its ID's slot in the new generation's texture table and heap sets names its parts there (`heap_sets::place`), and leaving the slot walks every generation's parts. - Each program texture is kept by its generation's carry registry as it is made (`Carry::texture`). The call that made it sets how to make it again (`Remake`) and carries it itself where the take came first (`Device::kept_texture`, `Carry::late_texture`). - The carry runs inside a `NoticesFor::of_generation` scope for the new generation, so the buffer it remakes a texture over and a view's parent answer their parts there. - Left refused, and counted by kind in the notice: a heap's texture or one over a heap's buffer, a texture over the caller's `VkImage`, a sparse or shareable texture, a texture over a buffer left, and their views. - The notice adds ", and N textures whose contents were lost too (they read as new ones), M textures over the buffers carried and V texture views". Known gap, documented in API.md, the README and device/carry.rs: a carried texture's images on the lost generation, and so the lost `VkDevice`, stay until the texture goes. Letting them go at the lost generation's rest needs a hold of the parts by each call outside command buffers' work, as `Buffer::held_parts` does for buffers. Why: render targets and display textures made before a recovery were refused (`MadeBeforeRecovery`) where they met the new `VkDevice`, while Metal's go on. Tests: device_recovery_carry's main test now leaves a `Shared` heap instead of a texture as the object that keeps the lost `VkDevice`. Its held-parts test now expects the texture made by a call that completed on the lost generation to be carried by its maker. Docs updated: `MadeBeforeRecovery`, the device-recovered cost (degradation.rs and docs/API.md, kept equal), the runtime README and the heap docs. docs/REFUSALS.md regenerated (`view` became `view_as`). Verified: the lane run of the test commit before and this one after is reported with its sha. |
||
|
|
dc859fee56 |
Residency: host_imports_resident counts releasable imports alone; host_imports_held_for_good the rest
What: an import a read other than a blit's keeps for good (Residency::held_for_good) leaves the host_imports_resident gauge and joins a new gauge, host_imports_held_for_good, as it already left the device's count against its most (Shared::resident). Every move of an import's memory (a release, an import again, let_go, the drop) now goes through one place, Residency::holds_memory, which counts it as releasable or as kept for good, by the flag under the state lock, as the most was counted. WorkCounts docs, host_residency.rs's Counted list and HOWTO.md say so; the API table and host_ab's list name the new field. Why: host_imports_resident's doc said 'the imports the device may release', but it went down only at a release, a let_go or a drop, so it also counted every import kept for good. A guest walk on the RX 7900 XTX showed about 1,040 'resident' beside a cap of 64 releasable imports, which read as the cap failing. The two gauges show both numbers without subtracting. Verified: the dma-buf and pointer residency tests now check the exposure step moves the import from one gauge to the other, and that a gone import leaves both (job ids in the report). |
||
|
|
b1d963289e |
The resident-set search is its loop alone, without 16 unrolled steps
Each resolve of a loaded pointer emitted 16 unrolled binary-search steps before the loop that
finished sets of more than 2^16 entries. RADV inlines every call of the search, so a module with
many loaded pointers paid the 16 steps at every site: on a curve-shading kernel with 1,065
searches, its creation on the 780M took 92.9 s and 8.4 GiB of compile memory.
The search now starts the loop from all N entries. A step halves the candidates whatever its
compare gives, so the trip count, ceil(log2 N), depends on N alone: every invocation that
searches one table takes the same branches, and a set below 2^16 entries does fewer entry loads
than the 16 steps did (they kept loading after one candidate was left). search_step is the loop's
step; search_rest is now bisect, from (0, N). SEARCH_STEPS is gone, SEARCH_WORDS charges one step
plus the loop, and the docs (roots.rs, API.md) and the tests that named the unrolled reach say
what is true now. The handle-table search keeps its own unrolled steps. Answers are unchanged.
Measured on the 780M (RADV PHOENIX), before (
|
||
|
|
f5d97f8e95 |
Cut a rate-mapped execution's big draws into ranges of their indices
A piece bound by command count, or by whole commands, still lets one command hold unbounded work: the sample's largest executed command draws 161,820 indices, times its 2,074 regions about 2.5 times the old piece work in one draw. Where an executed command's draw in a rate-mapped pass would alone hold more than the piece work, it is now drawn as consecutive ranges of its indices, each a draw of its own that a piece may begin before. That draws what Metal's one draw does only for an indexed list (points, lines, triangles: Metal never restarts a list) cut at primitive ends, of one instance, whose pipeline reads no [[primitive_id]] and writes no memory; every command of the sample is such a draw. Ranges are sized by the most region draws a draw of the execution made so far (the most a plan holds before any), an even count of primitives so 16-bit ranges keep 4-byte offsets. Any other draw rides whole: FAST-PATHS' known gaps now name them, with the encoder's own draws, as able to pass amdgpu's job timeout and NVIDIA's context-switch timeout. PIECE_WORK halves to 2^26, so a piece of cut draws holds under 2^27: about 56 ms of Iris Xe at a trivial vertex function, 35x under 2 s. WorkCounts::rate_map_index_ranges counts the ranges past the first; the signature table gains it and the four piece counters. A runtime device test draws eight commands of a twice-drawn blended triangle grid through 32-bit and offset 16-bit indices over a falling map, and checks the execution cut under a small piece work against the uncut execution and the encoder's own draws, byte for byte, with pieces and ranges counted. Unverified at this commit: the compile check and device runs are next. |
||
|
|
a610b58b8a |
A replayed draw whose making outlasts the commit's bound leaves its pass to the host step
The last draw dropped for its making's time: a draw of an execution's replay at commit (render commands the CPU writes) whose pipeline the replay began itself and that was still being made at the command buffer's bound recorded nothing. Metal cannot encode a draw before its pipeline exists, so every encoded draw runs. Now the replay at commit stops there, keeps the making on the command buffer (CommandBuffer::leave_unmade), and the pass takes it into the makings its host step waits for (DeferredPass::left_for_makings): the commit leaves the pass to the host step with its pipelines pending, as it already did for a pass whose settled makings were still being made, and the step records it from the records as they stand then once the making lands. A replay inside a host step waits for its making until made, on the step's thread. record_on_gpu declines to the host step the same way. The commit still returns at its bound at most. Removed: DrawDroppedStillMaking, WorkCounts::draws_dropped_still_making, CommandBuffer::drop_late_draw, RenderLowering::drop_late_replayed_draw, the execution's encoder place that only named the dropped draw, and the open-gap text in FAST-PATHS row 43, API.md (the bullet and the catalogue entry), the runtime README and the PipelineWaitPolicy docs (api_signatures.tsv -2). The IndirectCommandCheck and executed-commands docs name the new case in which an execution read at commit is read and checked again in its host step. The gap's test flips: a_replayed_draw_whose_pipeline_is_still_being_made_at_its_bound_renders_once_made (commit returns after the bound and before the 10 s watchdog; the command buffer is not complete a second past its bound while another queue completes; once the hold goes it completes with the rectangle drawn and nothing dropped). Checked by the lint and lavapipe jobs reported with it. |
||
|
|
b4eaf4caa7 |
Keep the replayed draw's test as the open gap's, and name the gap by the replay's own wait
The lavapipe run (m3-max-23046) showed a draw of a commit-time replay of CPU-written records dropped at the bound: the replay waits for that making itself, which the settle did not leave to the host step. That is the open gap this change keeps; its test asserts the drop, and the docs name the gap by the replay's own wait. |
||
|
|
91dbc91bbc |
Hold a command buffer for its draws' and dispatches' makings instead of dropping them
A dispatch whose pipeline was still being made 4.5 s after its command buffer's commit recorded nothing, and so did such a draw. Metal makes a state's pipelines inside its creation, so every draw and dispatch it encodes runs: a dropped dispatch leaves wrong results (a guest's path tracer dropped 45 dispatches behind a 116 s compile on the RX 7900 XTX), and a dropped draw leaves content drawn once (a cached shadow map, a glyph atlas) without it. The owner's rule: no switch may break Metal's contract, so the dropping form is removed, not kept behind a switch. A batch's host step now waits for every making its segments record, past the bound too (Segment::steps_after_pipelines; the scheduler's StepWaits loses its `until`, and Segment::holds goes): the batch stays in its queue's line on the scheduler's thread, which no call waits for, and records the draws and dispatches once made. Held batches still give way to other queues' later commits that share no fence. `commit` waits for no making but a pass that executes render commands the CPU writes, until its bound, and leaves that pass to the host step past it. The pending dispatch, tile dispatch and pending draw recordings wait until made. DispatchDroppedStillMaking, its counter and catalogue entry, and CommandBuffer::drop_late_dispatch are removed. One drop remains, an open gap named in FAST-PATHS and the notice: a draw of an execution's replay whose pipeline the replay itself began making, of a key the commit's settle did not foresee, still being made at the bound (DrawDroppedStillMaking, now that case alone). That case is the next change. Tests (device, rewritten): a draw, a replayed draw and a dispatch whose makings are held past the bound each complete once the making lands, drawn or written, nothing dropped, while another queue's command buffer completes meanwhile and the held one is still not complete a second past its bound. |
||
|
|
3c88a7df60 |
An address pool goes on past its device's recovery
What: `AddressPool` holds a root handle of its device (`Device::root`) and the device's address space, instead of a handle of the generation it was reserved on. A buffer placed in one of its slots after a recovery passes the same-device check (`Device::same` answers a root and any generation of its line alike), and the pool's drop gives its span back to the address space, which every generation shares, without reaching a generation. Why: a consumer found that after a recovery every new buffer in a slot of a pool reserved before it was refused (`MadeBeforeRecovery`), which refused all of its buffers under 16 KiB. A pool holds no Vulkan object and no memory: it is a span of the line's address space (`AddressSpace::reserve_pool`), and a buffer in a slot takes its own memory as any buffer does, only its Metal address from the slot. Holding a generation handle also kept the lost `VkDevice` alive while the pool lived. Docs: the recovery lists in `MadeBeforeRecovery`, the device-recovered cost (degradation.rs and docs/API.md), the runtime README and device/carry.rs name address pools; the pool's own docs say it goes on. docs/REFUSALS.md regenerated with no change. Verified: the lane run of the test commit before and this one after is reported with its sha. |
||
|
|
6e3b5d4795 |
Guest RAM: a copy over a chunk that takes no import goes through the CPU always
On ANV an object over a listed chunk keeps its own import (residency flat), which holds
the chunk back from the copies over it, as an object's pointer import at the RAM's own
addresses does on every device. copy_take answered such a chunk ThroughCpu, but
stages() still declined a gather some use may write the bytes of (an object lies over
them) and any copy that also touched a chunk it would import (Waits); those went to
the chunk's import and failed with the invariant "a guest RAM chunk a live import of an
object's own holds pages of" (a consumer's IOSurface block on the Iris Xe).
Now copy_take answers CopyTake::CpuOnly for a chunk the device refuses or objects' own
imports hold back, and stages() stages every copy over one, whatever else it touches
(Staging). A gather over such a chunk whose host bytes some use but a copy's read may
write takes a part of its own (Deferred::gpu_written for its GatherStage), so the work
before it in its command buffer is submitted and completed before its host step reads
the pages; its uses are noted again at that part's start, where its copy lies, and it
counts as a gated fill. An encoder holding a gather over such a chunk keeps no log
(Deferred::recorded_by_an_encoding_again), since an encoding again would copy it
through the imports.
Docs: copy.rs ("First touch", stages, record_staged, Staging), host_ram.rs
(CopyTake::CpuOnly, copy_take), deferred.rs, HOWTO.md.
|
||
|
|
bf9e921058 |
Guest RAM: on ANV an object over a listed chunk keeps its own path
7536aa8c75 had an object over a listed chunk not imported import the chunk where the device's barriers do not order two imports of the same pages (ANV), or where the object had no source of dma-bufs. With a consumer's run resolvers on every object, that pins every 512 MiB chunk any object lies in, the residency regime RV 2144 left. Back to RV 2144's object path on every listed plan: the object takes its own path (its import of dma-bufs alone where the aliases are ordered, 345302afc2). On ANV its own import still holds the chunk back from the copies over it; the CPU path that takes those copies follows separately. The beside test now runs where the device orders the aliases only, and the listed idle test's first object takes its own import on every driver, as before. |
||
|
|
f7941289d2 |
Guest RAM: an object a listed RAM routes outside its chunks imports its dma-bufs alone
The object's own path on a listed plan whose device orders two imports of the same pages (7536aa8c75) took its pointer first wherever the device takes it, as every own import does (lavapipe takes a shared mapping's pointer; RADV refuses it, so its imports there were dma-bufs already). An import of the pointer at the RAM's own addresses holds the chunk back (one page, one import), so the copies over the chunk could still not import it. Now pages a guest RAM routes that no chunk binds in, where the RAM's chunks may be imported beside them (Routed::own_dma_bufs: listed plan, ordered aliases), are imported as the caller's dma-bufs alone, never by the pointer and the gate not asked, as pages beside live dma-buf imports are since RV 2134; a failed import of them is a copy. At the buffer's making and at a rebind. Found by the new test on lavapipe (m3-max-22946): the object's own import was ImportedByPointer where the test expects ImportedAsDmaBuf. |
||
|
|
9c35a3407d |
Guest RAM: a listed chunk is imported beside objects' own dma-bufs; on ANV objects import it
Since RV 2144 an object over a chunk not imported on a listed plan takes its own path,
outside the RAM's routing. At the RAM's own addresses its import is noted in the
aliases registry, which held the chunk back (RamOnDevice::held_back): the chunk could
not be imported while the object lived, and a copy by runs over it that no CPU stage
takes (a gather over bytes an object lies over) failed with "a guest RAM chunk a live
import of an object's own holds pages of" (a consumer's IOSurface block on the Iris Xe,
Mesa 26.7.2; on the 780M the hold-backs went from 4 to 45 in a walk once every object
got a run resolver, the copies falling to run lists).
Two cases, by whether the device's barriers order blits through two imports of the
same pages:
- They do (RADV, lavapipe): held_back now answers Held::{Free, BesideDmaBufs, Back}.
Where every live import holding the chunk's pages is of dma-bufs and the plan is
listed, the chunk is imported beside them as one dma-buf of the RAM's source, never
by its pointer (import_chunk's new beside flag drops the pointer fallback): two
aliases of external memory, ordered by the host bytes they lie over, the rule
Device::imports_beside applies to objects' own dma-bufs since RV 2134. Counted as
ObjectChurn::dma_buf_imports_beside_live, not host_ram_chunks_held_back. Imports of
a pointer, and claims in flight, still hold the chunk back.
- They do not (ANV, AliasedImportBlitsUnordered): the chunk's import beside an
object's would be unordered, so an object there takes the chunk's import (made or
waited for), as it did before RV 2144 and as on plans that import ahead. So does an
object with no source of dma-bufs of its own pages, whose own import would be of its
pointer. for_object takes the object's `sourced` (HostWindow::source) through
bind_in_chunk.
Docs: host_ram.rs (module, Held, held_back, for_object, copy_take, import_chunk,
use_host_ram), WorkCounts::host_ram_chunks_held_back and chunk_bound_buffers_made,
ObjectChurn's two import counters, HOWTO.md.
|
||
|
|
62923811dc |
A library and its functions go on past their device's recovery
What: a library holds a root handle of its device (Device::root) rather than the generation it was made on, and its functions take that handle, as a fence does. A library is the compile layer's parsed library and a function the compile layer's function with its constants, no Vulkan object; their sampler-ID holds are the line's resource IDs, which every generation shares. So a pipeline made from them on any generation passes its device check (same matches a root handle by its line), and they no longer keep the lost VkDevice alive. Docs: library.rs, carry.rs, MadeBeforeRecovery (libraries leave the refused list), the device-recovered cost (degradation.rs and docs/API.md), the runtime README. REFUSALS.md regenerated: unchanged. Why: after a recovery a pipeline made from a library or function made before it was refused NotImplemented(MadeBeforeRecovery); Metal's library goes on. Verified: see the lane run reported with this sha (the test commit before it fails, this one passes). |
||
|
|
fb7eaa8cbc |
A depth/stencil state goes on past its device's recovery
What: a depth/stencil state holds a root handle of its device (Device::root) rather than the generation it was made on, as a fence does. The state is its descriptor and the compile layer's Vulkan depth/stencil state, no Vulkan object, so a render encoder of any generation accepts it (check_device matches a root handle by its line), and it no longer keeps the lost VkDevice alive. gpu_resource_id asks supports_family, which goes to the serving generation, instead of the "now" form a root handle has no generation for. Docs: depth_stencil.rs, carry.rs, MadeBeforeRecovery, the device-recovered cost (degradation.rs and docs/API.md), the runtime README. REFUSALS.md regenerated: unchanged. Why: after a recovery a state made before it was refused NotImplemented(MadeBeforeRecovery) at set_depth_stencil_state; Metal's state goes on. Verified: see the lane run reported with this sha (the test commit before it fails, this one passes). |
||
|
|
e05beb832d |
A fence goes on past its device's recovery
What: a fence holds a root handle of its device (Device::root) rather than the generation it was made on. A fence has no Vulkan object, only the key the tracker orders on, so update_fence and wait_for_fence of any generation's encoder now accept a fence made before a recovery (check_device matches a root handle by its line); an update made on a lost generation went with that generation's work, so a wait on the next one finds none, as for a fence never updated there. The fence no longer keeps the lost VkDevice alive. Docs: fence.rs module and item docs, carry.rs, MadeBeforeRecovery, the device-recovered cost (degradation.rs and docs/API.md), the runtime README. REFUSALS.md regenerated: unchanged. Why: after a 780M gfx ring timeout and a recovery, a guest's waitForFence: calls were refused NotImplemented(MadeBeforeRecovery) about 2,000 times; Metal's fence goes on. Verified: see the lane run reported with this sha (the test commit before it fails, this one passes). |
||
|
|
b10839e2b2 |
A recovery carries Private heaps with the buffers placed in them
What: a device's recovery now carries each live heap to the new VkDevice (Heap::carry,
called from Device::carry_to after the buffers, or by a heap's maker where the recovery
took the generation first). A Private heap's own buffer is made again in new memory placed
where the heap's textures can lie (place_heap_buffer), zeroed as a carried Private buffer
is, keeping its ObjectId, hazard key, Metal address and range, range token, label and
purgeable state; the heap is registered by its key there and kept in the new generation's
registry for a later recovery. Each live buffer placed in it gets a new link on the new
generation (Buffer::carry_placed) at the same offset of the carried bytes, with the same
ObjectId, address, label and a shared aliasable flag; its old link lets go of its live-list
entry and device handle at the lost generation's rest (LostPlaced). A placed buffer's drop
gives an automatic heap's range back only from the link carried to last, so a carried
buffer frees its range once. A buffer placed while the heap is being carried carries itself
under the heap's placed lock. The heap's textures made before stay the lost generation's
(no recovery carries a texture); the heap forgets them (keeping their numbering), so a
use_heap on the new generation never makes an old image resident. Shared heaps (their bytes
are pooled host-visible memory, never the runtime's own pages), no-copy heaps and sparse
heaps stay left, with their buffers.
The recovery notice now counts carried heaps ("N `Private` heaps (B bytes) with the M
buffers placed in them") and left heaps by kind, and splits the old "buffers over the
caller's or exportable memory" into "buffers over the caller's `VkBuffer`" and "buffers in
exportable memory" (Left::Caller / Left::Exported). Docs: carry.rs module docs, the
Buffer::carry docs, heap.rs, MadeBeforeRecovery, the device-recovered cost (degradation.rs
and docs/API.md), the runtime README. REFUSALS.md regenerated: unchanged.
Why: after a GPU recovery a guest's MTLHeap newBufferWithLength:options:offset: was refused
NotImplemented(MadeBeforeRecovery) and the guest got nil; Metal's heap goes on.
Verified: see the lane run reported with this sha (the test commit before it fails, this
one passes).
|
||
|
|
da3cea7633 |
A heap texture's chosen constexpr samplers are one sampler array, not a switch
A heap texture sampled through one of several constexpr samplers that a sampler handle names at run time (a table of constexpr samplers read at a computed index) was a switch-at-use with one arm per candidate: each arm its own heap sampling and raw-texel emulation. On large kernels that multiplies the sampling code by the candidate count. Where every candidate is a constexpr sampler, their handles are consecutive, each candidate's sampling is the same but for its sampler and the state its raw emulation follows, the use is not tangled, and the device indexes a sampler array non-uniformly (shaderSampledImageArrayNonUniformIndexing, which heap textures already need), the sampling is now one sampling through a set-0 array of the candidates' samplers (ResourceKind::SamplerArray, BindingSource::SamplerArray): element handle - first, NonUniform, its immutable samplers each made as the heap sampler of that candidate alone would be (DescriptorBinding::immutable_samplers, listed per stage in StageInterface::sampler_arrays). A handle outside the array reads zero, as the switch's null arm. The raw emulation reads the element's sampler word from a constant table at the same index (heap_raw::State::Table), through the runtime-word path. Elsewhere the switch stays. The runtime bakes one sampler per element into the set layout, pushes each element's own sampler where set 0 is pushed, and keys the set-0 shape on them. Tests: the array form on every profile with the sampled heap (one sampled image, L3), the switch kept for non-consecutive handles, each element equal to the immutable sampler of the candidate sampled alone and never written by the plan, and a device test (lavapipe under m2v_cpu_icd) that each lane reads what its sampler alone reads and what the address modes define. Docs: API.md section 5, the sampler module doc, api_signatures, api_surface, REFUSALS regenerated. |
||
|
|
bcfec16960 |
A rate-mapped draw skips the regions its viewport and render area leave no pixel
Each draw of a rate-mapped pass was recorded once per region of the map's plan, even where the region's scissor, cut to the pixels whose centres lie in the guest's viewport and to the render area, held no pixel. Such a recording shades nothing (the scissor test discards every fragment), and its vertex function repeats nothing observable (a plan of several regions refuses a vertex function that writes memory), so it is now left out. Where the cut leaves no region a pixel, the first region alone is still recorded through its empty scissor, so the vertex function runs as Metal's does. A draw whose viewport covers part of the screen now records only the regions it reaches; one over the whole screen records what it did. The new lane test draws the case's fullscreen triangle over a 256-pixel map at the falling quality with a viewport over the screen's left quarter: fewer regions than the whole screen's, from an indirect buffer region by region, and the direct (batched) draw shades bit for bit the same pixels, inside the left half of the physical columns. |
||
|
|
1b1ebfd055 |
GPU times from the host start at the first submission that carried the work
A command buffer whose work went as several submissions (a wait for an event the host signals, an execution its host step records) answered, on a device made with gpu_times_from_host or a driver whose timestamps wait for every queue's, the call of its LAST submission (its kernelEndTime) as its GPUStartTime: its window missed the work of its earlier submissions. Metal's GPUStartTime and GPUEndTime span the whole command buffer's GPU work. A consumer that answers GPU times from the host read windows of 0 to 240 ms on an Iris Xe for command buffers whose kernel start to end spanned 2 to 8 s, each GPU start at the kernel end. KernelTimes keeps the call of the first driver's submission that carried a batch of the command buffer (the batch's own vkQueueSubmit, or its group's), and the host-clock start is that call where it came before the kernel end, else the kernel end as before, or the queue's latest GPU end where later. A command buffer whose work went as one submission answers as before. Devices that write timestamps already started at the first batch's timestamp (lavapipe, job 22670: GPU start 173 ms before the signal its second batch waited for). Docs: gpu_time.rs (the host-clock bullet, rule 2), gpu_start_time, DeviceOptions::gpu_times_from_host, the GpuTimesFromHost notice's cost and its API.md entry. Verified: pending lavapipe before and after, the 780M, lint. |
||
|
|
6014ad370d |
Faces: a logged pass turns, and an encoding again meets the faces as first met
While the device has a buffer over host pages, every render pass logs its calls for a rebind, and a pass with a log, or with an earlier encoder of its command buffer keeping one, turned no texture (Unturned::Pass): under a consumer that keeps host-page buffers alive, no attached read ever took the turn and every one copied in. A logged pass now turns as any other. A rebind's encoding again of the command buffer's encoders meets the faces as their first encodings met them: the encoding again runs with a thread-local context of the command buffer and the encoder's parts (with_faces_as_of); a texture a later pass of the command buffer turned presents the face from before that turn to it (Faces::face), and the turning pass encoded again takes its turn again (Texture::retake_turn: the shadow of the face from before the turn held current, no copy in). Any other pass encoded again turns nothing. TurnPoint drops logs_kept; SwapRecord keeps the face it turned from. The shadow log (METAL2VULKAN_LOG_SHADOWS) also names, once per shadowed texture, at the first draw that binds it after its shadow was made: the slot, whether the function fetches, samples or writes it, and each sampler's min, mag and mip filters (a sampler state's by Metal's names, a constexpr sampler's as the layout bakes it). Tests: the runtime's attached_read_faces gains a lane with a host-page buffer alive (a logged pass turns; a blit and a turning pass behind a shared-event wait, encoded again by a rebind, read the texels from before the turn), against the same lane beside an open command buffer (the copy route); the validation crate's runtime_lane::logged_face_turns runs the same under the layer. Not yet run: dispatched next. |
||
|
|
7926fa6e66 |
SEMANTICS_VERSION 2062: the predicated walk's size estimate charges what the walk emits
The commit before this one. The emulated-simdgroup variant (a dispatch whose threadgroup leaves a partial simdgroup) took its size forecast from divergent::extra_words: 512 words per AIR block and 12 per operand use, about 15M words on a large kernel, so two kernels of a guest's path tracer (4.0M and 4.5M words emitted) were refused LimitExceeded(SpirvWords) before emission, where Metal makes them. The estimate now charges each construct the walk emits beyond the plain walk, from the structured tree (guards per segment, syncs and their guarded stores, reloads of demoted uses, flag and vote words per walked loop, arm sequencing per walked branch); each constant names the emitter code it bounds. Translation results change: modules that were refused now translate. Verified (on the branch): nextest -p metal2vulkan --all-features (m3-max-22642) 3500/3501, the one failure golden_hashes from SEMANTICS_VERSION 2061's pending re-bless (blessed since at pin 59; this commit changes no emitted word); the shared test helpers assert estimate >= emitted on every Emulated-tier or walked module the engine suites build; a_large_predicated_body_compiles_under_a_cap_it_fits (old forecast ~20x emitted). Lint m3-max-22643. Release translation, amd-780m-radv profile (m3-max-22644): the two kernels' emulated variants at 1.64 s / 256.6 MiB and 1.99 s / 287.4 MiB, within 20 s / 500 MiB. Census over the 3,781 simd/quad/barrier rows on vk12-floor (m3-max-22649) pending. |
||
|
|
cc694355b1 |
Residency: a device test of the release past the most, and the guide's and HostMemory's words for it
past_the_most_resident_the_least_recently_read_import_is_released: with the most held at two (Device::keep_resident_host_imports), three dma-buf imports read in turn; one released past the most, the least recently read; the other two read with no import again; the released one's next blit imports it again and reads the file's writes made meanwhile. It prints the free's and the import again's times. HOWTO.md and HostMemory::with_dma_buf say a device whose held imports cost every submission keeps at most 64 resident. |
||
|
|
f62966f4f0 |
did_modify_range's bytes are taken at the next commit, as Metal takes them
What: did_modify_range (and a CPU write through a texture over a buffer) notes the range on the device (managed.rs Modified); every commit, at its start and before it returns, copies each noted range of a buffer with a host copy on the CPU into staging buffers as the host copy holds it then (Buffer::upload_now, CallerCopy::copy_in_now, managed_copy::stage_in), which the next submission copies into the device copy before any of its commands. A range the staging buffers find no memory for falls back to the copy from the host copy as the submission runs. Why: the copy in read the host copy (the caller's pages through their import, or the runtime's own host copy) when the GPU ran it, so a CPU write made after the commit, before the GPU reached the command buffer, was what the command buffer read. Metal on a Radeon Pro 5300M (macOS 26.7.1, reims's oracle) takes the bytes at the commit after didModifyRange: a write before the commit (after the call, or with the command buffer encoded before it) is read, one made 30 ms after the commit while the GPU spun is not. Capturing at the call would be wrong (steps 2 and 3 read the later write there). An RX 7900 XTX computed frame 0 of a benchmark on frame 1's input this way. Docs: managed.rs and managed_copy.rs state the rule and its cost (a CPU copy of the range's bytes at the commit); API.md, the runtime README and FAST-PATHS.md's managed row follow. managed_bytes_copied_in counts a caller copy's copies alone, as before. Verified: the lane test of the parent commit on an RTX 3090 (job ids in the report). |
||
|
|
27cd4bccc0 |
Guest RAM: on a listed plan an object over a chunk not imported takes its own path and asks for no chunk
On a device whose plan is listed (each held import costing every submission and the RAM's chunks its dma-bufs: RADV, ANV where the import tax holds), an object over a chunk whose import was not made was bound in an import of its own run and asked the device's thread for the chunk, which faulted in and imported the whole chunk: udmabuf allocates every page of it and keeps them after the import is freed, so attaching runs to every no-copy object would make the guest RAM under every object resident chunk by chunk (12.3 GiB of a 16 GiB guest on the 780M before the listed plan). Now such an object is bound in the chunk only where its import is made, and otherwise takes its own path, as over memory no RAM holds: no run import, no ask. Chunks are imported for the copies over them, and the objects over them after that lie in them. Plans that import ahead (NVIDIA, host-pointer chunks) are unchanged. Removed with the object path: RunAgain, Routed::run_again, Placement::over_ram_run, the residency's AgainFrom::RamRun with Device::ram_run_in_chunk and ram_run_alone_again, and WorkCounts::run_bound_buffers_made (an object is never bound in a run import now; copies keep their ranges alone and run_imports_live). Docs: host_ram.rs, host_residency.rs, copy.rs, HostMemory::with_runs, driver_defects.rs, WorkCounts, HOWTO.md; the API signatures table re-blessed. Tests: the listed tests now import their chunks by copies; the first object over a chunk not imported, with a source of its own pages as a consumer's come, takes its own import, no chunk imported and none asked of the RAM's source, and the objects over a chunk a copy imported lie in it. The other host RAM tests lose their run-bound terms (0 on every plan they run). |
||
|
|
a7ba65dd66 |
synchronize_texture copies a Managed texture's bytes over a two-copy buffer out
What: on a device without unified memory, BlitCommandEncoder::synchronize_texture now copies a Managed texture's bytes over a buffer from the buffer's device copy to its host copy (the caller's pages, or the runtime's own host copy), as synchronize_resource of the texture already did. A level that lies in the image alone (a tiled texture's past its first) copies nothing; a texture of an image alone still records nothing, its CPU access reading its image. The copy is shared code: synchronize_resource's buffer and texture arms now call synchronize_bytes and synchronize_texels. Why: synchronize_texture recorded nothing on every device, its doc saying Managed memory behaves as shared memory. Without unified memory a Managed buffer is two copies (managed.rs, managed_copy.rs), and a texture over one serves get_bytes, and the buffer its contents, from the host copy (buffer_texture.rs Texels::read). So a program that synchronized with synchronizeTexture:slice:level: read the CPU copy as of its last didModifyRange: stale texels. Found reading the read-back paths for a benchmark that fails validation on an RX 7900 XTX. Docs: the stale doc is replaced; API.md and FAST-PATHS.md name synchronize_texture beside synchronize_resource for the copy out; the managed counters' docs count it. Verified: the lane test runtime_lane::device_copies:: a_synchronize_texture_copies_the_texels_out (a blit into rows of a Managed texture over pages and over a runtime-made Managed buffer, then synchronize_texture: the contents and get_bytes hold the rows; the copy out counted for the pages with two copies) is run on a discrete NVIDIA GPU with this change and once without the runtime fix (negative control); job ids in the report. |
||
|
|
7b27d0b63e |
Re-derive the generated documents at the landing tip
They are generated from the whole case set, and the set grew on `development` while this branch was in flight, so the copy committed here counted a smaller one. Verified: regenerating at this tip leaves no change beyond the `Generated at` stamp. |
||
|
|
df9ae6b02d |
Snapshot reads with no barrier: API.md's accepted difference covers writers
docs/API.md's accepted difference for a draw that reads its own pass's color at its own pixels with no barrier now covers a draw that writes the color too: it reads what the draws before it wrote where the runtime takes no copy for it (in place, or through a snapshot where the device takes that route and the snapshot costs no more than the copy: a surface's reader always, a private texture's by the area rule), else the copy, the M3 Max's texels. Its lead-in is the slug the pass-start-barrier read rows name. FAST-PATHS.md's row and texture/attached_reads.rs say the same, each naming both answers. Verified: docs only; the conformance unit test that the slug exists runs in the 780M job. |