d166086d920987cfa62e7d6479b50ebf0a6dc069
28
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
d166086d92 |
RUNTIME 2270: an encoder's open looks at the encoders ended since the open before, not every earlier one
Every compute and render encoder's open built what it starts with (the shadowed textures its command buffer's ended encoders made resident) from scratch: the command buffer's joined residency, then each ended encoder not joined yet, one shadows_onto each. The joined residency advances only where the command buffer's own work reads it, so a command buffer of n compute encoders walked n(n-1)/2 ended encoders: at Geekbench Fluid's ~2300 one-dispatch encoders a command buffer, the open grew to ~2.9 us a dispatch on lavapipe (866 ns at 6 encoders), and reims's decodeperf profile (M3, MoltenVK) put inherited_residency and shadows_onto at 762 of open_compute's 874 samples. The command buffer now keeps what its next compute and its next render encoder start with, with the number of ended encoders it took in (State::inherits): an open takes in the encoders ended since, each once, in the order they ended, and hands out a copy (a count: the residency's resources are shared until one copy changes). It is let go of where the joined residency or an ended encoder's residency may change: joined_residency (every read that joins, the heaps' textures made since, the first submission, a re-encode) and a re-encode's splice of an encoder's residency. The result is the one the walk made: the joined residency's shadows first, then each ended encoder's onto them in order, usages and stages joined as before. Counted: WorkCounts::ended_residencies_looked_at (an ended encoder's residency looked at for an open's inherited shadows). Tests (tests::joined_residency): 64 encoders with a read of the residency after the 32nd look at 62 residencies (the walk: 992); a shadowed texture made resident for reading, then writing, reaches the next encoder with its usage widened. RUNTIME_VERSION 2270: an encoder open inherits residency incrementally (the same result). Also (compenc): dispatch_chain gains --host (each encoder call and the commit timed on the calling thread, commit_and_submit, per-thread CPU on Linux), --binds 4|tex (four buffers, or the Geekbench compute shape: 2 textures, a sampler, an output buffer and setBytes) and --pages (buffers over host pages). Verified (compenc, msi lavapipe): touched tests 165/165 (m3-max-28544) incl. tests::joined_residency: 64 encoders with a residency read after the 32nd look at 62 ended residencies; a shadowed texture made resident READ then WRITE reaches the next encoder as written. Negative control (drop the slots every open, m3-max-28547): 992 vs 62, fails. Release dispatch_chain --host --only encoders --dispatches 2300 --binds 4, ns a dispatch: open 2862 -> 573, encode 7332 -> 5004, thread CPU 7532 -> 5205 (jobs 28534/28545); ended_residencies_looked_at 1.00 a dispatch. SR-like (6 encoders a CB) unchanged (866 -> 913). Clippy x3 and rustdoc run after landing. Squashed from steelbrain/compenc d0d524b6de..84b304c5e3. |
||
|
|
dd286c7304 |
RUNTIME 2268: record consecutive compute encoders of a command buffer into one VkCommandBuffer
A command buffer of N one-dispatch compute encoders went to the queue as 2N - 1 command buffers (each encoder's primary and a kept barrier command buffer before it). A compute encoder now records on in the tail of the compute encoder before it where nothing needs a boundary: same dispatch type and logging, same batch (no event wait or signal, no host step), the earlier encoder one plain part (no segment, no fence update, nothing failing or faulting), no command predication, encoder trail off, protection options 0. The barrier between the two is recorded per command by the tracker's own rule between two encoders of a batch (encoder_fold::FoldOrder), joined with the encoder's own serial barrier into one vkCmdPipelineBarrier. The folded encoder's uses and fence waits join the group's first part's summary, so the batch's plan orders the group as a whole; its own part keeps its fence updates alone. A rebind encodes a group again whole or not at all; a failure that fails one encoder of a group fails the group (docs/API.md section 10, "A command buffer committed as failed"). Counted: WorkCounts::encoders_folded. FAST-PATHS: the ANV command-buffer row notes folded encoders begin none. Also: the dispatch_chain example (gbkern, dchain): a chain of dependent dispatches by how a command buffer holds them (encoders, serial, raw barrier, raw split), with each shape's first command buffer's counts. RUNTIME_VERSION 2268: compute encoders fold into one VkCommandBuffer. Verified (dchain, at d7e4a9ce51, the same diff before its rebase): - lavapipe (m2v_cpu_icd): 40 tests incl. 8 new tests::encoder_fold (dependent chain, independent encoders take no barrier, dispatch-type change, fence update ends a group, commit_failed inside/at a boundary, rebind re-encodes a group whole). - RTX 5080 (m2v_gpu, b5080): 190 touched-family tests; FOLD-CHAIN folded 23, begun 1, barriers 17, 0 wrong words. - 5080 dispatch_chain, encoders shape, GPU us a dispatch: 1000: 8.41 -> 2.92, 2300: 7.43 -> 2.92 (raw barrier 2.92); vkQueueSubmit per command buffer at 2300: 1007 -> 44.6 us; command buffers submitted 2N -> 2. Owed after landing: the negative control (fold barrier removed reads wrong words), clippy x3, rustdoc, the full lavapipe runtime suite at the rebased tip (m3-max-28507), the 780M and XTX before/after. Squashed from steelbrain/dchain f51ba34c37..2f2000cfbc. |
||
|
|
490db00052 |
Re-encode: the encoder's last part read from the back
Clippy's double_ended_iterator_last on 14854f2473's lint job. |
||
|
|
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. |
||
|
|
f10321aad5 |
A pass left for its draws' pipelines takes its encoding again once they are made
A render pass whose draw's VkPipeline was still being made as it was encoded records as a segment
of its encoder once the pipeline is made (render/pending.rs). A rate map's reset after that
making finished, before the command buffer's commit or after it while the command buffer waited,
encoded the pass again from its log, and the splice refused it: the segment in its place was
neither one whose pipelines are still being made nor work recorded on the GPU alone. The pass
then drew by the map it took and the reset announced rate-map-reset-unencoded, where Metal's GPU
draws by the map as reset. The rate-mapped multi-draw route made this common: its vertex variant
is made at a pass's first draw, so the reset lanes failed by timing
(a_reset_shows_in_a_pass_not_yet_submitted and a_reset_shows_in_every_pass_not_yet_submitted on
lavapipe, jobs m3-max-22179 and m3-max-22244).
The splice now also takes the place of a render pass left for its draws' or tile dispatches'
pipelines alone and executing no render commands (Deferred::left_for_pipelines,
DeferredPass::left_for_pipelines), made since or not: the encoding again recorded those draws
where it found their pipelines made, or left a segment of its own where they were still being
made, and what the first recording took stays retained, as for a segment still being made.
Verified, before the fix: a diagnostic on lavapipe (job m3-max-22327) waited a second after the
draw and refused the splice in both cases ("keeps false gpu_alone false ... making false"),
shading the identity's 64 by 64 pixels with the notice; without the wait the pipeline was still
being made and the splice took it. The new lane
a_reset_shows_in_a_pass_whose_pipeline_was_made_after_its_draw waits for the making
(WorkCounts::variant_pipelines_made) and checks the half map's 33 by 33 pixels and no notice.
|
||
|
|
5d2c21b79b |
Runtime: keep the encoding-again take mode; a rebind's segments decide no takes
The before-runs of the GPU-pass rebind leg passed on the pre-fix code (lavapipe, m3-max-16674 with the draw before the execution, m3-max-16689 with it after): the draw read the bytes. A render pass recorded in a segment has its shadowed textures' copies planned by its encoder's own core as the pass ends (render.rs end_pass, shadows::plan), the take among them, and the segment only records them. GPU-alone compute executions (gpu_execute) plan no shadows. The segment cores that plan their own (indirect dispatches, executions recorded from records) are host steps' recordings, which a rebind does not record again. So no segment a rebind records again decides a take, and the encoding again's main core already keeps them (ShadowSync::again). So this puts back shadow.rs's two modes, State::replaying_takes and step_takes, and reencode.rs and encoder.rs as development has them. The shared pool, the give-backs at a splice and Replayed::takes are gone. Kept: the failed-submission give-back (State::give_back_from, never_runs_from, place joining a segment's takes into its encoder's), its docs, the loop gap in FAST-PATHS, and the GPU-pass leg as a regression test, its doc now saying where the take is decided. |
||
|
|
4289823b20 |
Runtime: work recorded again keeps its tiled takes; a batch that fails at its submission gives them back
A tiled texture's copy taken at use is taken by the first use encoded after its mark; a recording that never runs must hand its take on or give it back. Three paths lost it: - A rebind that encodes an encoder again re-recorded the encoder's segments (a render pass recorded on the GPU alone, its shadowed textures' copies in the segment) into cores that asked the mark, which the first recording had cleared: the pass read a copy nothing made. The same held for work on the GPU alone a rebind records again without encoding its encoder again. - A host step whose recording failed, and a vkQueueSubmit that failed, failed the command buffer outside fail_part: the takes of the batch and the later ones were never given back, so the next use read stale levels. How: - shadow.rs: one way to decide. ShadowSync::again (take nothing unmet, note nothing) is gone; every recording in place of others is ShadowSync::over a shared Replaced pool: a use that meets a decision of the replaced recordings keeps its take, any other asks the mark. The cores recorded during one turn share the pool, so each decision is met once, in order. - State::replaced_takes (was step_takes and replaying_takes) holds the pool while a host step, a rebind's encoding again (the first encoding's takes and its segments' recordings' takes, State::takes_of) or a rebind's recording again on the GPU alone records. segment_raw hands it to every core. A spliced encoding again or segment gives back the takes of the first recordings it did not meet (Takes::give_back_unheld); a refused one gives back its own takes the first did not hold. The encoder's record keeps the encoding again's takes. - State::place joins a placed segment's takes into its encoder's record, and CommandBufferShared::never_runs_from (State::give_back_from) gives back the takes of every part from the failed batch on, called beside each of the scheduler's three failed() calls. - docs/FAST-PATHS.md, known gaps: a predicated loop's run again records its work apart as a new recording that asks the mark, so a did_modify_data during the loop is taken mid-loop and the next use after it takes nothing. Keeping the first run's takes (over) would copy in again at every run, so it stays a recorded gap. - docs/API.md and the shadow.rs and reencode.rs module docs say the above. Verified: see the next report (lavapipe before/after, the 780M, lint). |
||
|
|
eddd9112aa |
Runtime: an encoder encoded again takes a tiled texture's copy where its first encoding took it
A tiled texture of more than one level over a buffer is a copy of the bytes taken at use: the first use encoded after its making, a did_modify_data or a level-0 replace_region clears the texture's mark and records the copy in and the later levels. A rebind of a no-copy buffer (or heap) the encoder also named, before its command buffer's first submission, encodes the encoder again and puts that recording in place of the first, which is never submitted. The encoding again found the mark already cleared, recorded no copy, and the texture's levels kept zeros or an older copy for good; a did_modify_data made after the commit was cleared by the encoding again instead of the next use. The decision now belongs to the encoding. ShadowSync notes, in order, what each first use of a copy taken at use decided (shadow::Takes); the ended encoder's record keeps that with its log, and the core an encoding again records into (EncoderCore::replaying, fed by reencode.rs through State::replaying_takes) takes each copy where the use in its place took it, never touching the mark. Its forget gives nothing back to the mark either. Other per-encoding state checked for the same shape: the shadow carry (an encoding again starts with none and copies the truth in, which earlier encoders copied back to as they ended; drops-writes shadows are never carried), gated copy-ins and standings (decided at batch submission, which sees the recording put in place), heap tiled and multisample sample moves (planned per recording, no mark), and segments recorded again on the GPU alone or at a host step (their shadow copies were planned by the encoder, not decided again). None consumes a mark at encoding. Verified at the parent (66b00df138), lavapipe, jobs m3-max-16324/16333: all four tiled_texture_reencode tests fail (levels read zero through the encoding again; the next use after a did_modify_data took nothing). The new CPU unit test in tests/shadow.rs covers the decisions directly. Runs of this commit follow in the report. |
||
|
|
1c14b4b44a |
Staged gathers take their staging at their host step, not on the calling thread
A gather staged through the CPU (
|
||
|
|
48caeeb155 |
DegradeNotice::command_buffer: the command buffer whose work announced a notice
A consumer that makes some notices fatal (reims-vgpu's ReleasedCommandState, PrivateResourceOption, HostDeallocatorDelayed) could not tell which command buffer a notice was about: a ReleasedCommandState announced at a host step on the scheduler's steps thread ended its whole VM. Now every notice carries the ID of the command buffer whose work the runtime was doing on the announcing thread, so the consumer can fail that one command buffer. What changed: - CommandBuffer::object_id: an ObjectId, minted at the command buffer's making from the process-wide count buffers, textures and heaps use. - DegradeNotice::command_buffer: Option<ObjectId>, read at the notice's making from a thread-local scope (degradation::NoticesFor), as `call` reads the call being lowered. The scope is set where the runtime holds the command buffer and does its work: the compute and blit encoders' logged funnels and their other recording calls and ends, the render lowering's at-call funnel, its unit calls, its batches' lowering (on the lowering thread or a drain) and its end, the resource state encoder's calls, encoder openings, the commit (at the call or queued behind a render end), a batch's submission and the storage-form settle that rides on it, host steps, a rebind's encoding again, and GPU-time reads. Nested scopes name the innermost. - None, explicitly, for a recovery of the device (device-recovered), for grouped-completion (several command buffers' batches), and inside the program's code the runtime calls (exit_guard::program, indirect command checks, executed-commands handlers). - A bind's memoized notices, announced again at each later bind under announce_each, are named as that bind's: its command buffer and the call being lowered (the call was the first bind's before; same mechanism). - ObjectId docs, docs/API.md section 9, docs/RUNTIME-PORTING.md; API signatures re-blessed (two records: the field and the method). Tests (runtime crate, device tests): - notice_command_buffers: an ICB execution recorded at a host step announces released-command-state on the steps thread naming the executing command buffer; its commit's host-replayed-indirect-commands, on the program's thread, names it too; private-resource-option of an ICB made between the encoder's calls names none. - deferred_calls: the call-naming test also checks the command buffer under both lowering policies; a new test waits for the lowering thread to announce unsized-points after end_encoding and checks the thread, call and command buffer, and that a device notice between the encoder's calls names none. - vertex_conversion_notices: a memoized bind notice (device-nan-encoding) announced at a second command buffer's draw names that command buffer and its own call index, with bound_notices_made proving the memo was reused. (cherry picked from commit b4c2ba83ea726229f129a405ce6f432b0bdb0127) |
||
|
|
4368a35894 |
Let a linear run's passes name buffers over host pages; a pass a rebind encodes again alone reloads its run
A pass over a linear attachment rendered apart joined no run where its commands named a buffer
over host pages (render.rs's once rule): a rebind of one encodes the pass again alone, and a
linear run had no keep after such a pass. A consumer's setVertexBytes lands in an upload chunk in
its guest RAM, a no-copy buffer over host pages, so every pass of reims's many_passes merged
alone: 706 passes, 706 merges, 705 scratch reuses (11-05).
Measured at development
|
||
|
|
241ee2c0d1 |
Keep and merge a run of passes over one shadowed texture once, not once a pass
What: a render pass whose color is a shadowed texture merged back (its truth a buffer's bytes
another writer may write, such as a no-copy buffer's host pages or a Shared buffer's), loaded and
stored, now joins a run of passes (pass_runs.rs) where it may. The run's first pass copies in (or
takes the carried image) and keeps, as before. Each later pass goes on over the image the pass
before it left (ShadowSync::go_on) and keeps nothing. Each pass leaves its merge to its batch's
submission (Deferred::RunMerge, RunWork::Shadow), and the run's next pass takes it over, so the
merge recorded is the last pass's, compared against the first keep. The run holds the keep's
scratch or kept image (RunHeld::Shadow, its MergeLease) until it ends or the command buffer
commits.
Why: consecutive render passes over one merged-back shadowed texture each copied in, kept and
merged the whole texture. 700 one-rectangle passes over a 1024x1024 BGRA8Unorm texture over host
pages took 1,401 shadow copies and 700 merges.
The rule, structural, with no names: a run ends wherever something other than its own passes
could observe or change the bytes, as in the linear runs' list:
- any encoder between its passes that is not a render encoder;
- a render encoder that names the bytes' buffer or its host range, reaches memory it does not
name, fences, resolves, writes visibility results, records later or renders over a rate map;
- a render encoder with an attachment over those bytes, or whose draws or attachments take a
shadowed texture over them (the run's own texture bound to a draw included);
- a signal, a wait or a host step (a new batch), and the command buffer's end;
- for a shadow, the encoder no longer carrying the image (the carry dropped).
A shadowed color joins only when it is loaded and stored, has no stand-in and no planes, belongs
to a pass of one render pass instance that is not inline and not inside a predicated laying, is
laid out as one image's texels at level 0 and slice 0, and merges back.
Encoded again: unlike a linear attachment's run, a shadowed texture's run may hold passes over
host pages, which a rebind before the first submission encodes again. Such a pass leaves its run
(RunMerge::leave). The merge it took over records after all (given back), and the pass copies in,
keeps and merges for itself. Where a later pass took its merge over, it keeps the run's scratch
again after its own merge (RunMerge::keep_after), so that later pass's run merges what the passes
after it change. Run segments now record again (Segment::records_again) and splice. An encoder
encoded again takes no pooled scratch or kept image (ShadowMerge::new's `lent`). A run's merge is
resolved at its calls (Deferred::resolved_at_its_calls), so it holds no host pages past commit;
before this, a rebind of such a run was refused with Rebind(EncodedUses).
Two more changes. A run's keep that a later pass writes outside merges and keeps every texel next,
and a run's pass that needs texels the copy-in did not hold copies every texel in. A merge in whole
blocks stays in blocks where the keep holds the pass's area (stores_blocks), under the same
read-to-store window that shadow.rs's Stored attachments already state.
Counted with the existing counters: shadow_copies, shadow_texels_kept and
shadow_merge_dispatches_planned fall from one per pass to one per run. docs/FAST-PATHS.md records
the run and its costs.
Verified on the M3 Max (MoltenVK 1.4.2), --cfg m2v_gpu, under maclock and memcap:
- tests::shadow_runs (new, all pass):
- runs_over_host_pages_keep_and_merge_once: 1024x1024 BGRA8Unorm over host pages, rows of 15360
bytes, with blits, foreign render encoders, reads, CPU byte writes, a signal and an aliasing
view between runs. Mid-sequence and final reads match a private texture byte for byte, and
the padding is untouched. Joined: 22 copies, 9 merges. Apart: 112 copies, 54 merges.
- rebound_passes_leave_their_runs: 3 encoders encoded again, 0 refused, bytes equal.
- scissored_runs_keep_again_once_and_merge_in_blocks: keeps at passes [0, 1], all in blocks.
- Runtime suites (shadow, merge_scratch, linear_runs): 69 of 69 passed.
- Validation runtime_lane (shadow, padded, linear): 91 of 91 passed.
- Negative controls, each a sabotaged build, source restored and touched after; each fails:
- go_on off: every pass keeps;
- follows across encoders: keeps [D0, D8, D9, D10, A11, D12];
- leave off: 961,469 bytes differ;
- stores_blocks reverted: every scissored pass keeps.
- Release probe, 700 passes in one command buffer, base a543f6428d against this commit: shadow
copies 3 against 1,401, texels kept 1,048,576 against 734,003,200, merges planned 1 against 700.
Commit to completion, runs 1-3: 31.6-35.3 ms against 69.3-99.9 ms. With a 1x1 render encoder
between every two: 61.6-65.0 ms against 107.4-118.6 ms.
On the RTX 5080 Laptop GPU (NVIDIA 615.71.09), the same probe, runs 1-3: 6.6-10.0 ms against
40.6-43.0 ms, and 9.7-12.3 ms against 44.5-47.1 ms. The same 11 shadow, merge and linear device
tests passed there.
clippy --all-targets --all-features -D warnings passed plain and with --cfg m2v_gpu, and cargo fmt
was run.
(cherry picked from commit bf783428131f46c7289518a50b8505e809ecc8e5)
(cherry picked from commit 99949a4cd08cd042e448484e0b1d2f5da1898db5)
|
||
|
|
2f9a3a3782 |
A command buffer joins its ended encoders' resources where its work reads them, not as each ends
Each compute or render encoder's end joined everything it made resident into its command buffer's
residency (Residency::join_encoder: a clone and a hash insert per resource), and each later
encoder's open walked every texture of that union for the shadowed ones. Most command buffers'
work never reads the union: only the commit's and host steps' recordings against every encoder's
resources (CommandBuffer::residency), the resident set of a GPU-alone recording, a texture made in
a heap since, and an encoder encoded again do.
- command_buffer/mod.rs: an encoder's end joins its heaps at once (join_encoder_heaps) and leaves
its resources in its record; State::joined_residency joins the records not joined yet, in the
order they ended, at the first read (CommandBuffer::residency, make_resident, fresh_ranges, a
splice of an encoder encoded again, before the textures its heaps made since). The union holds
what the eager join made, in the same token order: State::sync_heaps joins the records first
where a heap made textures, as each encoder's join came before them. The commit's sync of its
heaps and an encoder's open (State::inherited) read no resource list unless one did.
- residency.rs: each residency lists its shadowed textures' tokens (shadowed), found where an
open first asks for them (find_shadowed) and each texture looked at once, so making a texture
resident reads nothing of it, and an open starts with the shadowed textures of the joined union
and of the records not joined yet, in the order they were made resident, with the joined usage
and stages, at the cost of their count. The join's resource and heap halves and sync_heaps's
finding and joining halves are split out.
- WorkCounts::resident_resources_joined counts the joins (api_signatures.tsv blessed: one field).
The records hold what their encoders made resident until the command buffer completes, as before,
and the union goes with them, so nothing lives longer or shorter. The same resources, usages,
stages, tokens, shadows and heaps at every read.
Release numbers, M3 Max (host_ab --only encode, runtime side, median of 3 rounds, µs; before is
this landing without this commit, after with it, two or three interleaved runs each):
before (3 runs) after (3 runs)
resident_0 end_call 14.1 11.6 14.9 11.3 14.4 15.1
resident_256 end_call 34.7 25.6 37.3 11.1 13.3 15.4
resident_4096 end_call 230.3 152.3 244.3 11.4 14.1 15.5
resident_moving_4096 end_call 170.5 154.3 248.6 10.7 11.8 15.2
resident_textures_256 end_call 41.5 29.5 43.1 11.2 13.0 15.3
resident_textures_4096 end_call 287.8 193.5 294.6 11.5 12.9 15.8
resident_4096 use_call 346.1 379.3 335.1 326.1 297.3 342.0
resident_textures_256 use_call 38.0 37.0 36.9 35.1 35.1 37.2
resident_textures_4096 use_call 450.3 481.0 430.3 409.5 419.6 438.3
resident_4096 encode/dispatch 1.73 1.32 1.62 1.74 1.65 1.65
resident_textures_4096 encode 2.20 1.78 1.93 1.93 1.99 1.97
static encode/dispatch 1.75 1.74 1.61 1.62 1.64 1.60
The end call no longer grows with what the encoder made resident, and the useResources call does
not take the cost instead. A first form of this change looked for a texture's shadow as it was
made resident; that put about 80 µs into resident_textures_4096's use_call (260 to 317 against
188 to 200 before, four interleaved runs each), which is why the shadowed textures are found
where an open first asks for them. Percall's counts are the same with and without this commit;
the calls workload's end_compute allocates 5 a call where it allocated 8.5.
Checks that fail without it, in tests/joined_residency.rs:
- ended_encoders_join_their_command_buffer_s_residency_where_it_is_read: with the second
encoder's open joining the records (the eager join's timing), its first assert fails (16 joined
where 0).
- shadowed_textures_made_resident_reach_the_next_encoders_in_order: with find_shadowed looking
at none, its first assert fails (no shadowed texture inherited).
Verified: the runtime GPU suite on the M3 (1527 passed, 3 skipped); cargo clippy -p metal2vulkan
-p metal2vulkan-runtime --all-targets --all-features -D warnings, with and without --cfg m2v_gpu;
scripts/api-signatures/signatures.py --check.
(cherry picked from commit 18553c295c98dabe4c74fc226be6b45955c0c13a)
(cherry picked from commit ae56cfdfdd2e4cb1e9b189c7ce303d680fbc2b7f)
|
||
|
|
44d97aaa5e |
Record each command into the driver's command buffer at the call
Recording at the call replaces the deferred replay, with the pipeline-wait test settling the
device's in-place check that recording at the call made fall inside its run.
One work packet, landed as 2 commits on archive/development-linear-2026-10-29, in order:
* Record each command into the driver's command buffer at the call (6c9d1f4551)
An encoder's command buffers are the driver's VkCommandBuffers from the command
buffer's pool, recorded at each call on the program's thread. The deferral is
gone: the per-command log, the deferred handles, the replays and the recorder
thread, the scheduler's wake of it, the host pages' replay holds, and
WorkCounts::{command_buffers_deferred, command_buffers_replayed,
command_buffers_replayed_inline} (removed public fields; none is read by the
consumer). The slots' routed entry points stay as a counting door:
WorkCounts::commands_replayed counts each command at the call, across every
command buffer (the scheduler's barrier buffers and primaries begun ahead
included, so its totals rise: the drag frame's 1000 -> 1094). A shadow's copy in
over dirty-logged host pages becomes a segment its batch's submission records
(Deferred::GatedCopyIn), so its regions are still decided after the commit's
dirty-log stamp. Rebind re-encode (replay.rs, reencode.rs) is unchanged.
RUNTIME_VERSION 1692.
Verified on the Apple M3 Max (MoltenVK): runtime device suite 1392/1393 twice
(pipeline_wait_order's "a batch waiting for a pipeline holds only the batches
that share its resources" fails under suite load only, a known load flake that
now fails more often; 3/3 alone; the base passed 1395/1395 under the same
load); new recorded_at_the_call::a_fill_is_recorded_at_its_call; the three
dirty_pages_device tests through the gated segment; plain runtime 1145/1145;
conformance plain 1007/1007 (its racy-count test now reads wakes_spared and
command_buffers_submitted); clippy plain and --cfg m2v_gpu; rustdoc.
Release A/B on the M3 (5 interleaved pairs, host load 16-43): drag frame
commit-to-handler p50 3.416 -> 3.386 ms back to back, 4.185 -> 3.671 ms paced
at 60 Hz; encode per draw +7.9% back to back, +15.7% paced (the recording moved
onto the program's thread). Not run: the validation plain suite, the
validation lanes edited, lavapipe; conformance's MoltenVK cost records hold
begin/end/barrier bounds from the narrower count and need re-recording.
* Settle the device's in-place check before the pipeline-wait test frees its no-copy buffer (40c79d69e6)
The test's texture over a no-copy buffer starts the device's check of images
over host pages, whose rounds make internal submissions on the
m2v-in-place-check thread. On MoltenVK freed memory waits for every device-own
submission issued before it went (freed_memory.rs), so a check submission in
flight as the test drops the buffer delays its deallocator
(host_deallocators_delayed 1). That wait is the runtime's documented behaviour;
the unrelated batch holds no reference to the buffer (a temporary backtrace on
the device's internal submissions showed every one from the check thread, none
from barrier buffers, primaries begun ahead or gated copy segments). The test
assumed no other device work was in flight, and recording at the call made the
test about 2.5x faster, so the release fell inside the check's run. The test
now calls settle_in_place_checks (a condition-variable wait, no sleep) before
its work.
Verified on the Apple M3 Max (MoltenVK): with three heavy device tests beside
it, 10/10 pass (5/10 without the settle, each "the deallocator waited for the
import"); alone 5/5; the runtime device suite 1393/1393. Also run there, all
passing: the validation lane device tests record at the call edited
(commands_replayed, detach, hidden_depth, clear_reach, rate_mapped_passes,
frame_costs, and the row_copies/frame_costs_plain measurements).
|
||
|
|
a730cf1e96 |
Stop a rebind's re-encoded tile dispatch making or waiting for its pipeline
The steps this packet landed as, in order: - Let a rebind of a pending tile pass's buffer run, and place the pass it leaves - Say in the rebind rule that a pipeline being made does not hold a rebind off - Re-pin the runtime sources at the landing tip Content: the tree of `development` at 7da33c898d, unchanged. |
||
|
|
06be826c2f |
Leave a rebind's re-encoded dispatch its segment instead of waiting for a compile
The steps this packet landed as, in order: - Re-pin the runtime sources at the landing tip Content: the tree of `development` at f1bb798795, unchanged. |
||
|
|
089cc0a9e0 |
Encode a unit of predication's encoders again where each encodes again exactly
The steps this packet landed as, in order: - Bump RUNTIME_VERSION to 1580 and hold `Unit::fresh` to its invariant - Prove the kept refusal from an ungated dispatch, clear of an unrelated defect Content: the tree of `development` at a6ffe90b3e, unchanged. |
||
|
|
8294000cbf |
Encode a predicated compute encoder again at a rebind where it was its unit alone
The steps this packet landed as, in order: - Regenerate docs/REFUSALS.md over the twelfth stack - Pin the runtime sources and bless the golden table over the twelfth stack Content: the tree of `development` at 6ca8b9005a, unchanged. |
||
|
|
87eb8bc3b7 |
Reset and mutable rasterization-rate maps, as Metal's GPU reads them
The steps this packet landed as, in order: - Read a YCbCr texture's 2D-array view as Metal's, and drop packed 4:4:4 writes - Name bfloat attachments in the unreached-tiles notice - Let go of each predicated loop run's sets and uploads once the run completed - Check that a lent descriptor arena takes every set and reuses its reset pools - Bump the semantics, artifact format and runtime versions for the eighth stack - Pin the runtime sources of the eighth stack - Bless the golden hash tables over the eighth stack Content: the tree of `development` at ee0b90d176, unchanged. |
||
|
|
a653c11b49 |
Match Metal's detach timing: per submission, until the handlers ran
Content: the tree of `development` at 281583adb4, unchanged. |
||
|
|
b94953dfa9 |
Resolve GPU-alone work's resident set at the first submission, not by recording it again
Content: the tree of `development` at 3f5472f696, unchanged. |
||
|
|
d218c939a4 |
Encode again at a rebind an encoder whose only host-page use is its end copy back, and its GPU-alone work
Content: the tree of `development` at 3c7d40aea2, unchanged. |
||
|
|
8c96577b40 |
Record GPU-alone work again at a rebind before the first submission
Content: the tree of `development` at adea9e457c, unchanged. |
||
|
|
c9b0d74912 |
Record Vulkan commands off the encoding thread through deferred command buffers the recorder replays
Encoders log their commands into deferred command buffers, and the device's recorder thread replays them into Vulkan once the command buffer is committed, so the encoding thread no longer calls the driver for each command. Every recorded command goes through a slot of its device's; the recorder's queue and the scheduler's inbox are sized for a frame's commits and grow ahead of them on the recorder's thread; a commit's end allocates nothing; a render pass instance's secondary that nothing executes is never replayed. The replays' commands are counted by kind, and the recorder's modules are listed among those that may keep the device's functions. Folds in: - Route every command the runtime records through a slot of its device's - List recorder/mod.rs among the modules that keep the device's functions - List recorder/thunks.rs among the modules that keep the device's functions - Record Vulkan commands off the encoding thread: encoders log into deferred command buffers, the device's recorder thread replays them once committed - Grow the recorder's queue ahead of the commits, on the recorder's thread - Give the scheduler's inbox and the recorder's queue room for a frame's commits from their making - Count the commands the recorder's replays call, by kind - Give a commit's tail log its fold's room when its encoder ends - Never replay a render pass instance's secondary that nothing will execute - Give new replays room to end each deferred command buffer as it is made, so a commit's end allocates nothing Verified by each folded change's own checks; the tree this series ends on is the one verified at the tip on six GPUs, the CPU suites and lint (see the tables commit). |
||
|
|
3bb4722d9f |
Release idle pointer imports where they follow their address, keep deallocator timing Metal's across rebinds and detaches, and cut host-import work
No-copy buffers and host imports now cost the kernel and the encoding thread less, and their deallocators run in the call Metal runs them in, including when a detach races a commit. What changes: - Idle pointer imports. A no-copy buffer's own pointer import is releasable, as its dma-buf import was: while only blits read it and no pending command buffer holds it, the residency thread releases it after its idle window (2 s, doubling at each import again up to 64 s), and the next blit imports it again at the same pointer. Only where the new measured fact DriverFact::PointerImportsFollowTheirAddress holds (ANV 26.2.4 on the Iris Xe; lavapipe 26.0.8 to 26.2.4): there a pointer import reads the pages mapped at its address at each submission, so an import again reads what the kept one would. A refused re-import fails the blit's call, typed. - Deallocator timing. A released import hands its keep-alive and deallocators to the objects a command buffer still holds, so they run as that memory is freed (or parked and announced, as a kept import's). A committed but unsubmitted command buffer holds a blit's import objects weakly, so a rebind or detach before its first submission runs the deallocator in its call, as Metal does. A detach racing a commit on another thread runs the deallocator in one of the two calls: a let-go mark on the pages and the commit's hold count, both sequentially consistent, make each side see the other, and a commit that sees the mark replays its own command buffer at once. The live list re-reads a buffer's pages where a detach moved them meanwhile. HostDeallocatorDelayed is no longer announced for these races. - Fewer kernel queries. A no-copy buffer asks the kernel about its mappings (PROCMAP_QUERY) only where it makes its own import; a rebind onto a live buffer's bytes lies in that buffer's import and asks nothing; /proc/self/maps stays open for the queries (reopened in a forked process). Three blit paths that read the caller's buffer as a read apart now read it as blits, so their imports stay releasable. - Fewer rewrites and lookups. A rebind or detach rewrites only the heap slots of textures over the bytes it moved; host-page alias lookups visit only the length classes that hold ranges and keep each range's overlapping ranges; a binding and a descriptor each read where a no-copy buffer lies once. - Counters (WorkCounts): host_imports_used and host_imports_read_apart (with its six reasons), host_imports_kept_for_fds and kept imports by cause (of_heap, rebound, pointer, no_stand_in), heap_slots_rewritten, host_mappings_queried (Linux; 0 elsewhere), host_range_lookups, host_remaps_reported, host_remaps_over_imports, host_imports_remapped, host_pointer_imports_made and _bytes_made, no_copy_lies_read, host_imports_rebound_unlisted, host_rebind_imports_made and _covered. - Docs: docs/HOWTO.md on both kinds of release, the RLIMIT_NOFILE soft limit a program raises itself and the new gauges; a FAST-PATHS known gap that a buffer made before a remap reads the new pages on drivers whose pointer imports follow their address, where Metal keeps the old ones (HostMemory::new's contract forbids such a remap); the rustdoc of host_range_remapped. Why: ANV over i915 lists every VkDeviceMemory in every execbuffer, and a pointer import costs about 0.19 us an execbuffer; the consumer's guest keeps hundreds of no-copy buffers live and uses few in a frame. Its swap thread spent 1.54 ms of kernel time a frame querying mappings of a buffer that joined a live import. And a released import's deallocator unmapped pages under a live userptr, losing the device. Verified: - Iris Xe, a guest-shaped lane of 520 pointer imports and 43 command buffers a frame, the idle ones released: objects per execbuffer 536 -> 51, ioctl 4.24-4.31 -> 0.85-1.09 ms a frame, scheduler CPU 4.96-5.05 -> 1.33-1.74 ms a frame, frame p50 5.27-5.43 -> 2.70-3.11 ms. - The fact, probed outside the runtime on the Iris Xe and through tests::pointer_residency on it and lavapipe: a kept import read the pages a remap put at its address. - The detach race on the Iris Xe and RTX 5080 under the validation layer: without the fix 3 of 3 runs failed (deallocators late or on another thread); with it 12 of 12 runs, 15,360 races, each deallocator in the detach or the commit, never late. - A second no-copy buffer over 2040 scattered mappings: 415-418 us -> 0.3-0.6 us. A rebind with 1024 other live textures: 4766 -> 49 us. Alias lookups: a draw -5.3% instructions on host-page frames (RX 7900 XTX). - Device and unit tests: freed_memory, pointer_residency, host_residency, blit_holds, encoder_holds, host_import_counts, host_aliases (up to 45 passed per run); lanes rebinds, rebind_reach, detach, detach_textures, host_memory, no_copy_heaps, dma_buf_imports, draw_work (74 passed on lavapipe, 30 on the Iris Xe for the deallocator fixes). clippy -D warnings (plain, m2v_gpu, m2v_cpu_icd) and rustdoc. |
||
|
|
2423b8de61 |
Keep the Iris Xe's depth fast: DontCare stores, sampled usage for hierarchical depth, multisampled depth held out of GENERAL
Three measured cost facts for ANV (Mesa 26.2.4) on the Iris Xe of RPL-P (0xa7a0), each a pure fast
path that keeps every texel and the order of every use: no policy switch, notice or ledger row.
What changes:
- DriverFact::DontCareStoreIsOneOfMetals gains a row for this GPU: an attachment a pass stores
DontCare is Vulkan's DONT_CARE there, as on the UHD 770 and the Radeon 780M.
- New DriverFact::SampledDepthKeepsHiZ. ANV turns off a single-sample depth image's hierarchical
depth and compression in GENERAL (the layout every runtime image rests in) for an image of
transfer-source usage, but keeps its write-through form on for one of sampled usage. Where the
fact holds, a single-sample depth attachment plan the device samples takes SAMPLED too
(image_plan::hiz_candidate), heap textures and the runtime's own depth images included; the heap
size answer comes from the same plan. Memory size and alignment are equal with and without it.
- New DriverFact::MultisampledDepthFasterOutOfGeneral. A multisampled depth image renders very
slowly in GENERAL on this GPU, since the write-through hierarchical depth is single-sample only.
Where the fact holds:
- each render pass instance holds a multisampled depth attachment in
DEPTH_STENCIL_ATTACHMENT_OPTIMAL, moved from GENERAL by a barrier before it and back after
it (the feedback-loop mechanism, generalized to moved images; WorkCounts
depth_attachments_moved);
- the device's own Private multisampled depth texture stays in the attachment layout between
encoders that only render it (texture/held_depth.rs). The scheduler moves it at encoder
boundaries, before any encoder that uses it otherwise, as a tracked write of the whole image so
the hazard tracker orders it against every use on every queue. A pass holds only when nothing
else in its encoder touches the image; a later use breaking a hold fails the encoder's end
with a visible internal error. WorkCounts depth_instances_held and held_depths_released.
- An instance an execution of render commands joins, inline instances and the resolve-after
instance stay in GENERAL. Layout transitions preserve contents unless the old layout is
UNDEFINED (Vulkan, Synchronization, Image Layout Transitions).
- New measurement runtime_lane::depth_costs (ignored by default).
Why: in GENERAL these depth attachments lose the hierarchical depth test, so the depth test
rejects no fragment a block at a time; and moving back to GENERAL after every pass costs a full
hierarchical-depth resolve, about 1.95 ms a pass at 1080p with 4 samples.
Verified, release, on the Iris Xe:
- runtime_lane::dont_care_stores: every texel of its twelve kept cases was the earlier or the
stored one, none other.
- A 1080p heap Depth32Float at 32 layers: 4.72-5.66 -> 0.82-0.87 ms with sampled usage. A 4x
Depth32Float at 32 layers: 12.14 -> 1.44-1.52 ms moved per instance; held between encoders, 1
layer 2.56 -> 0.62 ms and 32 layers 4.35 -> 2.38 ms (GPU clock fixed at 300 MHz). Batches that do
not name the depth showed no CPU difference above noise.
- runtime_lane::msaa_depth_moves 9 of 9 under the validation layer with the counters checked (a
blit between passes, a resolve in its pass, frames, reads after each pass, two queues ordered by
an event, a split pass, an argument-buffer read with useResource, an encoder that also binds its
depth, an indirect-command-buffer execution); the depth, resolve, snapshot, clear-reach,
memoryless and fence-stage lanes passed. On the Radeon 780M and RTX 3090: msaa_depth_moves 9 of
9 with the fact off and every counter 0. Runtime unit filters 134 passed.
- The RTX 3090 measured neutral for both depth facts, and the RX 7900 XTX keeps DontCare as STORE
(not a measured identity), so neither is listed.
- Unaudited: no lane covers a tile dispatch in a held pass.
|
||
|
|
bd21b102f5 |
Cut a draw's and a pass open's allocations
Compare a draw's graphics key in place, keep a drawing state's routing for the pass colors it last met, write descriptors from the stack and allocate the set in place, keep a draw's small lists on the stack, hold what a draw retains by reference in one entry per encoder, find a draw's bind shape among its state's settles, fill push bytes in place, bound coverage without allocating, gather named keys only once a draw reaches the resident set, compare viewport compensations as they come, list argument samplers again only where the device's changed, and keep each pass shape's compatible render pass on the device (up to 64 shapes). The frame-cost lane bounds a draw at 27 allocations and a pass open at 14. Gain: allocations per draw from 67.5 to 24.5 and per pass open from 18 to 13 on RADV, ANV and lavapipe. Frame CPU on ANV (Iris Xe), clean rounds: 5.66 -> 5.02 ms. Verified on the original branch: the runtime lanes, 1313 of 1313 on RADV, ANV and lavapipe. This squashed commit (with the wake fix under it) was not re-tested on its own. |
||
|
|
13b279df1b |
Squash 11203 commits of translator, runtime, and validation work
Rolls up everything since
|