19677fdfd6a71234df65dcbce4c2ab7fcfe0cc7d
1175
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
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. |
||
|
|
090930eebf |
Queue times: a default-off diagnostic notes when a command buffer became its queue's head and when its submission returned
What: with METAL2VULKAN_QUEUE_TIMES set, each command buffer notes two host times beside its kernel times (gpu_time::KernelTimes), read through two hidden runtime-extension methods: - CommandBuffer::queue_head_time: its first batch became the first of its queue's batches the scheduler had not taken. Noted as the scheduler takes it in onto an empty line, or as the batch before it on its line is taken for submission (Order::next, in the scheduler's passes and a committing thread's). - CommandBuffer::submit_returned_time: the vkQueueSubmit that carried its last batch returned (submit.rs for a batch submitted now, group.rs for a group's members). kernelEndTime is that call's start, so the two bracket the driver's time in the call. Unset, nothing is noted and no line is looked up: a relaxed load of the device's flag (read once from the environment into gpu_time::Timing) per take and per submission. Why: walkprof5 (m3-max-22376) put commit -> submission start at 37.0 ms p50, while kernel start to kernel end was 0.008 ms, which does not bracket the vkQueueSubmit cost (the call starts at the kernel end). The consumer's trace needs to split commit -> submission into time behind the queue's earlier work and time held at its head, and to see each call's own length. Docs: env_vars.rs's registry entry and accessor, docs/API.md's diagnostics paragraph, the validation artifact note's list of variables the runtime reads; api_signatures.tsv blessed (two hidden methods). Tests: tests::kernel_end_device::queue_times_are_noted_in_the_order_of_a_queue_s_submissions_and_only_where_asked (three command buffers on one queue, committed back to back): unasked, both read 0; asked (Timing::note_queue_times, test-only), head <= kernel start <= kernel end <= returned for each, heads in commit order, and each submission returned before the next one's kernel start. |
||
|
|
8274894e15 |
API.md: a rate-mapped pass draws several regions in one multi-draw where the device allows it
The accepted difference "A rate-mapped pass draws region by region" now says where the device enables multiDraw, multiViewport, shaderOutputViewportIndex and shaderDrawParameters, a direct draw of a vertex pipeline records up to the least of maxViewports and one below maxMultiDrawCount regions in one vkCmdDrawMulti[Indexed]EXT, its vertex variant storing ViewportIndex as DrawIndex, with the same pixels. Docs only; the behaviour landed in the previous commits. |
||
|
|
62568021fd |
Region viewports: name the three features in the refusal; bless the API table and REFUSALS.md
The refusal under LoweringInputs::region_viewports lists its features literally, so the refusal surface names them (devices without shaderOutputViewportIndex, shaderDrawParameters or multiViewport). api_signatures.tsv takes the new fields and variants; REFUSALS.md the new sites. Verified: signatures.py --bless and refusal_surface.py ran locally (source-only). |
||
|
|
3591461c0b |
Memory log: each copy of a no-copy object's host pages says its caller's pointer and length as it is made and as it goes
An Iris boot lost its VkDevice to one float written into an ANV batch buffer right after the boot's one copied no-copy buffer was made. A copy's merge back writes exactly the bytes the GPU changed into the caller's pages, one 4-byte store for one changed float, so a caller mapping unmapped under a live no-copy buffer and reused for a batch mapping would show that symptom. The memory log (METAL2VULKAN_LOG_MEMORY) placed only device addresses, so it could not test that. With the log on, the copied registry (copied.rs) now says one line as each copy is made and one as it goes: its number, the caller's pointer and length with the range's end, and the copy's host address and end, the two ranges the runtime's comparisons write on the CPU. The going line is said after the registry's lock is let go, as the consumer's sink takes it. Off, nothing is formatted: the registry holds no log. Verified: fmt only here; the new tests::memory line test, clippy and rustdoc run on a CPU node next. |
||
|
|
182e21e83c |
Arguments that function constants put on overlapping slots of one table are an invalid request
Function constants can set an argument's slot ([[texture(c)]]; the frontend states the index as a
global the static initializer computes). Values that put two present arguments of one argument
table on overlapping slots make a specialization Metal refuses when it makes the function: "<kind>
argument X has invalid location (<index,count>)", naming the later argument. Measured on an M3 Max
(macOS 27.0.1) for:
- buffers, a constant buffer and an argument buffer;
- a visible and an intersection function table, and an acceleration structure;
- textures, and a texture array overlapping a range;
- samplers;
- threadgroup memory.
Arguments of two tables at one index (a buffer and a texture at 0) are made.
The translation took such a set as valid and went on. Where a write texture and a sampled one met
on slot 0, the slot plan gave the slot the write access and the sample was refused as
Unsupported(Lowering(Sampler)), NotImplemented: a gap that is not ours. Where the two arguments'
uses agreed, one resource stood for both, a pipeline Metal never makes.
The specialized entry now refuses it (canon::interface, beside the duplicate color output check),
as RequestError::OverlappingArgument { param, index, count } and
DescriptorError::OverlappingArgument. Only present arguments count (MPS keeps gated pairs on one
index), and a count of 0 binds no slot. past_table and the new check share one table map.
API.md, the runtime's new_function_with_name_constant_values doc (the runtime checks constants
when a pipeline compiles the function) and the specialization planner's doc say so. The
signatures table is re-blessed; REFUSALS.md is unchanged (this is a refusal Metal makes).
Verified: the canon test covers each table and the non-overlapping cases. The MPS census A/B
(590 rows, every constant 0, release CLI on msi, base
|
||
|
|
0a4f4e87f2 |
Labels: command buffers and encoders take Metal's label, and a lost device's notice names the hang by them
A lost VkDevice's recovery notice named its hang only as "a command buffer (of queue `Q`)", so an Iris boot's GpuHang (46 victims) left nothing to tell which work hung. The runtime had no label for a command buffer or an encoder at all. CommandBuffer::label/set_label (MTLCommandBuffer.label) and label/set_label on the blit, compute, render and resource state encoders (MTLCommandEncoder.label) now keep what the program sets. A command buffer has one encoder open at a time, so the open encoder's label lives on the command buffer's state, and the encoder's record takes it as it ends: each EndedEncoder reports its label, in its place, a render encoder that ends on the lowering thread included. The recovery names its culprit from the command buffer's state as it fails the pending batches: its label and its queue's, then its first 32 ended encoders' places, kinds and labels, counting the rest, e.g. "command buffer `busy` of queue `relayed` (its 1 encoder: 0 blit `copies`) failed as the hang (`GpuHang`)". set_label and label are no calls in EncoderCall's numbering. The API table, the Metal and conformance coverage maps, docs/API.md's DeviceRecovered entry and the runtime README say so. The table's WorkCounts::spare_command_buffers_freed_past_recorded line moves to where the script sorts it. Verified: fmt only on this machine; tests::labels (both lowering policies) and tests::device_recovery's relayed-loss test, which asserts the named notice, run on lavapipe next. |
||
|
|
ad402b548e |
Every VkPipeline the runtime makes is named for the validation layer's messages
Where the instance reports messages (VK_EXT_debug_utils), each pipeline now carries a debug name, which the layer prints after its handle. Until now only a raster-order pipeline was named, so a synchronization report could not tell a program's kernel from one of the runtime's own. - A program's pipelines are named by its Metal functions' names, in pipeline order, joined by " + ". Each variant's objects keep them (`VariantObjects::name_pipelines`), set where a compute variant is made (`pipeline/mod.rs`) and at each render variant's making (`RenderVariant::of`). A pipeline library is named the same, with its part in parentheses. An indirect-bindable replay pipeline takes its variant's names. - The runtime's own pipelines are named "metal2vulkan: " and the kernel or step: each owned kernel by its module (for example "metal2vulkan: PagesCopy(Gather)"), the split, merge, resolve, copy and plane steps by their kind, the in-place check's draw, and the priming's kernels beside its pipeline. - A raster-order pipeline keeps its name alone, since the validation crate's lanes match it whole (`raster_order_gap.rs`). - A name is worked out only where the instance reports messages (`DeviceShared::name_pipeline` takes a closure), and nothing reads it: it is a diagnostic, and no translation or runtime path depends on it. Why now: a sync-validation run on the XTX (SYNCVAL_SHADER_ACCESSES_HEURISTIC) reported 45 WRITE_AFTER_WRITE hazards. All were vkCmdDispatch after vkCmdDispatch, on one pipeline, at storage binding 1 of a pushed set 0. What the code points to, which the next run's names will confirm or not: - The runtime's pushed kernels are RowsCopy, PagesCopy and the shadow copies and merges. Of those, the ones whose binding 1 is a written storage buffer are PagesCopy(Gather), RowsCopy and ShadowCopyBack. - Only PagesCopy(Gather) records several dispatches in a row with one pipeline in one command: one per guest RAM chunk the runs touch (`host_ram/copy.rs`). Every one of them binds the same window of the destination buffer at binding 1. - That path is taken only when no destination byte is written twice (`twice()`; a gather whose runs share a buffer byte takes regions instead), so those dispatches write disjoint words. The tracker orders the copy as one command over its whole span. - The heuristic counts each dispatch as writing its whole bound range. So these would be reports of disjoint writes, not a missing barrier. - Guest kernels push set 0 too, so a program's kernel in a concurrent compute encoder is not ruled out. That is what the names settle. Docs: HOWTO section 8 says what the names are. |
||
|
|
bf359931a6 |
Spares, FAST-PATHS: the dynamic-pool gap states what the guest's core measured
A scan of every ANV command buffer in the crashed guest's core found the 1 GiB dynamic state pool held in full (1023.7 MiB over 2985 command buffers). Nine held 92 to 112 MiB each: the crashing recording, and four earlier command buffers whose two passes (one vertex binding, then four) each replayed an indirect command buffer over the rate map, two to a pool. So a guest's command buffer of one draw per region holds 184 to 224 MiB, and about five alive at once fill the pool. The gap says so as today's measure, not as a bound, since a route that records fewer commands per region changes it. Verified: docs only; the scan is m3-max-22188 (core read in place, streamed). |
||
|
|
01207df533 |
Spares: a command buffer that recorded much frees its pools' command buffers as it gives them back
A rate-mapped pass records each draw once per region of its map, each with its own viewport and scissor. On ANV (Mesa 26.2.6, Iris Xe) every such draw takes about 100 bytes of a device-wide dynamic state pool of 1 GiB. A command buffer holds what its recording took until it is begun again, reset or freed, and spare pools kept their command buffers' recordings for later takers. A guest's ICB passes over a rate map, replayed by host steps at about 880k draws a step, filled the pool with four command buffers alive. The core showed the "dynamic pool" block pool at its 1 GiB maximum, one command buffer holding 97.5 MiB of it, and its batch status VK_ERROR_OUT_OF_DEVICE_MEMORY. ANV then wrote the next SF_CLIP_VIEWPORT through a null state inside vkCmdDrawIndexed, and QEMU took a SIGSEGV. A command buffer now counts the draws its recordings record (its host steps' included) with the state commands they set (CommandBuffer::recorded, counted at render.rs's draw loop). Where the count reaches spares::RECORDED (65,536), each pool it gives back sheds every command buffer it holds, freed on the device's free thread as an idle spare's are, and rejoins the spares stocked with a secondary. Below the bound nothing changes. The rerun check's pool passes its command buffer's count. A kept chunk's pool passes 0, since its draws count in the command buffer that recorded them. Counted: WorkCounts::spare_command_buffers_freed_past_recorded (api_signatures.tsv). FAST-PATHS records the gap that remains: command buffers alive at once that record enough to fill the pool by themselves. Tests: tests::spares::device::a_command_buffer_that_recorded_much_frees_its_pools_command_buffers (lavapipe). The opt-in Iris probe runtime_lane::rate_mapped_volume (m2v_gpu_hazards) prints the new count per round. |
||
|
|
99146ff67f |
In-place reads: the lane test and docs name the devices whose passes fetch no color
A pass on a device with rasterization-order color attachment access (lavapipe) or without the pixel interlock (the RX 550) fetches its colors as input attachments, and in place, like the snapshot, takes no such pass (its subpass would name the color in two layouts). The lane test asserts the read in place only where the device's passes fetch no color, and API.md, FAST-PATHS.md and render/snapshot.rs say which devices keep the copy. Verified: lavapipe lane job m3-max-22227 (msi) at e83d75fe83: 33 of 34 attachment-read, snapshot and in-place tests passed, debug and under METAL2VULKAN_LANE_VALIDATION=sync; the one failure was this expectation (lavapipe fetches through inputs: copies 1, in place 0). |
||
|
|
7284147b43 |
A draw that reads its own color at its own pixels and writes none of it reads in place
A draw whose fragment function reads, at its own pixels alone, a texture its own render pass instance renders as a color, and whose pipeline writes no channel of that color, now reads the attachment in place, with a memory barrier before it or without: no copy, snapshot or split. The color is in the feedback loop layout for its instance, the pipeline is made with VK_PIPELINE_CREATE_COLOR_ATTACHMENT_FEEDBACK_LOOP_BIT_EXT, and the slot binds the texture in that layout. A by-region barrier before the draw (color writes to fragment shader reads) orders the earlier draws' and the load's writes before its reads (Vulkan 8.10.5), and a by-region execution barrier after it (fragment shader to color output) orders its reads before later draws' writes. Its own writes go to other colors, so no fragment of the draw races another over the texels it reads. It reuses the snapshot route's checks (pass shape, view format, pins, one image) and its binding (render/snapshot.rs, in place), on a device that enabled attachmentFeedbackLoopLayout. Why: the real Macs disagree on such a read without a barrier (probe ownread.m: the M3 Max answers the texels from before the pass at every pixel; the 5300M answers the earlier draws' writes at 98.6% of pixels and at all after a barrier; the UHD 630 at all but 0.01%). Under the owner's rule for such disagreements we take the cheapest form, the x86 Macs' answer, recorded as an accepted difference in docs/API.md. A compositor's backdrop reads paid a copy of the whole target per draw before. texture/attached_reads.rs now gives a color's image feedback loop usage wherever the device enabled attachmentFeedbackLoopLayout, not only where it has the snapshot route's write-mask command. New WorkCounts::reading_draws_in_place (api_signatures.tsv row). The draw-key and graphics-key carry a feedback_loop bit for the pipeline flag. render.rs (the draw's snapshot plumbing) is touched at: the draw's snapshot request, the phase hole, the counts, the snapshot views, the pair base and phases, Recording::record (the barrier after), and settle_draw's snapshot checks. Lane test runtime_lane::in_place_reads with an owned fixture ipr_reads.metal (regenerated with scripts/regen-air-fixtures). The golden tables and the compile census are re-blessed on development. Verified: not yet compiled; potluck build, lint and lavapipe lane jobs follow. |
||
|
|
47ca9278c8 |
Pages beside live dma-buf imports import their own dma-bufs, not a copy
A no-copy buffer or heap (made or rebound) whose pages a live import of another holds some of was always a copy of them (CopiedBecause::OverImport), for VK_EXT_external_memory_host's undefined second import of a host pointer (its issue 6). On RADV every no-copy object's pages are udmabuf dma-bufs, which that clause does not cover, so since the one-import rule landed a consumer's 780M walk made 2715 such copies (copied_over_live_imports, 292 MB copied in). Now, where every live import that holds some of the pages is of dma-bufs, the pages come with a source of dma-bufs the device imports, and the device's barriers order blits through two imports of the same pages (no RuntimeDriverDefect::AliasedImportBlitsUnordered, which ANV and MoltenVK have), the object imports its own dma-bufs from the source, never its pointer (Device::imports_beside). Two dma-bufs of the same pages are two aliases of external memory (Vulkan 1.4, 12.11 Memory Aliasing: consistent for buffers, uses separated by a memory dependency); the tracker orders every use by the host bytes it touches across keys with global memory barriers, as for a guest RAM's run imported beside its chunk. A pointer import on either side keeps the copy. A failed import there falls back to the copy, announced with the failure. HostAliases::within now names the live imports that meet the pages (Within::Meets(Vec)). Counted: ObjectChurn::dma_buf_imports_beside_live (imports_inside_live stays the count of pages imported twice where that is undefined). Tests: tests::dma_buf_beside (device, Linux): a buffer over part of a live import's pages and a buffer rebound onto pages two live imports hold some of, as made and without pointer imports: beside dma-bufs where the first import is of dma-bufs, else a copy; the GPU reads the CPU's bytes, CPU writes between encode and commit reach the command, GPU writes reach the pages and the other buffer, and in imports a fill through one and a copy through the other in one encoder are ordered either way. The host_aliases unit test checks Meets names the import met. The validation lane's dma-buf joined-import test takes the third outcome. Checks: to run. |
||
|
|
3a619009b7 |
Run one-row threadgroups of a row-lockstep kernel on a variant without its simdgroup barriers
What: a kernel whose only simdgroup semantics are lockstep simdgroup barriers that order pairs meeting only where a simdgroup spans two rows (RowLockstep) kept them, their cross-lane class and, on a device with tangled 32-lane subgroups, its pinned subgroup size, even for a dispatch of one-row threadgroups, where no such pair meets. On the Iris Xe that pin makes ANV compile a register-heavy kernel at SIMD32, which spills and takes seconds where SIMD8 takes 0.3 s. - Address facts: a place among the threadgroup's linear threads (thread_index_in_threadgroup, and under rows thread_position_in_threadgroup's x, never the grid's) with its low five bits cleared (`& -32`) or shifted out (`>> k`, k >= 5) is one value per simdgroup (AddrFacts:: aligned, in fixed). The lattice walk skips such terms like uniform ones, and its spread now holds two facts, the finest lattice and the whole bounded difference, either clearing a pair. - Lockstep::rows holds where, under row facts, no conflicting pair wants more than a threadgroup barrier: threadgroup barriers stand where the whole threadgroup runs together, order every pair a simdgroup barrier would and need no subgroup size, so a one-row pipeline keeps them and drops only the simdgroup barriers (the argument is in Lockstep::rows' doc). - VariantKey::one_row / LoweringInputs::one_row: the lockstep pass inserts only the threadgroup barriers where rows holds; the kernel states RuntimeFact::OneRow (Mechanism::Variant). The binder asks a dispatch whose every region is one row of a RowLockstep kernel for it (dispatch_variant), the planned pipeline still runs such a dispatch, and the variant's plan sends a dispatch with a taller region back (NeedsVariant). The runtime settles on it through dispatch_variant and prepares it beside the base where a one-thread dispatch asks for it. Tests: engine_simd_emulated's a_one_row_dispatch_drops_the_lockstep_simdgroup_barriers on the Iris profile (a tile whose halves meet only across rows plus a workgroup-uniform pair): the own pipeline keeps its simdgroup and threadgroup lockstep barriers, CrossLane(BASIC), Direct and RowLockstep, and leaves the expected words at 144 x 2 (the shared lane's included); the one-row variant has one threadgroup lockstep barrier, no simdgroup one, (None, NoSubgroup), no subgroup requirement and OneRow, and leaves the expected words at 128 x 1 and 48 x 1 at 8, 16 and 32 lanes; the binder sends 128 and 48 to the variant and 144 x 2 to the base, whose plan refuses the variant 144 x 2; the kernel with a simdgroup sum keeps Direct and its own pipeline for 32, 128 and 144 x 2. a_row_of_a_lockstep_only_kernel_takes_one_compile now expects the one-row variant for one-row threadgroups of the row kernel, and the pinned pipeline for whole ones of the others. The mechanism table, the inputs-encoding test and api_signatures take the new items. |
||
|
|
b46459080d |
A batch held for its pipelines' making gives way to later commits of other queues
What: the scheduler's order across queues (scheduler/order.rs) no longer keeps the place of a batch held unsubmitted for a host step that has not taken its gate: its pipelines being made, or a step that reads nothing the GPU writes (`place_of`: `Place::GivesWay`). A later commit of another queue that conflicts with it on a resource goes first, and the held batch is submitted after it, so the tracker orders the two that way (submission order). The batches after it on its line give way with it. What still holds a head back behind such a batch is a fence the two share (`tracker::fenced`: one updates a fence the other waits for or updates, or a batch whose uses are not known yet against one that names a fence), so no batch is moved after a fence update it waits for. Unchanged: same-queue order, event and binary-semaphore waits (a batch waiting for the program still keeps no place), batches held for their submission checks or for a host step whose gate was taken (they keep their place: a later write going first would land after the step read), and the order among submitted batches. Why: on an Intel Iris Xe a guest process's cold compute pipeline took about 3 s to make; its command buffer kept its place, and the other processes' heads that conflicted with it (the window server's frames among them, over a surface they shared) waited behind it: the guest's display froze for 3.1 s. Metal's order across queues is the order the GPU takes the command buffers, not commit order: probes/cross_queue_surface_order.m's same-buffer control (one tracked buffer, written by queue A's long compute, then read or written by queue B's later commit) ran B before A once in three on a Radeon Pro 5300M and on a UHD 630 (macOS 26.7.1; m3-max-21850, m3-max-21851), and in commit order on an M3 Max (macOS 27.0.1). Where real Macs differ, the cheapest form inside them is taken; no switch, as matching the x86 Macs trades no accuracy. (The previous commit's message miscounted the no-copy buffer case: unordered in 10 of 12 runs, 6 of 6 on the M3, 3 of 3 on the 5300M, 1 of 3 on the 630.) Docs: order.rs's contract (**Tracked order across queues is the order the batches go**, **Held batches give way**, **No deadlock**), the scheduler's tracking and gate docs, WorkCounts::heads_held_for_earlier_commits, pending_dispatch.rs, docs/API.md's and the runtime README's pipeline-wait passages. Tests: tests::scheduler a_later_commit_goes_before_a_batch_held_for_its_making and a_batch_held_for_its_making_holds_back_a_commit_sharing_a_fence (the order's model; its existing a_later_commit_that_conflicts_waits_behind_a_batch_held_for_its_step is the kept-place control); tests::hold_sites a_head_that_shares_a_buffer_with_a_batch_held_for_its_making_goes_first (was ..._waits_behind_it: the fill completes while the dispatch is held, and the dispatch's words land over it), a_head_that_waits_for_a_fence_a_batch_held_for_its_making_updates_waits_behind_it (the fence control), and the host-alias leg, which passes again. |
||
|
|
aa2256b6e7 |
Order host-alias uses across queues again: Metal orders textures over one IOSurface across queues
Reverts a5634d48db and 3926d2d8c9, which left the uses the host aliases add out of the scheduler's order across queues on the strength of host_aliases.rs's line that Metal orders two textures over one IOSurface across queues only as the program orders them. The conformance probe probes/cross_queue_surface_order.m measured that case (queue A's long compute write committed before queue B's blit read of the same bytes, no event between them, three runs each): - two tracked textures over one IOSurface: B ran after A and read its writes in every run on an M3 Max (macOS 27.0.1, m3-max-21812, m3-max-21830), a Radeon Pro 5300M and a UHD 630 (macOS 26.7.1, m3-max-21850, m3-max-21851); untracked, the same but one run on the 5300M; - a texture of another surface (control): ran alongside A on the M3 and the 5300M; - two no-copy buffers over one allocation: B ran alongside A, reading stale or mixed words, on all three (8 of 9 runs; the 630 ran it one after the other twice); - one tracked buffer (control): ordered on the M3; the 5300M and the 630 each took B first once. So the alias keys' order across queues is the surfaces' order, which Metal keeps; dropping it was wrong for the consumer's surfaces, whose textures lie over per-texture no-copy buffers. host_aliases.rs now states those measurements, the plain no-copy buffers' among them, in place of the M4 line. The freeze the revert reopens (a held batch's making holding other queues' heads over a shared surface) is answered by the next commit, which lets a batch held for its making give way across queues, as the x86 Macs' GPUs may take a later commit first. Until that commit, tests::hold_sites::a_head_over_the_same_host_bytes_through_another_buffer_goes_while_a_batch_is_held fails as before a5634d48db (m3-max-21752). |
||
|
|
1b802ea45a |
Cross-queue commit order counts a conflict only on a resource both batches name
What: a use the device's host aliases add (host_aliases.rs: a no-copy buffer over the bytes of another, the consumer's textures of one IOSurface over their plane buffers) is now marked (`Use::aliased`). The scheduler's order across queues (`Footprint::conflicts`, behind `Order::is_behind`) leaves marked uses out, so a batch the runtime holds for a reason of its own (its pipelines' making, a host step, its checks) holds back no later commit of another queue that meets it only over shared host bytes. A use joined with one its command named stays named (join and merge keep `aliased` only where both are; `covers` lets no aliased use hold a named one), so two batches that name one resource still run in commit order, as Metal's tracking orders them. The tracker's barriers, inside a queue and on the GPU once both are submitted, take aliased uses as before. Why: on an Intel Iris Xe, one guest process's compute pipeline took about 3 s to make cold. Its command buffer kept its place in commit order (held for its making), and five other queues' heads in each scheduling pass, the window server's frame among them, conflicted with its footprint only through the alias keys over IOSurface pages they shared (heads_held_for_earlier_commits +5 per pass, footprints_built +2, the scheduler otherwise idle). The frame's present waits for its writers' completion, the guest's display pipe allows two unanswered presents, and the guest froze for 3.1 s. Metal orders two textures over one IOSurface across queues only as the program orders them (host_aliases.rs's measurement: an M4, macOS 27.0.1, plain and under API validation), so a later commit of another queue through another resource over those pages does not wait for an earlier one there; holding it was ours alone. docs/HOWTO.md's paragraph on copied and same-surface buffers says the same; the order.rs, scheduler gate and host_aliases.rs docs name the exception. Tests: tests::hold_sites::a_head_over_the_same_host_bytes_through_another_buffer_goes_while_a_batch_is_held (the previous commit) failed before this change on lavapipe (m3-max-21752: TimedOut, the fill waited behind the held dispatch) and is expected to pass after; tests::tracker gains a_use_the_host_aliases_added_orders_no_batch_across_queues (aliased-only overlaps unordered both ways, a named key on both sides ordered, a named use joined with an added one of the same range named); tests::host_aliases expects the added uses marked. |
||
|
|
a96e93f4da |
runtime_lane under sync validation: the layer's false positives become narrow claims, and the tests' own races are taken out
Under METAL2VULKAN_LANE_VALIDATION=sync on lavapipe the runtime lane failed 31 tests on the layer's hazard reports. At |
||
|
|
1d911cb848 |
FAST-PATHS: RADV refuses a dma-buf plane at offset 32 even at 256-byte rows
The probe on the Radeon 780M (m3-max-21640, Mesa 26.2.6): a dma-buf DRM_FORMAT_MOD_LINEAR plane at rows 256 bytes apart is made at offsets 0 and 256 and refused at offset 32 (VK_ERROR_INVALID_DRM_FORMAT_MODIFIER_PLANE_LAYOUT_EXT), and an image's memory offset must be a multiple of its own alignment (VUID-vkBindImageMemory-None-10735), so the gap row names the offset as well as the pitch. Verified: the cited device run. |