cee5c7eeb3c237f23ea88dffecba19e65b3ce33c
1388
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
cee5c7eeb3 |
Name a draw's read behind a barrier as the cause in the render-pass-split notice
What: a split made so a draw reads a color attachment's texture after a memory barrier (`Split::AttachedRead`, the pass-start barrier's split among them) is now counted for the split's degrade notice (`SplitCauses::attached_reads`), whose reason says so: "draws that read a color attachment's texture after a memory barrier read what its load actions and the draws before the barrier stored, in a Vulkan render pass instance after theirs, ending N of them". The `RenderPassSplit` declaration and docs/API.md's catalogue entry list the cause. Why: such a split counted neither as a barrier split (`self.barrier` is false for a render-target barrier before any draw, and for one between draws, which records in the instance) nor as any other cause, so the notice fell to its last reason, "its draws keep different attachments out of their subpass", which describes no part of this pass. The conformance replays of the pass-start barrier family showed the split announced on every barrier row (Apple M3 Max, lavapipe). How verified: builds (conformance binary, debug). The lane assertion added to `a_draw_after_a_barrier_at_the_pass_start_reads_the_clear` (the split's reason, and a notice exactly where a pass split) is NOT yet run; the runtime-sources pin is not re-hashed (the coordinator's). (cherry picked from commit 30b797c61b27d4dbe34386c36a27837bb3ed8ead) |
||
|
|
34bafa410d |
Record the pass-start barrier family on the M3 Max (unverified on our side)
WORK IN PROGRESS, parked: recorded on Metal, not yet replayed on the runtime.
pass_start_reads.rs adds 13 conformance cases (pass-start-barrier-*), each a pass that clears a
BGRA8Unorm target and draws a read of it (owned fixture psb_reads):
- 32x32 private and over-a-buffer targets, each with: the barrier then a read at own pixels; the
barrier then a pixel-coordinate sample; the read and the sample with no barrier; a solid draw,
the barrier, then the read.
- display-masked-read: a 1728x1216 private target holding an earlier DontCare pass's leftovers
(61x55, 45x45), cleared, the barrier, a read at own pixels through a 453x100 scissor beside an
A8Unorm mask over a buffer at texture 3.
- new-texture-chain: two new 896x576 private textures, each cleared, the barrier, a read at own
pixels through 841x521 (the second beside the first at texture 3), then a target over a buffer,
loaded, the barrier, and a read of the second over it.
- new-texture-tile: a new 448x576 texture cleared, the barrier, a read over all of it.
Texels are recorded as runs of equal texels (fresh_contents::texel_runs, now pub(super)). Rows
with a barrier accept, beside the M3 Max's recorded answer, the Mac2 answer the case states, by
docs/API.md's accepted difference a-barrier-over-the-render-targets-orders-what-it-names-as-a-
mac2-gpu-s-does (the sentence naming these cases is added to it here). tests.rs bills the 13
cases' cost records to the next whole-set run (AFTER_THE_LAST_RUN).
Verified:
- conformance record on the M3 Max (macOS 27, 3 runs, one outcome each): every row's read
draws the texels from before its pass, the barrier or not; Metal's validated leg stops the
barrier ("scope (0x4) cannot contain MTLBarrierScopeRenderTargets on this device; afterStages
(0x2) can not contain ... MTLRenderStageFragment on this device").
- cases::pass_start_reads unit tests pass (plain target), including
metal_reads_the_texels_from_before_the_pass_on_the_small_rows against these recordings.
- clippy -p metal2vulkan-conformance --all-targets --all-features -D warnings.
Unverified / owed:
- conformance replay of these cases on the runtime (M3 MoltenVK, 5080, lavapipe): whether each
barrier row matches the stated Mac2 answer exactly, and which notices each venue announces
(shared-in-system-memory is declared; shadowed-texture or dont-care-stand-in may be needed).
- times::every_case_carries_its_timing fails until `conformance times --write` runs over these
13 cases on the M3.
- docs/CONFORMANCE-COVERAGE.md not regenerated.
- new-texture-chain's recording is 1.46 MB of pretty-printed JSON (three 896x576 sites of 1042
runs each); consider dropping the first texture's site.
(cherry picked from commit 724afbf80b78c14a8824dfb96203df3813fba9aa)
|
||
|
|
c60898f65a |
Say what makes the own timelines' completed writes visible under every driver
OwnTimeline's doc said every batch with work waits for the timeline at the value the host saw it reach, and that the wait makes what it wrote visible. That is not what happens where the driver stalls on semaphore operations (completed_by_barrier, NVIDIA): such a batch takes no wait and starts with Barrier::after_completed instead. Internal submissions take neither. The doc now gives the guarantee that holds for both, from the spec (vkspec 1.4.366). The signal's "first access scope includes all memory access performed by the device" (7.4.1), which makes the writes available to the device domain (Appendix B, availability, visibility and domain operations). The host saw the signal and recorded it with AcqRel/Acquire. A later vkQueueSubmit then "performs a memory domain operation from host to device, and a visibility operation with source scope of the device domain and destination scope of all agents and references on the device" (Appendix B). With 7.9's ordering of the submission after prior host operations, those writes are visible to every later submission with no wait or barrier of its own. The doc then says which of the two each kind of submission still takes. This settles the staging GPU-wait gap I had raised: under by_barrier, a batch or an internal submission after a host-seen staging completion already sees the copies. The one link the spec states only in an intro sentence and an informative note is that a host vkWaitSemaphores happens after the signal it sees (7.4 and Appendix B's system-synchronizes-with note); fences have the normative sentence. Doc comment only. Verified: cargo fmt --all. No build or test run; the change touches no code. (cherry picked from commit aca36f8dc0d57c5c897a3ef9563f1e168d489a70) |
||
|
|
60d3c512a6 |
Announce copied-host-pages for a buffer that lies in a live copy
What: a no-copy buffer or rebind that lies in the live copy of the same bytes (`Device::degrade_copied_shared`) announces `copied-host-pages`, its detail saying it lies in that copy and whether the copy drops the GPU's writes. docs/API.md says so. Why: such a buffer makes no copy of its own, but the GPU uses a copy for it all the same (`Buffer::host_backing` answers `Copied`); before the join each one was a copy and was announced. A consumer that asks for the kind at each occurrence (`DeviceOptions::announce_each`) hears it per buffer as before. Verified: cargo check of the runtime (all features); the lane runs follow on the M3. (cherry picked from commit a4a75f118381a9f049157b1da063ba2fa4c9bff5) |
||
|
|
2fd6c9853f |
Add the copied present bench: a new buffer over a refused surface each frame
An ignored release-mode device test (COPIED-PRESENT): each frame makes a new no-copy buffer over a surface's pages, its import refused, and a texture over it that the display reads, at 64x64 and 3840x2160 BGRA8, beside a buffer of the surface's that lives across frames and alone. It prints copies made a frame, the median CPU time of the making and of the frame, and bytes copied in and merged back a frame. It uses only API both before and after the copied-join change, so the same file measures both. (cherry picked from commit 58054b774a02947bb908c0f0b92a10d73cb047df) |
||
|
|
dd9fca0990 |
Let a copy's merge keys go with the pages that named them
What: a copied host buffer's registry entry keeps each key with a count of the pages lying in the copy that named it (`Copied::name`), and the pages' drop takes their naming back (`Copied::unname`, `HostPages::named`). Each pages names once. Why: since the previous commit, a buffer made over a live copy's bytes lies in it and names its key, and the consumer makes one such buffer per texture per present. Keys were only ever added, so the entry's key list (scanned by every merge back and every naming) grew by one a frame without bound. Dropping a key once its pages go is safe: the command buffers that used the pages hold them until their completion turn, which merges back before it lets go of its holds (`command_buffer/completion.rs`). Verified: tests::copied::a_copy_s_keys_are_those_of_the_pages_lying_in_it (1000 named-and-gone keys leave one; a key two pages named stays until both went and is compared until then), with the rest of tests::copied and tests::host_aliases passing; clippy of the runtime under m2v_gpu. (cherry picked from commit 597804ec5352113f212ad702ce95ed96ee0de815) |
||
|
|
44c3f94793 |
Add the copied surfaces lane: buffers over one refused surface are one copy
runtime_lane::copied_surfaces makes reims-vgpu's probe shape (64x64 BGRA8, 256-byte rows, each texture over its own new_buffer_with_descriptor NoCopy buffer whose gate refuses) and holds every texel fresh in their two cases (two blit encoders of one command buffer; a reader committed first on a second queue waiting on the writer's event) plus one queue in flight and a host-ordered control, and counts one copy made and one buffer shared per surface. It also checks that a Shared and a Managed buffer share one copy with didModifyRange/synchronize semantics intact, that a bit-24 buffer stays apart on macOS (read-only view import, no copy, its fill dropped) and joins elsewhere, and that a rebind lies in the copy unless its texture moved in its page (then a copy of its own laid at the old offset). The expectation is Metal's as reims measured it on the M3: the validation crate's Metal side runs authored kernel cases, not this host-memory shape, and Metal has no import gate. (cherry picked from commit 94ac84d62eeff8d85c10a87e1a1c88261bdd462d) |
||
|
|
6c4b409fb0 |
Lay a no-copy buffer over a live copied host buffer's bytes in its copy
What: a copied host buffer (the caller's gate refused the import, or an admitted import failed) now joins its memory and is placed as an import is (`HostAliases::join` with `Kind::Copy`, `HostAliases::place`). A later no-copy buffer over exactly the same first byte and length, of either storage mode, finds it (`HostAliases::import`: an import of its class, else the live copy), lies in it through `Device::buffer_in_import`, is named to it (`copied_as`) and joins its key, with the gate not asked. A rebind onto such bytes lies in the copy too where its textures were planned at the copy's offset (its first byte) and no image in place rides on it; an import keeps the old `!moved` rule. A heap's own copy is placed but joins nothing; a buffer whose writes are dropped keeps its read-only view. New counter `WorkCounts::copied_host_buffers_shared`. Why: two copies of one memory agreed only through the pages (merge back at the writer's completion, copy in at the reader's commit). reims-vgpu measured on the M3 (MoltenVK) two textures over one 64x64 BGRA8 surface, each over its own refused no-copy buffer: a blit write then a blit read in one command buffer, and a reader committed first on a second queue waiting on the writer's event, both read all 16384 bytes stale, where Metal and the runtime in place read the write. The consumer also made a full copy of the surface per texture per present. The remaining GPU-to-GPU gap, between a copy and another copy or import of overlapping but different bytes, is recorded in copied.rs, docs/API.md, docs/HOWTO.md and docs/FAST-PATHS.md's known gaps. Verified: cargo check of the runtime with tests; the lane in the next commit, run on the M3 (see its message). (cherry picked from commit 69feb791dc6ec3bc2405dbf5b6ae5d0b27d936aa) |
||
|
|
7127ca8035 |
Re-record the conformance costs for the set-0, staging and ICB changes
Stack 26 moves gated cost bounds on purpose, so the cost check against the old records failed with 20 gated numbers moved. This re-records every case: a whole-set `conformance cost --runs 8 --write`, then `cost --runs 8 --alone --write` over every changed case (all 636), so each record carries its contrast. The gated moves the old records rejected: - The set-0 trade, per-stage pushes in place of rebinding set 0: descriptor-set binds down and push constants up, for example vertex-format-constant-step 540 -> 45 binds and 45 -> 540 pushes, integer-vertex-attributes 288 -> 64 and 64 -> 288, and indirect-render-commands-vertex-stride 2 -> 1 and 1 -> 2. set_zero_sets_reused rises in 8 cases (render-state-facing 1 -> 9, depthstencil-depth-codes 56 -> 66), and stage_tables_read_in_part moves 28 -> 29 in depthstencil-depth-compares. - Newly gated counts: bound_offsets_moved in 42 cases; set_zero_sets_found given up in 21. - draw_states_recorded rises in three cases, cause still open: indirect-render-commands-inherited-state 32 -> 34 and indirect-render-commands-executed 13 -> 15 (each also +2 push constants), and render-state-facing 75 -> 82. A bisect over stack 26's commits is under way. These bounds hold today's counts, so a fix will show as a gated move down. Every record also takes the whole-set run's scheduler and object-churn counts (scheduler_passes, scheduler_sleeps, buffers_evicted and the like), which move in both directions with the run. Verified on the M3 (potluck job m3-max-96, exit 0: 636 cases measured, none the venue could not measure), then the conformance suite on this tree, 1011/1011 passed. |
||
|
|
4812a51dbe |
Have the steps-apart lane set a state that may encode before its write use
Under the write routes a write use of an indirect command buffer lets the GPU write its records
only beside a state that may encode indirect commands. steps_apart's pass made its buffer
resident for writing with no such state, so its records stayed the CPU's, its execution was
recorded at the commit, and no host step ran: another_queue_goes_on_while_a_host_step_records
waited 60 s for A's step to begin ("A's host step began: Timeout"). The lane was not among the
modules b5fc188d93 moved to indirect_host_steps::encoding_state_set.
Its pass now calls encoding_state_set first, as those lanes do: the state is set in an encoder of
its own that runs nothing, so what the records may hold gains its resets alone and the pass's
execution is the host step it was before the write routes.
Verified: see the coordinator message (steps_apart module, debug --cfg m2v_gpu, M3 through
potluck).
(cherry picked from commit d3c4c243fa54153b26a9c380591556ddbf1b4e81)
|
||
|
|
fd471f794c |
Bless the golden tables for the pass-start barrier's psb_reads fixture
The pass-start barrier fix brought the psb_reads fixture (its own branch never blessed it), so the engine inventory, the air_input printout and the golden hashes lacked it: the gate's core suite failed five tests (inventory order, air_input printout, golden hashes, two assembly parts). The bless adds only psb_reads rows (12 inventory lines, 12 golden-hash lines, psb_reads.txt); no existing row moved. Verified: the three bless steps exited 0 on the M3 at 0b556ddfd6's tree; the five tests rerun next. |
||
|
|
0b556ddfd6 |
Pin the runtime sources after RUNTIME_VERSION 1763's stack
The runtime sources changed with the stack this bump covers (staging copies and first moves, the free thread, the pass-start clear order and reads, the settle shape, the ICB write routes, the set-0 per-stage pushes). No removed Degradation variant, WorkCounts field or method. |
||
|
|
023d9237bb |
Bump RUNTIME_VERSION to 1763: batched staging copies, queued first moves, freed blocks on a free thread, the pass-start clear order, kept pass-start reads and the settle shape
Runs of unchanged artifacts and plans do something else under this stack: - replace_region's staging-queue copies go out as one submission (they carried a burst); - a Managed texture's first move and zeros are queued, not waited for at create; - released blocks are freed on the device's free thread, and an event's semaphore is destroyed inline again; - a render-target barrier at a clearing pass's start orders the pass's clear before a later draw that reads it (split or snapshot); - a draw's pass-start-read check over what its encoder made resident runs once while the uses keep their identity; - an encoder that took another render state's spare bind state rebinds its draws; - the ICB write routes, set-0 per-stage pushes and gathered resident uses already in this stack. Verified: the API signature and refusal-surface checks pass on this tree. |
||
|
|
92728bbb30 |
Answer an equal shape's settle with the draw's very shape, so an encoder that took another state's bind state rebinds
What: GraphicsState::settle_shape looks a draw's bind shape up among the
state's last settles, by identity first, then by value. A hit by value
answered the entry's own shape, an equal Arc but not the draw's. The
encoder keeps the draw's shape (LiveBind::shape), and its next draws find
their settle kept only by identity (LiveBind::settled, settles_kept), so
they found none. Each of them took every step (draw_resident) and settled
by value again, and none of them was rebound. Now an entry found by value
holds the draw's shape from then on, and the answer carries it. What
settle answers is a function of the shape's value and the forms alone, so
nothing changes but which Arc is shared.
Why: an encoder starts from the bind state an ended encoder gave its
device (SpareLiveBinds), shape included, whichever pipeline state that
encoder drew. Programs that make a render state of the same descriptor per
thread (reims-vgpu's decoders, one per lane) give each state's memo a
shape of its own. An encoder that took a bind state another thread's
encoder left then drew its whole command buffer through every step. On
the M3 Max this is reims-vgpu's 4-thread draws.10k cost of 11,980 +
k x 978 instructions a draw, k from 0 to 18 by run: k is how many of a
run's 18 command buffers took such a bind state.
Evidence:
- The bench (draws.10k on N threads, each with its own queue, target,
chunks and render state over one device), at
|
||
|
|
3b5badc418 |
Check a draw's uses of what its encoder made resident against the pass's fragment stages once
A draw's check against what its render pass's fragment stages wrote and read
(render/pass_start_reads.rs: PassStartReads::announce, then PassStartReads::add) walked each of
its uses: announcing a read in place of bytes a fragment stage wrote, and an access of those
stages Metal orders and the device may not, then noting the draw's own. That is work of the
count of the resources its encoder made resident, at each draw, which draws keep from one to the
next with their identity (binding::ResidentPrefix). On the resident-draws lane at N 2000 it was
12% of the samples after the uses were kept.
render.rs's draw path and a rebound draw choose by CommandUses::prefix: a draw whose uses have
no identity is announced and noted as before (announce, add, which find what they announce
through the same per-use tests as the rest, in_place and ordered). One whose uses have one goes
through PassStartReads::draw:
- Noting (add_draw): where the last such draw began with the same uses, and no list merged a
key's ranges into their hull as it noted them or since, each of them is held as it was noted,
and noting it again changes nothing (a range held already adds nothing; only a merge drops
one), so only the uses past them are noted (add). The lists count the ranges they took and
their merges (Written::changes).
- Checking (check): where none of those uses met anything, that holds while the bytes the
fragment stages wrote stand, and those they read where one of the uses writes in a stage whose
writes count, and while the draw's emulated stages record as they did (compute_after); then
only the uses past them are checked, and the first of the draw's uses each announcement names
is the first past them. Where one of them met something, every draw checks them all, as before,
so a device that announces each announces each.
Counted: WorkCounts::resident_uses_against_fragments, the kept uses those two walked, whole for
each: 0 at a draw that begins with the uses the last began with while nothing they meet changed.
WorkCounts gains that field, so a struct literal of it must name it; the signature table is
blessed. Builds with debug assertions check every answer against the whole uses': the uses
noting skipped are each held as they were noted, and the check finds what a check of the whole
uses finds.
Tests (with debug assertions):
- render::pass_start_reads::tests::a_draw_checks_its_resident_uses_again_once_the_fragments_wrote_more:
a draw's resident uses are checked again after its own fragments wrote, not after a draw that
changed nothing, and after another draw's fragments wrote what they read at each draw, finding
the read. With the check ignoring the changes of what the fragment stages wrote and read, the
test fails ("its fragments wrote").
- render::pass_start_reads::tests::a_draw_notes_its_resident_uses_again_once_a_list_merged_their_ranges:
draws reading the same resident bytes and 16 ranges of their own note the resident bytes once,
and again only after the draw whose range merged the list. With noting keeping the identity
where a list merged, the debug check fails ("a pass noted a draw's uses by their identity less
than its uses").
- tests::resident_uses::draws_announce_each_read_of_what_their_encoder_made_resident_their_pass_s_fragments_wrote
(--cfg m2v_gpu): after a marker draw whose fragments write a position the encoder made
resident, each entry draw reads it in place through the resident set and announces
InPlaceVertexReads at each draw (announce_each), the later ones keeping their uses. With the
check keeping the identity where the uses met something, the debug check fails here and in the
first unit test ("a pass checked a draw's uses by their identity less than its uses").
- tests::resident_uses::draws_keep_the_uses_of_what_their_encoder_made_resident_until_it_or_their_plan_changes
now also counts the kept uses the checks walked: 0 at each draw that kept them.
Verified on the M3 Max (macOS 27), this tree:
- the runtime's suite (--cfg m2v_gpu, debug): 1591 passed;
- the validation lanes over residency, draws and notices (resident_draws::each, used_resources,
argument_buffers, render_arguments, indirect_command_buffers, indirect_executions,
draw_changes, draw_work, draw_costs, frame_costs, heaps, heap_textures, handles,
attachment_reads, attachment_read_costs, pass_start_reads, degrade_notices, degradations,
executions, shadows, in_place_textures): 245 passed;
- clippy (workspace, all targets and features, -D warnings) at --cfg m2v_gpu and plain, and the
runtime's release --tests check at --cfg m2v_gpu: clean; the signature table check: clean;
- the negative controls above, run: each fails as described.
Measured:
- Plain rebound draws (reims's draws.10k, no resident uses; the runtime leg's instructions a
draw, median of 9 runs, two interleaved rounds): d1 11387.1 and 11385.7, this 11378.4 and
11377.8. The tests in_place and ordered make are inlined into each walk (#[inline(always)]):
called, the plain draw's walk took 35 instructions more.
- RTX 5080 laptop (host_ab encode, 10,000 draws; median over 6 runs of each run's median, us a
draw; two exclusive holds of 3 interleaved passes, the CPU package at 63 to 66 C): draw_offset
d1 0.459, the last commit 0.414, this 0.413 (draw_offset is bimodal by process);
draw_compositor d1 0.978, the last commit 0.980, this 0.974.
- The resident-draws lane on the M3 Max, whole-process instructions over 5 frames (frame
median ms), the last commit then this, interleaved:
entry own encoder N 500 1.381e9 (7.1) 1.211e9 (6.5)
N 1000 2.788e9 (21.7) 2.513e9 (19.1)
N 2000 8.375e9 (75.3) 7.290e9 (66.2)
N 5000 45.85e9 (430.2) 39.10e9 (366.8)
entry own write N 5000 49.05e9 (458.3) 40.63e9 (388.4)
about 54 instructions fewer a resident use a draw (67 where the entry draw writes).
(cherry picked from commit f1f03ae940fee1d403121125cbd9a6a683f8d0de)
|
||
|
|
398b6b6bda |
Weigh a render-target barrier at a clearing pass's start before a read of its target
pass_start_barrier_costs (ignored, release, report only) runs a pass that clears a display-sized (1728x1216) or backdrop-sized (896x576) private BGRA8Unorm target, with and without a memory barrier over the render targets first, then one draw through a scissor that reads the target at its own pixels beside an A8Unorm mask over a buffer (psb_masked) or samples it in pixel coordinates (psb_sample). The cells run in turn, round after round; each prints the median GPU time and the median CPU time from command buffer to commit per pass, and per pass the splits, snapshots, render pass instances begun and texels copied in. It weighs the instance after the pass's first that a read after such a barrier now takes. Verified: clippy --all-targets --all-features -D warnings on metal2vulkan-validation with --cfg m2v_gpu. Its readings come with the commits that cite them. (cherry picked from commit ab6a9e5364202a6b45e2762ca42e47bfacc6f67e) |
||
|
|
3797c098eb |
Order a pass's clear before a draw that reads it after a barrier at the pass's start
A pass that clears a color and begins with a memory barrier over the render targets (after the fragment stage, before it) and then samples that color's texture in a draw read the texels from before the pass. Mac2 GPUs read the clear there (an Intel UHD 630 after the barrier, an AMD Radeon Pro 5300M with or without it). The draw reads the texture's copy, taken ahead of the pass's load actions (render/shadows.rs), and a barrier split the pass only where a draw of the current instance came before it, so a barrier at the pass's start split nothing. Such a barrier now orders the pass's load actions (`loads_ordered`): the scope form with the render targets, or the resource form over an attachment's texture, after the fragment stage and before a stage at or before it, recorded before any draw of the pass. A draw after it that samples the texture of a color the pass clears (`Texture::cleared_in`) takes the existing after-barrier path: it records into an instance after the pass's first, which runs the clear and draws nothing (`next_instance` keeps the first instead of replacing it), so the copy before it holds the clear; or, where the device has them, it reads through snapshots inside the first instance. The split is counted as the after-barrier read's (`attachment_read_splits`, `instance_splits_attached_read`) and reloads stand-ins over a buffer's bytes as one after a barrier does. A pass with such a barrier but no such draw records as without it. docs/API.md section 10 gets the accepted difference this ordering is: Apple GPUs do not support the render-target scope, and the M3 Max reads the texels from before the pass after it. The owned fixture psb_reads (regen-air-fixtures) holds the functions the lane and the coming conformance cases draw with: a read and a pixel-coordinate sample of texture 0 at the fragment's own pixel, channels reordered so a read is told from a skipped draw, and two-texture reads. Verified on the M3 Max (MoltenVK, debug, --cfg m2v_gpu), runtime_lane::attachment_reads: - a_draw_after_a_barrier_at_the_pass_start_reads_the_clear: both targets (own image, over a buffer), psb_read and psb_sample, the scope alone, with the textures and the resource form: the clear inside the scissor, one split each (attachment_read_splits 1, instance splits 1, 2 instances begun), own-pixel copies of 308 texels (the 20x12 scissor and a pixel round). - a_draw_after_a_clear_with_no_barrier_reads_the_texels_from_before_the_pass: no split. - a_barrier_at_the_pass_start_costs_nothing_without_a_read_of_a_cleared_color: a loaded target read after the barrier, and a cleared one with a draw reading another texture: no split, as many instances begun and copies taken as with no barrier. Negative control: the same tests on the tree without the runtime change fail at pixel (4, 4), reading [0, 64, 0, 255] (the texel from before the pass, reordered) where the clear's [120, 200, 40, 255] is due. (cherry picked from commit 923095effcd188a93ee5134ecc4dad3fab21b3fe) |
||
|
|
be72c4bebc |
List the free thread as a keeper of the device's functions, and rename the methods a release scan reads as frees
The runtime's whole suite on the M3 Max at 1659544703 failed two of exit_guard's source scans, both from the free thread's commit (6d722a6769): - every_release_goes_through_the_release_door reads `.free_` as a call of a vkFree* entry point outside release.rs, and matched Memory::free_on and Memory::free_thread(). Neither frees anything: one sets the device's free thread, the other hands out a share of it. They are now Memory::post_frees_to and Memory::posted_frees. - only_the_listed_modules_keep_the_device_s_functions found free_thread.rs keeping an Arc<Functions> and no entry for it in KEEPERS. It is listed now, with why it may: the thread frees each posted block inside an exit-guard section, and the device's teardown stops the thread, which frees every block posted, and joins it before vkDestroyDevice. No behaviour changes; no WorkCounts field or public signature changes. Verified on the M3 Max: tests::exit_guard (41 tests) pass; clippy for the workspace, all targets and features, -D warnings, plain and with --cfg m2v_gpu; cargo check of the runtime's tests in release with --cfg m2v_gpu. (cherry picked from commit 00c5bc5a6e9491948ae991eba7c49af9e2f91e54) |
||
|
|
1a541744e1 |
Destroy an event's semaphore where its release goes again, and record NVIDIA's event costs
What: an event's release destroys its timeline semaphore on the releasing thread again, as at
4bbafa667d (event.rs is that commit's again); the device's free thread frees blocks alone. The
semaphore posting goes with its counter (WorkCounts::semaphore_destroys_posted; the API table
blessed: the field removed), its runtime test and its lane rows. docs/FAST-PATHS.md's known gaps
record what making and releasing an event costs on NVIDIA, and why the release is not posted.
Why: NVIDIA's driver runs a vkCreateSemaphore behind a vkDestroySemaphore another thread runs,
so a posted destroy moves its cost onto the program's next event and adds to it. Measured on the
RTX 5080 Laptop GPU with the bench's event modes (each row 1000 events unless said; before and
after interleaved within each hold; CPU package 83-103 C), p50 unless said:
burst, 1000 made then released inline: make 143-262 us, release 495-579 us
(0.47-0.57 s a 1000 released)
posted, bound 4096: release 0.2-0.5 us, but the makes
while the destroys drained 1048-1676 us (1.10-1.66 s
a 1000)
posted, bound 64: release 0.5-1.2 us, p99 1.5-2.2 ms,
0.51-0.66 s a 1000; makes unchanged
steady, make one and release the inline 203-238 us a pair; posted (64) 390-507 us
one before, back to back
steady, 2 ms apart (500) inline 488-490 us a pair (event), 663-677 us (shared);
posted 260-263 us and 417-421 us
the driver's own cost grows with the semaphores live: 98-119 us a make and a
release with one or two live, against the burst's
143-262 and 495-579 us with 1000 live
On the M3 Max (MoltenVK 1.4.2) a pair costs 2.6-2.8 us inline and 5.3-5.9 us posted back to
back, about 45 us either way 2 ms apart; Metal's own newEvent and newSharedEvent take 0.8-1.9
us there. The consumer's guests made no event in a boot of theirs, and their host makes a few a
second, so no shape of use has the posted destroy ahead, and the burst at a program's close,
which posting was for, gains nothing: the device's teardown drains what was posted.
Verified on the M3 Max (debug, --cfg m2v_gpu, under maclock and memcap): 90 runtime tests
(posted_frees, freed_memory, teardown_threads, memory, allocations, event, cpu_copy_layouts)
and 27 lane tests (posted_frees, shared_event, events, pool_churn, staging_batches) pass;
api_signatures and api_surface pass; clippy (plain and --cfg m2v_gpu, workspace, all targets,
all features) and the release check of the runtime's tests are clean. The inline rows above
are the RTX 5080's at 4bbafa667d's event path, which this restores.
(cherry picked from commit 1659544703425cd461106fba2cff7cfe73a02a8a)
|
||
|
|
03db73b32c |
Count a block texture's CPU copies on a staging-queue device as that queue makes them
`block_cpu_copies_stage_their_writes_and_read_where_the_device_copies_on_the_host` had arms for a device that copies blocks on the host and for one that serves reads from a host shadow, and none for a device with a staging queue, whose block textures take neither: it failed on the RTX 5080 Laptop GPU before the staging queue's copies were queued (4bbafa667d: writes 0/4/0, reads 0/4/0, three runs of three) and after (writes 0/0/0, reads 0/4/0). The new arm holds what the queued copies give there: no write makes a submission, and each read makes one on the staging queue, which carries the write queued before it. Also rewraps two doc paragraphs of the staging copies' past 100 columns. Verified: on the RTX 5080 Laptop GPU the test passes 3 of 3 runs (writes 0/0/0, reads 0/4/0); on the M3 Max (no staging queue, the shadow arm) it passes among 64 runtime tests (posted_frees, freed_memory, teardown_threads, cpu_copy_layouts, event). (cherry picked from commit 7649ad0d7d4a60987b1783354023aee629cf7505) |
||
|
|
b8ed1b8185 |
Free released blocks and events' semaphores on a free thread of the device's
An object's release that frees a block of the runtime's memory ran its
vkFreeMemory on the releasing thread. A driver that unmaps the block's pages
charges that to the free: on the M3 Max a release that freed a block took up
to 24 ms (a 2048x2048 Shared texture's, a 16 MiB buffer's), and the consumer
measured 2.4% of drops at 0.5 ms or more on an RTX 5080, up to 9.5 ms. An
event's release destroyed its timeline semaphore inline, about 400 us on the
5080 (the consumer's measurement), in the kernel driver.
Now the device has one free thread (free_thread.rs), started by the first
post, with a bounded queue (64 frees):
- Memory::let_go posts the block's buffer of addresses and memory, and the
fresh pages a buffer's block was imported from (unmapped there after the
free). Never an import of the caller's memory (a no-copy object's, a
read-only view of the caller's pages, a guest RAM chunk): the spec's
"the application must ensure that the imported memory range remains valid
and accessible for the lifetime of the imported memory object"
(VkImportMemoryHostPointerInfoEXT), and the caller may free its pages once
the release returns, so those stay freed before it returns. On a device
that parks freed memory (MoltenVK), a block whose batches had completed as
it went is posted; a parked one is freed by the handler thread as before.
- EventShared::drop posts its semaphore's destroy: at the last holder's drop
no batch (each holds the event until it completed), no reserved caller
signal (held until it landed) and no caller submission
(SharedEvent::vk_semaphore's contract) uses it. It leaves the device's set
of own timelines at once; the driver hands the handle out again only after
the destroy. Never recycled.
- A full queue, a teardown begun or a thread that cannot start frees inline
(WorkCounts::free_thread_queue_full).
- Posted frees still count: against maxMemoryAllocationCount until their
vkFreeMemory (allocations.rs), so an allocation at the limit waits for them
before it is refused; and against their heap's size (Memory tracks each
heap's live block bytes and the thread its posted bytes), so a block that
would take its heap past the heap's size waits for them first, as one whose
making failed for room does (memory.rs place, make_room). The runtime has
no memory-budget query, so the heap's size is the bound.
WorkCounts::memory_free_waits counts the waits.
- The device's teardown stops the thread after Memory::destroy and before
vkDestroyDevice: every posted free runs and the thread is joined.
- The thread holds a share of the device's functions and its queue only, and
runs each free in a section of the exit guard.
Address and ID reuse need no free: the Metal address space is the runtime's
own (address.rs; pinned addresses are its ranges, Vulkan device addresses are
never shown, no capture-replay address is asked for), and resource IDs and
ranges go back with the object as before.
Counts: WorkCounts::memory_frees_posted, semaphore_destroys_posted,
free_thread_queue_full, memory_free_waits (api_signatures blessed).
Verified on the M3 (MoltenVK, which parks freed memory, so the posts there
come from blocks whose batches had completed): runtime tests posted_frees (5:
a pinned address and a forced resource ID take new resources while the old
blocks' frees are held pending; an allocation at the limit waits for 3 held
frees and is made, none refused; a block past its heap's held size waits;
the teardown returns only after the held frees ran, the thread joined; an
event's semaphore destroy posted once the command buffer that signalled it
let go), with freed_memory, host_ram_device, teardown_threads, memory,
allocations, recycle, pool_room, fresh_pages and event tests: 105 passed.
Validation posted_frees (each release of a 96 MiB buffer, Private, Shared
over fresh pages or Managed, an 8192x8192 texture, a 96 MiB heap posts its
block; a no-copy buffer's import is freed inline, none posted; 8 events post
8 semaphore destroys) with pool_churn, placement, host_memory,
staging_batches and event lanes: 59 passed. Negative controls from archived
sabotaged builds: without the waits and the teardown's drain, the limit, heap
and teardown tests fail (3 of 5); with nothing posted, the lane fails
("private buffer: 0 posted").
Release bench on the M3 (C mode, before 4bbafa667d / after, same hold): the
releases that free a block had maxima of 4.5-5.2 ms (2048x2048 Managed and
Shared textures, 16 MiB buffers of each mode, a 64 MiB heap) and now 16-106 us;
16 MiB buffers' 300 releases total 10-11 ms before, 0.4-0.6 ms after.
No-copy releases are unchanged (inline by design, up to 1.3 ms for 16 MiB).
Events on MoltenVK: make about 2 us, release 0.2-0.4 us either way.
fmt, clippy (workspace, all targets, all features, plain and --cfg m2v_gpu),
rustdoc of the runtime, the release check with --cfg m2v_gpu and the
signature table are clean. The 5080 legs run on msi.
(cherry picked from commit 6d722a6769e1e5e7f4e7ff789f050a966b68c128)
|
||
|
|
54d6fce7ed |
Free a carried staging submission's bytes inside an exit-guard section
A staging submission that a batch carries is held by the batch until it
completes (Flushed), and so is dropped on that queue's waiter thread. Its drop
waited for the staging timeline (vkWaitSemaphores) outside any section of the
exit guard: in debug builds Functions::get aborts there ("the runtime's thread
metal2vulkan-queue-wait-0 reached the device outside an exit-guard section"),
and in any build the wait could run while the process exits.
The drop is now one section of the exit guard; once the process is exiting the
staging buffers are left to its end, as every other release is.
Found on the RTX 5080 (the M3 has no staging queue, so no batch carries one
there): staging_batches::a_burst_of_new_textures_makes_no_staging_submission,
a_burst_of_replace_regions_shares_one_staging_submission and
first_use::frame_sized_textures_copy_texel_exact aborted with SIGABRT at
cad7056ece. Re-run on the 5080 follows.
(cherry picked from commit e08e1e6f51a1ff9c06cf4cec18aae5b38247bed0)
|
||
|
|
164fdf475f |
Queue a staging-queue texture's first move and zeros instead of waiting at create
A texture that copies on the staging queue (a transfer-only family, NVIDIA's) took its first layout move and its zeros in a staging submission of its own, which new_texture waited for on the host (FirstMove::record_alone): the consumer measured 0.95 ms p50 and 26.8 ms at most for a Managed texture's creation on an RTX 5080. Now the move goes into the staging queue's batch (texture/staging_copy.rs's Queued) as the texture is registered, under the registration lock and before its slot write, and rides the next flush: its first replaceRegion's copy (recorded after it, a transfer write-to-write barrier between them when the image repeats), the next batch's or internal submission's flush (which the queue then waits for on the GPU), or a host read, hand-out or settle (waited on the host). Runs of moves share one barrier (FirstMove::record_several). The zeros come from one device-wide zero buffer (Device::staging_zeros) instead of a buffer per texture. The burst bound of copies and bytes holds the moves too. So every read of a fresh texture still answers its zeros, and a first copy lands after them: both ride one ordered queue. FirstMove::record_alone and Device::submit_staging go: nothing uses them now. WorkCounts::staging_moves_queued counts the moves queued (api_signatures blessed for the field; host_ab lists it). Verified on the M3 (MoltenVK, no transfer-only family, so the staging path does not run there and its counts do not move): staging_batches, first_use and heap_layouts lanes, 27 passed; conformance replay of the 22 fresh-texture-* cases exact; cost --alone --show of the 2d rgba8unorm managed and shared cases: no count moved. fmt, clippy plain and --cfg m2v_gpu, and the release check with --cfg m2v_gpu are clean. The 5080 legs (counts, before and after, the negative control) run on msi. (cherry picked from commit cad7056ecee2416d0e57d6db41b0cfdee07e3523) |
||
|
|
97baf233de |
Queue staging-queue texture copies and carry a burst in one submission
What: a replace_region into a Shared or Managed texture that copies on the device's staging queue (a transfer-only family: the RTX 5080's) packs the caller's bytes into a staging buffer of their own before it returns and queues the copy, instead of making a staging submission and waiting for it. The queued copies go to the staging queue in one submission, in their order (a barrier between two into one image), made by the first of: the device's next batch or internal submission, before its own, which waits for it on the GPU (Device::staging_wait, beside binding_wait); a get_bytes, which carries them before its read; a VkImage hand-out (settle) and CommandQueue::with_vk_queue, which wait on the host; a write into a texture whose VkImage was handed out; and the call past STAGED_COPIES / STAGED_BYTES, which waits on the host. The staging queue now records into up to eight command buffers and signals its own timeline on every device (no fence); a submission is waited for only where the CPU needs its result. The batch keeps what the flush copied (images, staging buffers) in its retained list until it completes; a queued copy holds its image weakly, so a texture gone takes its copy with it. Why: the consumer measured Safari's GPU process making 1776 replace_region_with_host_bytes calls at its first page on the RTX 5080, each waiting for its own staging submission (p50 120 us, p99 232 us, 223 ms in all). Metal's replaceRegion is a CPU copy; only the submission may move. Counted: WorkCounts::staging_copies_queued, staging_flushes, staging_gpu_waits (API table blessed: three fields added; conformance cost puts the last two in the submission region). Verified on the M3 Max (debug, --cfg m2v_gpu, under maclock and memcap): the new lane runtime_lane::staging_batches (6 tests) and runtime_lane::first_use (10), runtime tests cpu_copy_layouts, first_move, staging (30): all pass. The M3 has no staging queue (MoltenVK lists no transfer-only family), so there they run the host path and check the contract only; the staging path's counts and negative control run on the RTX 5080. clippy (plain and --cfg m2v_gpu, workspace, all targets, all features) and the release check of the runtime's tests are clean. (cherry picked from commit d47df5a36970e54e51465588e4ae3d6b299bcb0a) |
||
|
|
3a219dcb06 |
Re-bless the golden tables after the routed ICB writes and the per-stage pushes
The engine inventory gains the icb_routed_writes fixture's seven entry points and resident_draws' rd_encode kernel; air_input gains icb_routed_writes.txt and re-reads resident_draws.txt with the new kernel's types; golden_hashes moves with SEMANTICS_VERSION 1958. Verified: the three bless steps exited 0 on the M3 (inventory, air_input, golden hashes) at 6de4e38fbb. (cherry picked from commit 9ae9e999dd8a8f97ddb440774327d6e63380eaf0) |
||
|
|
8da041d648 |
Gather a draw's uses of what its encoder made resident once while their identity holds
A draw's gathering for its render pass instance (InstanceShadows::add, which the shadowed
textures it uses are copied around) compared each of its uses with the last draw's at its place
and gathered those that differed: work of the count of the resources its encoder made resident,
at each draw, which draws keep from one to the next since the last change
(binding::command_uses_into). On the resident-draws lane at N 2000 that was 17% of the samples
after the uses were kept.
The kept uses now have an identity (binding::ResidentPrefix): a number of the process's, given
where command_uses_into makes them (none where they are none), and their count. The numbers come
from one counter, taken at such a making alone; a draw that keeps them, or has none, takes none.
CommandUses::prefix gives it, None where there are none or command_uses made the uses whole.
A draw whose uses have an identity is gathered through InstanceShadows::add_draw, which keeps the
identity and count of the kept uses the instance's last such draw began with: a draw that begins
with the same gathers only its uses past them. What an instance gathered stays until it is
cleared, and uses of one identity are the same uses, so gathering them again changes nothing, as
each range only grows. A draw whose uses have none is gathered by InstanceShadows::add, as
before: render.rs's draw path and a rebound draw choose by CommandUses::prefix, so a plain draw
takes the code it took before but for that choice.
Counted: WorkCounts::resident_uses_gathered, the kept uses a draw's gathering walked: 0 at a
draw whose instance's last such draw began with the same. WorkCounts gains that field, so a
struct literal of it must name it; the signature table is blessed. Builds with debug assertions
check, at each such draw, that what the instance gathered holds each of the draw's whole uses'
reads and writes.
Tests (--cfg m2v_gpu, with debug assertions):
- tests::resident_uses::draws_keep_the_uses_of_what_their_encoder_made_resident_until_it_or_their_plan_changes
now also counts the kept uses each draw's gathering walked: 0 at each draw that kept them,
some at each that made them again. With add_draw taking any identity for the last's, the debug
check fails at the draw after the use_resource ("an instance gathered by its uses' identity
less than its uses").
Verified on the M3 Max (macOS 27), this tree:
- the runtime's suite (--cfg m2v_gpu, debug): 1588 passed;
- the validation lanes over residency, draws and notices (resident_draws::each, used_resources,
argument_buffers, render_arguments, indirect_command_buffers, indirect_executions,
draw_changes, draw_work, draw_costs, frame_costs, heaps, heap_textures, handles,
attachment_reads, attachment_read_costs, pass_start_reads, degrade_notices, degradations,
executions, shadows, in_place_textures): 245 passed;
- clippy (workspace, all targets and features, -D warnings) at --cfg m2v_gpu and plain, and the
runtime's release --tests check at --cfg m2v_gpu: clean; the signature table check: clean;
- the negative control above, run: fails as described.
Measured:
- Plain rebound draws (reims's draws.10k, no resident uses; the runtime leg's instructions a
draw, median of 9 runs, two interleaved rounds): d1 11386.9 and 11378.7, this 11384.8 and
11382.2.
- RTX 5080 laptop (host_ab encode, 10,000 draws; median over 6 runs of each run's median, us a
draw; two exclusive holds of 3 interleaved passes): draw_offset d1 0.471, this 0.441;
draw_compositor d1 1.038, this 1.020 (draw_offset is bimodal by process).
- The resident-draws lane on the M3 Max, whole-process instructions over 5 frames (frame
median ms), d1 then this:
entry own encoder N 500 1.389e9 (8.4) 1.273e9 (7.1)
N 1000 3.249e9 (27.0) 2.787e9 (22.5)
N 2000 10.23e9 (108.6) 8.384e9 (90.9)
N 5000 57.47e9 (642.4) 45.91e9 (517.7)
entry own write N 5000 60.72e9 (752.8) 49.10e9 (597.8)
about 92 instructions fewer a resident use a draw; entry one encoder N 5000, 3 frames:
2.224e9, 2.221e9.
(cherry picked from commit a46fe23585cf0a1d3183349d64d68d6e650e8758)
(cherry picked from commit 6de4e38fbb2daec5f1e61cf0aaffefd356e51a0d)
|
||
|
|
7e01e2a5ac |
Trim an argument table's change log once in as many calls as it keeps, not at every call past it
What: `Changes::note` dropped the oldest calls whenever the log held more
than CHANGES_KEPT slots: once the log was full, nearly every call moved
the whole log down. It now lets the log grow to twice CHANGES_KEPT and
then drops the oldest calls at once, down to the newest calls of at most
CHANGES_KEPT slots. A call's slots are dropped together. A reader under a
stamp the log still holds reads the slots changed since, as before; one
under an older stamp reads the table whole, as before.
Why: the drain's memmove was 0.4% (draws.10k) and 1.3% (WS-like) of the
encoding thread's samples after the set-0 fix.
Test: a unit test (the_changes_log_keeps_the_newest_calls) notes 200
calls of one to three slots and checks after each one that every reader
under a stamp the log holds reads exactly the slots noted since, with
their offset marks; that every stamp whose calls since changed at most
CHANGES_KEPT slots is held; and that the log never holds more than twice
CHANGES_KEPT. Negative control: the cut not moved to a call boundary, the
test fails ("call 16, read before call 9": a slot of an earlier call
read).
Per draw on the encoding thread, release with thin LTO, 3 round-robin
rounds against the parent build, medians:
draws.10k 8558.4 -> 8437.3 instructions (-1.4%)
WS-like 20902.2 -> 20817.6 instructions (-0.4%)
The A/B ran beside a test suite on the same machine, so its times are not
quoted.
Device run (debug, --cfg m2v_gpu, MoltenVK on an M3 Max) at this commit:
the runtime's argument-table, encoder, draw-again, set-zero, rebind,
binding-view and stage-in tests, 97 of 97; the validation lanes for draws,
argument tables, rebinds and frame costs (runtime_lane::frame_costs among
them), 220 of 220. Clippy plain and with --cfg m2v_gpu (all targets, all
features) clean; cargo check --release --tests with --cfg m2v_gpu clean.
(cherry picked from commit 8a22e07a0049451555b3490d1205ca52ab728345)
(cherry picked from commit 2e303e79ab7c977a30355f21c312b9c7ccdf7efc)
|
||
|
|
253361e723 |
Tell what a buffer slot binds from its binding, without making its shape
What: `instantiate::bound_buffer` compared what a slot binds with the plan's kind through `BoundKind::of(shape(0))`, making the binding's whole shape to read three facts from it. `BoundKind::of_bound` reads them from the binding itself: unbound, bytes, or a buffer with its length class and whether it has a device address. In builds with debug assertions each answer is compared with `of`'s. The commands written are the same, so SEMANTICS_VERSION stays. Why: bound_buffer runs at every changed slot of a rebound draw and at every slot of an instantiation. Per draw on the encoding thread, release with thin LTO, 3 round-robin rounds against the parent build, medians: draws.10k 8561.1 -> 8558.4 instructions (-0.03%) WS-like 20928.9 -> 20902.2 instructions (-0.1%) Both are inside the rounds' spread: a small change, kept because it is correct and built. The A/B ran beside a test suite on the same machine, so its times are not quoted. Device runs (debug, --cfg m2v_gpu, MoltenVK on an M3 Max), over the stack through the BoundKind change, this commit among it: the runtime's argument-table, encoder, draw-again, set-zero, rebind, binding-view and stage-in tests, 97 of 97; the validation lanes for draws, argument tables, rebinds and frame costs (runtime_lane::frame_costs among them), 220 of 220. Clippy plain and with --cfg m2v_gpu (all targets, all features) clean. The translator suite (cargo nextest -p metal2vulkan --all-features) at the stack's tip, this change included: 3324 of 3324. (cherry picked from commit b9aad523d5756a0113600a32d097812db4e83d18) (cherry picked from commit 9061ca54b83f89276ba44f87b852dae1b6390215) |
||
|
|
4333b15b7e |
Bring in a buffer slot whose offset alone moved from the binding read before, without looking at the buffer
What: a table's change log now marks a call that kept the buffer bound at
a slot and moved its offset or attribute stride alone (`Changed::offset`:
`setBuffer:offset:atIndex:` of the buffer already bound there,
`setBufferOffset:atIndex:` over a bound buffer). Where every call since a
stage table was read changed a buffer slot that way,
`ArgumentTable::refresh_changed` brings it in from the binding read before
(`refresh_offset`): its space length and addresses kept, its offset the
space's base plus the new one, its stride the table's. The buffer's
`exposed_address` and `base_and_device_address` (a no-copy buffer's pages
lock, `HostCell::lying`) are not called: each was called when the binding
was read, and what they give holds while no no-copy buffer moved, which
every caller's read already requires (`live_bind::ReadFrom::reads` with
`host_cells_moved`). A slot any call since changed otherwise is read as
before (`refresh_buffer`).
Why: refresh_changed was 3.8% (draws.10k) and 6.3% (WS-like) of the
encoding thread's samples after the set-0 fix, refresh_buffer 3.1% and
4.7% of it, base_and_device_address and lying 1.7 to 1.9%.
Checks: in builds with debug assertions every binding so brought in is
compared with `bound_buffer`'s (the read whole), and refresh_changed's own
`check_reading` compares the table. `WorkCounts::bound_offsets_moved`
counts the slots so brought in (a new public field; api_signatures
blessed).
Per draw on the encoding thread, release with thin LTO, 3 round-robin
rounds against the parent build, medians:
draws.10k 8637.5 -> 8561.1 instructions (-0.9%)
WS-like 21388.2 -> 20928.9 instructions (-2.1%)
The A/B ran beside a test suite on the same machine, so its times are not
quoted. Slots brought in so (bound_offsets_moved) in one round: draws.10k
29880 of its 30000 draws, WS-like 20456.
Negative control: refresh_offset given the space's base for its offset,
the debug comparison fires in set_zero_at_offsets' two tests and
draw_again's draws_after_buffer_changes_rebind_what_every_step_binds ("a
buffer slot whose offset alone moved brought in otherwise than read
whole").
Device runs (debug, --cfg m2v_gpu, MoltenVK on an M3 Max), over the
stack through the BoundKind change, this commit among it: the
runtime's argument-table, encoder, draw-again, set-zero, rebind, binding-view
and stage-in tests, 97 of 97; the validation lanes for
draws, argument tables, rebinds and frame costs
(runtime_lane::frame_costs among them), 220 of 220. Clippy plain and with
--cfg m2v_gpu (all targets, all features) clean.
(cherry picked from commit 719e1e33505c015e3b88969daf9b075483ddbf44)
(cherry picked from commit cfda984944cc15bb10130f7fc9a04f9ec3a5087c)
|
||
|
|
29d14ce770 |
Rebind a draw's changed buffer slots without looking up the slots no call changed
What: `rebind_slots` (`BindingPlan::rebind_draw_slots_into`) looked up and
shape-checked every planned buffer slot's binding (`bound_buffer`) to find
each changed slot's place among the bound descriptor-form ones. A slot no
call changed binds what it bound, of the plan's shape (the method's
contract: the state differs only in what the named slots bind), and the
plan's `PlannedBuffer::bound` says whether it binds anything: its place is
counted from the plan, and only the changed slots are looked up. In builds
with debug assertions the unchanged slots are still checked against the
state (`bound_buffer`). The commands written are the same, so
SEMANTICS_VERSION stays.
Why: rebind_draw_slots_into was 8.2% of draws.10k's encoding-thread
samples after the set-0 fix, `instantiate::bound_buffer` 2.2% of it.
Tests: a device test, set_zero_at_offsets'
draws_that_move_the_second_buffer_s_offset_alone_are_rebound: 9 draws of
colored_vertex that move the colours' offset (slot 1) alone, the positions
(slot 0) bound as before, are rebound (draws_rebound > 0), record set 0
once (one bind, or one push where the variant pushes it), and draw the
last colour; in debug builds every second rebound draw takes
every step and checks it worked out the same commands. The translator's
a_rebind_of_buffer_slots_writes_what_an_instantiation_writes also rebinds
the constant slot alone (its fixture's vertex slot is fixed-function, so
it checks the commands, not the place count).
Per draw on the encoding thread, release with thin LTO, 3 round-robin
rounds against the parent build, medians:
draws.10k 8853.4 -> 8637.5 instructions (-2.4%)
WS-like 21368.4 -> 21388.2 instructions (+0.1%, inside the parent's
rounds' spread of 21356.5..21487.8)
The A/B ran beside a test suite on the same machine, so its times are not
quoted.
Device runs (debug, --cfg m2v_gpu, MoltenVK on an M3 Max), over the
stack through the BoundKind change, this commit among it (before the
push-aware expectation of eb250fedd0, which both tests then passed on
the M3 and on the RTX 5080): the
runtime's argument-table, encoder, draw-again, set-zero, rebind, binding-view
and stage-in tests, 97 of 97; the validation lanes for
draws, argument tables, rebinds and frame costs
(runtime_lane::frame_costs among them), 220 of 220. Clippy plain and with
--cfg m2v_gpu (all targets, all features) clean.
(cherry picked from commit cc8c2736027e0a2c03009974850fdb369c0434ad)
(cherry picked from commit 1081bd9c4e49097e98bc8c7dc370096ca3392f86)
|
||
|
|
2ad059be0c |
Expect one set-0 push, not one bind, where draws at moved offsets push their set 0
What: set_zero_at_offsets (b875660ecb) expected the draws that move only a storage buffer's offset to bind their first draw's set 0 once (set_zero_sets_reused DRAWS - 1, one vkCmdBindDescriptorSets) and draws of their own buffers to bind a set each. Where the variant pushes its set 0 (WorkCounts::draws_pushing_set_zero: a device of Vulkan 1.4 or VK_KHR_push_descriptor whose set 0 a push descriptor set layout holds) no draw binds a set. The first draw's push carries its writes, and a later draw's push carries only the writes that differ from what set 0 holds (render/bound.rs). The test now takes the variant's draws as pushing all or none, and expects one vkCmdPushDescriptorSet for the draws at offsets and one per draw for the draws of their own buffers. Where set 0 is bound, the expectations are as before. The module docs say both. Why: on the RTX 5080 laptop GPU (Linux) the draws push set 0, and the test failed with (reused, binds) = (0, 0) against (8, 1). It drew the right texels. The counts there, draws.10k round of 30000 draws: pushes 30000 -> 120 and writes pushed 30006 -> 126 with the set-0 fix. Verified, debug, --cfg m2v_gpu: on this M3 Max (MoltenVK binds set 0) both set_zero_at_offsets tests pass; on the RTX 5080 (set 0 pushed), at the stack's tip with this change (the next commits' second test included), the runtime's set-zero, binding-view, range, rebind, argument-table, encoder, draw-again, device, enables, attribute and stage-entry device tests pass, 124 of 124. Clippy with --cfg m2v_gpu clean. (cherry picked from commit eb250fedd03dd0d79ebe5834f9ee15e473ff7158) (cherry picked from commit da992ace21cc44f2960c623a2eaa00b489a805de) |
||
|
|
0a0a03b8a8 |
Check a stage's function tables and offsets over its own buffer slots, and none where the table binds no function table
What: `ArgumentTable::check_function_tables` and `check_offsets` walked every slot of the pipeline's interface (every stage's, every class) to find the stage's buffer slots. They now take the stage's buffer slots alone, a range of the interface's map (`buffer_slots`: the map orders slots by stage, class and index). check_function_tables returns at once where the table binds no visible-function table and no offset made one null (`function_tables`, `null_tables` both empty): its refusal needs one of them at the slot, so no slot is refused, and the answer is the loop's. No answer changes, so there is nothing to count or cross-check. Why: check_function_tables was 3.3% of draws.10k's encoding-thread samples after the set-0 fix, a walk of every slot twice a draw (vertex and fragment) for a table that binds no function table. Verified with the stack's device run (below). Per draw on the encoding thread, release with thin LTO, 3 round-robin rounds against the parent build, medians: draws.10k 8993.9 -> 8822.2 instructions (-1.9%), 468 -> 455 ns WS-like 21525.4 -> 21343.1 instructions (-0.8%) Device runs (debug, --cfg m2v_gpu, MoltenVK on an M3 Max), over this commit and the stack's next ones through the offset-only bring-in: the runtime's argument-table, encoder, draw-again, set-zero, rebind, binding-view and stage-in tests, 97 of 97; the validation lanes for draws, argument tables, rebinds and frame costs (runtime_lane::frame_costs among them), 220 of 220. Clippy plain and with --cfg m2v_gpu (all targets, all features) clean. The body of f6a2518856 (the per-stage push) names robust-access tests among that device run; it had none: its runtime tests are the ones named above. (cherry picked from commit 2a1fed3292495514d40ee3e3e16d8ca171478902) (cherry picked from commit 34bfc52b8d7de992a58f551777c5e89fb56561f4) |
||
|
|
364ac7933c |
Push only the stages whose push-constant write changed since a draw's last push
What: `Bound::pushes` answered whether a draw's push constants differed
from the last push's, and the draw then pushed every write. It now answers
which writes to push (`Pushed`): every one where the last push was of
another layout or of other writes (their count, or a write's stages, offset
or length); else those whose bytes differ, and each later write that
overlaps one of those for a stage both name, which a push of all of them
would leave its own bytes over. Push constants update incrementally
(vkCmdPushConstants: "causing shader stages in stageFlags to read the new
data from pValues for push constants modified by this command, while still
reading the previous data for push constants not modified by this
command"), so every stage reads what a push of every write would leave it.
The comparison is a slice compare per write (it was a byte-by-byte
iterator over all of them). Both callers push only the writes it names:
`Recording::record` (render.rs) and, at its call site alone,
render/executions/gpu.rs (the ICB stream's file; nothing else there
changed).
Why: after the set-0 fix a draw that moves only a vertex buffer's offset
changes only the vertex stage's residual, yet both stages' writes were
pushed: 60000 vkCmdPushConstants in a draws.10k round of 30000 draws.
Checks: in builds with debug assertions `check_pushed` models every stage's
push-constant bytes and asserts that the writes pushed leave each byte a
write sets what a push of all of them leaves (allocation-free, the last
push's bytes kept in storage of the record's own, so a draw allocates as
many times as without debug assertions: runtime_lane::frame_costs). A unit
test (`a_push_carries_the_writes_that_changed`) covers the same bytes,
each stage's write alone, another layout, other lengths, and a later write
overlapping a changed one. Negative control: the overlap rule dropped, the
unit test fails in check_pushed ("leaves stage bit 4 reading another byte
8").
Counts, one round (vkCmdPushConstants): draws.10k 60000 -> 30003, WS-like
8000 -> 4008.
Per draw on the encoding thread, release with thin LTO, 3 round-robin
rounds against the parent build, medians:
draws.10k 9184.3 -> 8993.9 instructions (-2.1%), 477 -> 468 ns
WS-like 21704.7 -> 21525.4 instructions (-0.8%)
Device runs (debug, --cfg m2v_gpu, MoltenVK on an M3 Max), over this
commit and the stack's next ones through the offset-only bring-in: the
runtime's argument-table, encoder, draw-again, set-zero, rebind, binding,
robust-access and stage-in tests, 97 of 97; the validation lanes for
draws, argument tables, rebinds and frame costs
(runtime_lane::frame_costs among them), 220 of 220. Clippy plain and with
--cfg m2v_gpu (all targets, all features) clean.
(cherry picked from commit f6a2518856e4fb5f4a17ab93b61de0394afec8d5)
(cherry picked from commit 9336e9233e6e22e7e66c6a24903372616563bf8d)
|
||
|
|
b2df1add01 |
Bind a storage view of a whole buffer from its space's start, so draws that move only an offset keep their set 0
What: `bind::instantiate::planned_range` gives a descriptor-form slot read through a storage view of its `Whole` window the range from the start of the bound buffer's space to its padded end, whatever the bind offset, and the bind offset as its `SlotBindOffset` residual. `bind_buffers` (every draw's and dispatch's instantiation) and `rebind_slots` (`rebind_draw_slots_into`) take it. Every other slot keeps `descriptor_range`'s range: uniform views (whose `RangeAtBindOffset` specialization reads a range from the bind offset), bounded windows, and a storage view whose range from 0 would pass the view's `maxStorageBufferRange` (`PlannedBuffer::max_range`) or 2^32 bytes (a 32-bit residual and offset), or whose bind offset lies at or past the padded end. The tessellation factor and index bindings keep it too. Why: `EncoderCore::set_zero_of` was 14.3% (draws.10k) and 8.8% (WS-like) of the encoding thread's samples: every draw allocated, wrote and bound a set 0 of its own. A `device T *` slot's range started at the bind offset aligned down, so each new offset wrote another descriptor and neither `LastSetZero` nor `SetCache` could match. Vulkan: the descriptor's offset is the space's start (256-aligned, as a bind at offset 0 has it today) and its range ends where today's ends (the padded end), so offset + range, and a dynamic binding's effective offset + range (VUID-vkCmdBindDescriptorSets-pDescriptorSets-01979), are what they were. dynamic_writes moves that same start into the dynamic offset for every bind offset. The range is explicit, never VK_WHOLE_SIZE (06715 does not apply). Hazard ranges are untouched: they come from the plan's use ranges from the bind offset (`binding::bytes_use`). Behaviour: a Metal offset m from the bind offset reads byte residual + m of the range, the same byte as before for every access inside the window. An access that reaches back before the bind offset (a negative index, the 32-bit offset wrapping) and lands in the buffer's space now reads and writes the buffer's bytes there, as Metal's does; before, it lay outside the descriptor range unless it stayed within the alignment's residue. On a device with robustBufferAccess (or under in-shader containment against the view's size) accesses are bounded by the larger range [space start, padded end) instead of [bind offset aligned down, padded end): such an access before the bind offset is in range and reaches the buffer's bytes where it was a robust out-of-bounds access (a zero, a value from within the buffer, or a dropped write). Accesses past the end are bounded as before. SEMANTICS_VERSION 1957 -> 1958: instantiated descriptor ranges and residuals change. golden_hashes_match_the_table passed unchanged here (it hashes compiled modules, which this does not change); the re-bless on development decides. Tests: planned_range's unit tests (the range from 0 and the residual at every 4-byte offset for base alignments 16, 64 and 256, and a 2^32-byte buffer at its last word; each fallback equal to descriptor_range's answer). A device test, set_zero_at_offsets: 9 draws of colored_vertex moving only two device buffers' offsets reuse 8 sets and bind 1, and draw what 9 draws of buffers of their own draw (0 reused, 9 bound). dynamic_multi_variable's moved-offset dispatches now reuse their predecessor's set (7 of 8) and still answer Metal's values from each dispatch's own offset. docs/API.md states the range. Verified: the translator suite, 3324 of 3324 (plain). On the M3 Max (MoltenVK 1.4.2), debug, --cfg m2v_gpu, under maclock and memcap: 96 of 96 runtime tests (fix 1's set plus set_zero_at_offsets, dynamic_multi_variable, uniform_bind_offsets, binding_view, range, rebind_descriptor_slip, rebind_behind_a_wait, depth_ranges, attributes), and 220 of 220 validation lanes under the validation layer (fix 1's set plus stage_in_regions, stage_in_strides, padded_loads, escaped_slots, absent_reads, chosen_pointers, dispatch_*, read_through_views, guarded_effects, index_fetches, first_vertex, vertex_strides, host_bytes, pointer_uploads, commands_recorded, runtime_lane::tests, among them renders::public_render_cases_match_metal and tests::stage_in_region_cases_match_metal). Negative control: planned_range forced to fall back fails set_zero_at_offsets ((0, 9) against (8, 1)) and both dynamic_multi_variable moved-offset tests ((0, 0) against (7, 0)). clippy plain and with --cfg m2v_gpu clean. Per draw on the encoding thread, release with thin LTO, 3 interleaved rounds against the parent build, medians: draws.10k 11201.7 -> 9212.4 instructions (-17.8%), 616-661 -> 485-495 ns WS-like 23121.1 -> 21752.5 instructions (-5.9%) One round's counts: draws.10k 0 -> 29880 sets reused, 30000 -> 120 vkCmdBindDescriptorSets, 6 -> 60000 vkCmdPushConstants (the residuals; both stages' writes are pushed where either changes); WS-like 0 -> 3744 sets found in the command buffer's cache, binds unchanged at 4000. (cherry picked from commit b875660ecbad7dd6f9dfa9f976ef1c2b32bded1e) (cherry picked from commit b09293e9c22d80e4ae4c505b00ba0e07e6a8165c) |
||
|
|
cc6b083fc2 |
Let what every write route of a command buffer may write reach every buffer it made resident for writing
What: what an indirect command buffer's records may hold (WrittenCommands, command_writes) took a writer's writes only from the encoder that made the buffer resident for writing (Writers: the state set then, each set after, and that encoder's executions). The routes that mark the buffer (write_routes.rs) were already the command buffer's. Routes now keeps what all of its routes may write (states set in any encoder, before the residency or after it, and what executed buffers' records may name) and adds it to every buffer made resident for writing, at the call that brings either; an encoder opens with what the ended ones met. For two encoders open together (a parallel render encoder's) the commit adds what each did not see of the other, and the followers that sets off are marked outside the command buffer's lock, as the commit's marks are. Writers is gone: Routes holds a superset of what it held. Why: Metal runs what a kernel wrote with the buffer resident for writing in any encoder of the command buffer, before the kernel's or after it (the probe icb_routed_writes.m, M3 Max, macOS 27.0.1). The marks matched that; the summary did not, and an execution of a buffer that inherits the encoder's state decides on the summary whether the GPU alone runs it, as draws of the one primitive type it allows. With the residency in another encoder than the kernel's, the GPU alone ran the kernel's point as a draw of the CPU's triangles, which drew nothing (the previous commit's lane). The bug is older than the write routes: the summary was per encoder before them too. What it moves: an execution of a buffer whose command buffer sets, in another encoder than the one that made the buffer resident, a state that may write what the GPU-alone forms rule out: a render execution takes the host step where that state may write more than draws of one primitive type, buffers, resets and cleared barriers; a compute execution in a concurrent encoder orders its commands where it may set a barrier, and a checked one calls its check where the records may name a state that may encode. The lanes that made a buffer writable with a state set in an encoder of its own (indirect_host_steps::encoding_state_set: icb_replay_encode's, which may set pipelines, dispatch, set threadgroup lengths and barriers) showed it: with it, 6 of the 480 tests of the 40 modules changed (render_merged_executions' GPU forms into a shadowed target took the host step, 6 executions; five dispatch_executions tests saw barriers, check calls and a host step), all others as before, resident_draws among them (its writer and residency share an encoder: no host step on its write path, its chunks kept). Those lanes are about the GPU-written path, not about what the state writes, so the lever now sets icb_reset_encode's state (resets alone, which no GPU-alone form rules out). Docs: written_commands.rs and write_routes.rs module docs, IndirectCommandBuffer::command_writes, render/executions/gpu.rs, the runtime README and docs/API.md section 10. How verified (debug, --cfg m2v_gpu, M3 Max under MoltenVK): runtime_lane::write_routes passes (it failed before this commit: After and Before drew no point); the 39 ICB lane modules and write_routes, 480 tests, pass with the reset lever; the runtime's tests::write_routes_device::a_route_reaches_every_buffer_its_command_buffer_made_writable (new: a later encoder's state, one set before the residency, and a parallel encoder's at the commit) and tests::written_commands pass; clippy -D warnings with --cfg m2v_gpu is clean. (cherry picked from commit 7d13a4dee21162a972b40fd9868e3e2f9112a677) (cherry picked from commit 13b9646e48b767defdd189bf156a2a9130b3b857) |
||
|
|
e924d293c5 |
Compare against Metal what an execution runs of commands a kernel wrote, by where the command buffer made the buffer resident for writing
What: a new owned fixture, icb_routed_writes, whose kernels write command 0 of an indirect command buffer: a render command with its state taken from the argument buffer (irw_encode_draw), a render command of a buffer that inherits the encoder's state, a point at the target's centre beside the CPU's triangle in command 1 (irw_encode_point), and a compute command with its state from the argument buffer (irw_encode_dispatch). A Metal probe (crates/metal2vulkan-conformance/probes/icb_routed_writes.m) and a lane (runtime_lane::write_routes) run the same four shapes: the buffer made resident for writing in the kernel's encoder, only in an encoder after it, only in one before it, and nowhere; a later encoder of the same command buffer executes the buffer. Why: the marks of a buffer the GPU may write are the command buffer's, while what its records may hold was gathered per encoder. The lane asks whether an execution runs what the GPU wrote, with the right state and pixels, wherever the command buffer paired the residency with the writer. Metal's answers (the probe, M3 Max, macOS 27.0.1, validation off, verified): in the kernel's encoder, after it and before it, all three kinds ran the kernel's command (green, green, words 0x100 to 0x103). Nowhere: the render command and the point did not run (the CPU's records: red), the compute command did. docs/API.md records that last difference: no encoder of the command buffer made the buffer resident for writing, which Metal's contract asks of a function's write, and the runtime runs the CPU's records there (APART in the lane). How verified: the lane, debug with --cfg m2v_gpu on the M3 Max under MoltenVK, fails at this commit, which is the bug the next commit fixes: [(Same, [true, true, true]), (After, [true, false, true]), (Before, [true, false, true]), (Nowhere, [false, false, false])] against Metal's (with the compute command apart), the inherited state's executions taking 2, 0, 0 and 0 host steps: with the residency in another encoder than the kernel's, the GPU alone ran the kernel's point as a draw of the CPU's triangles, which drew nothing. The render command and the compute command ran right in every shape. (cherry picked from commit 25134688d13d1abedab5e3ee5e1ff4c9db442a90) (cherry picked from commit ba7f047a7987a63a9e1f6fd78ae7093f27326e55) |
||
|
|
a5a93374b9 |
Have the lanes that ask for records the GPU may write set a state that may encode, and pin a write use without one
Under the write routes a write use of an indirect command buffer lets the GPU write its records only beside a state that may encode indirect commands. Five lanes made a buffer resident for writing with no state, to reach the host step or the GPU-alone form: dispatch_executions' `writable`, render_resident_writes, buffer_texture_renders' `Writer`, render_merged_executions' run without a kernel, and topology_classes' GPU-written execution. `indirect_host_steps::encoding_state_set` sets `icb_replay_encode`'s state, made without `supportIndirectCommandBuffers` so no record names it, in an encoder of its own that runs nothing. Each of those lanes calls it before its write use. Because the state is set in another encoder, what the records may hold gains nothing of it (`command_writes`), so each lane's path is the one it took before. Both sides of the contract are pinned: - The flag test, renamed the_gpu_written_flag_is_set_by_a_write_use_beside_an_encoding_state_or_a_blit_into_it, finds the flag clear after these, each still clear once its command buffer completed, with one unmarked residency counted per commit: - a read use beside an encoding state; - a write use alone; - a write use beside states that cannot encode (`icb_replay_template`'s). - It finds the flag set at the call that completes the route: - an encoding state, then a write use; - a write use, then an encoding state; - a read-and-write use; - a state set in a later encoder of the command buffer; - a blit copy or reset, as before. - topology_classes adds a write use with no encoding state. Its execution is recorded at the commit and announced there, as one of a buffer made resident for nothing. Verified with the commit before this one (debug, --cfg m2v_gpu, this M3 Max on MoltenVK): the 39 lane modules that execute indirect command buffers, 479 tests, all pass; clippy -D warnings of the validation crate, all targets and features, under --cfg m2v_gpu. (cherry picked from commit 4bdc9850a21dbf0f69416e527b77b6e03aae5e65) (cherry picked from commit 28623bca3ae5338cce09e46accafc80e3fe74c8f) (cherry picked from commit b5fc188d9365f3a06d0c05404977d6c7750fb152) |
||
|
|
f35128eb43 |
Mark an indirect command buffer at the call that completes a write route, and let the routes go at the commit
The write routes marked a buffer at its command buffer's commit. An execution's segment is cut into a part of its own, which waits for the work before it, as it is encoded (`Segment::host`, from `gpu_written` then), so an execution encoded after the writer in the same command buffer, in its encoder or a later one, was recorded with the writer's part and ran the CPU's records: indirect_host_steps' commands_a_kernel_writes_run_after_it and 19 other lanes drew nothing. The routes now mark at the call that completes the pair: a write use where a state that may encode, or an execution whose records may name one, was met in the command buffer; such a state set, or such an execution encoded, where a write use was. An encoder opens with what its command buffer's ended encoders met (`Routes::carried`), so a later encoder's execution is encoded as one the GPU may write, as it was when a write use marked the buffer at its call. The commit still decides again from what the records name then, and still leaves the followers. The command buffer's routes held each buffer made resident for writing or executed until the command buffer itself dropped, past its completion: a released buffer's range and resource ID stayed taken (indirect_command_buffers' buffer_identifiers_follow_metal_s_encoders, resource_ids' an_indirect_command_buffer_s_id_is_held_as_metal_holds_it). The commit now clears them once it decided; what it leaves unmarked is held until completion, as before. Docs: the gpu_written contract, write_routes.rs, docs/API.md and the runtime README say when. Verified with the lane commit after this one (debug, --cfg m2v_gpu, this M3 Max on MoltenVK): the 39 lane modules that execute indirect command buffers, 479 tests, all pass, where B alone failed 35; the runtime's written_commands, degradation, degradation_catalogue and degradation_sites unit tests pass; fmt; clippy -D warnings of the runtime and validation crates, all targets and features, under --cfg m2v_gpu. (cherry picked from commit e8e85c6936ecc731fa557440033ac9d3e40953e2) (cherry picked from commit 106af168144e7a76fcc5366e39fec10a3693611c) (cherry picked from commit 38605155f851abdf697c818c5387c1980af6a0bd) |
||
|
|
66c9163ce3 |
Mark an indirect command buffer written by the GPU only where a route that may write its records meets it
A write residency of an indirect command buffer (useResource:usage: with MTLResourceUsageWrite) marked it written by the GPU at the call, whatever the encoder's functions could do. Every execution of it then waited for the work before it and was recorded by a host step, and kept no chunk. A page whose kernel only counts, with the buffer made resident for writing, paid the host step every frame (51 to 61% of the write frame in the kept-steps measurement), though no function of it can reach a record: a function writes records only through an indirect-command operation. The mark now comes from the routes that can write records (write_routes.rs), decided by structure alone: - the commit of a command buffer that made the buffer resident for writing in any of its compute or render encoders (residency is the command buffer's) and also set, in any of them, before or after, a pipeline state whose functions' indirect_command_writes is not empty (the translator's answer from their AIR: the indirect-command operations their bodies may call, every one where a body makes a call the translator cannot see into), or executed commands whose records may name such a state; - after a commit that found neither, the first CPU or GPU write that leaves such a state in the records of a buffer it executed (the executed buffers hold the commit's unmarked buffers weakly until then, released as the command buffer completes; the marks run once the setter let its locks go); - a blit's copy into the buffer or reset of a range in it, at the call, as before. A heap holds no indirect command buffer and residency sets are refused, so neither is a route. The mark is for good, as before. It keeps the route that met the buffer first, which the host-replay notice names: for a state, its functions' names and the kinds of indirect-command operation they may call; else the route. WorkCounts::indirect_write_residencies_unmarked counts each commit's write-resident buffers it left unmarked. The resident_draws fixture gains rd_encode, a kernel that may reset a command and resets none, regenerated with scripts/regen-air-fixtures; the lane's `encode` path uses it, off the measured paths. Docs: the gpu_written contract, the runtime README, docs/API.md (the catalogue's HostReplayedIndirectCommands trigger and cost, and the contract), the module docs that named the old rule. api_signatures.tsv blessed (one field). Verified (debug, --cfg m2v_gpu, this M3 Max on MoltenVK): the resident_draws lane's three tests pass: a kernel that cannot encode (rd_touch) leaves the buffer unmarked, with no host step in any of three frames, its two chunks run from the kept recording in the third, one unmarked residency counted a commit, and the read path's pixels; a kernel that may encode (rd_encode) marks it at the first commit, a host step every frame, no chunk kept, the same pixels, and the notice names rd_encode and its reset; every path draws the encoder's pixels. Negative control (neg.py: every state counted as calling no operation, and no executed buffer's records as naming one): the encoding test fails (no host step in frame 0), the other passes. The runtime's written_commands (a new test of the followers), degradation, degradation_catalogue and degradation_sites unit tests pass. fmt; clippy -D warnings of the runtime and validation crates, all targets and features, under --cfg m2v_gpu. (cherry picked from commit 6e1b62a03039dd81a2005afa26a3001de2064110) (cherry picked from commit 13dac865f4096559a5b97841d893e1da02e160ec) (cherry picked from commit 862a72c76e82b657ef158ee1c7cbf789240ea745) |
||
|
|
152987eb54 |
Read a wrapped macro argument as part of its member in the API signatures
The nightly's rustfmt wraps ir_id!(TypeId, "t") one argument per line, so the signature script, which reads a macro call's members line by line, derived `TypeId,` where the table holds `TypeId, "t"`, and api_signatures failed with nothing public changed. A member line that is only an identifier and a comma now takes the literal on the next line with it, which reads the wrapped call as the unwrapped one did; a member with more on its line (Degradation's rows, whose prose follows on its own line) is read as before. Verified: signatures.py --check passes with the committed table unchanged, on this tree and on bc127dbec3's pre-nightly sources; metal2vulkan's api_signatures test passes on the nightly. |
||
|
|
bc05f43aa0 |
Find the device tests' compile worker above the test binary in any Cargo layout
The nightly's Cargo builds with its newer build-directory layout: a test binary now sits in target/<profile>/build/<package>/<hash>/out/, not target/<profile>/deps/, while the package's binaries are still copied up into target/<profile>/. compile_worker() took the test binary's grandparent, which now names build/metal2vulkan-validation/<hash>/corpus-pipeline, a file that does not exist, so every device test compiling through the worker would panic. It now takes the first corpus-pipeline above the test binary, which is target/<profile>/corpus-pipeline in either layout. reims-vgpu found the layout change in its own C API tests. Verified on the M3 Max (--cfg m2v_gpu, MoltenVK, under the Mac GPU lock): candidate::tests::engine_compute::a_store_runs_through_the_binder_under_the_validation_layer passes; the old formula's path is absent from the built target. |
||
|
|
7d14d60cad |
Keep each worktree's target directories inside it, where kache shares incremental state
kache 2.0 imports a crate's incremental state from another worktree's target only when both
targets sit inside their worktrees: a CARGO_TARGET_DIR outside its worktree is attributed to the
target's parent directory instead, and neither gives nor takes. AGENTS.md and CONTRIBUTING.md
now say so: target/ (Cargo's default), and target/gpucfg for --cfg m2v_gpu builds, as CI and
docs/VALIDATION.md already name it.
Verified on the M3 Max at
|
||
|
|
7dbedfd151 |
Iterate the pull-model lane's colour attachments instead of indexing them
The nightly's clippy (needless_range_loop) flags the index loop, which compiles only under --cfg m2v_gpu, so the earlier sweep's plain clippy did not see it. Verified: RUSTFLAGS='--cfg m2v_gpu' cargo clippy --workspace --all-targets --all-features -- -D warnings clean on nightly-2026-11-03. |
||
|
|
a1e7576139 |
Escape the pipes inside a code span of routine.rs's frexp table
The nightly's rustdoc reads an unescaped | inside a code span of a Markdown table row as a column
separator ("table row has too many columns", an error under -D warnings). Escaped as \|, it
renders as before.
Verified: RUSTDOCFLAGS='-D warnings' cargo doc --workspace --all-features --no-deps clean on
nightly-2026-11-03.
|
||
|
|
18f5d1459d |
Pin the runtime sources after the nightly toolchain's lint rewrites
Re-hashes crates/metal2vulkan-validation/runtime-sources.sha256 for |
||
|
|
64b4e42d75 |
Build on nightly-2026-11-03 with rustc's parallel front end, kache and incremental builds
The owner asked for a nightly toolchain, -Zthreads, kache 2.0 with its incremental cache, and Rust's incremental compilation on. - rust-toolchain.toml pins nightly-2026-11-03 (rustc 1.101.0-nightly 1c3a65069), dated so every machine runs one rustc, clippy and rustfmt. The published crates keep rust-version 1.98, which this build no longer checks by itself (clippy's incompatible_msrv still flags newer std items). - .cargo/config.toml passes -Zthreads=0 (a thread per core) through Cargo's profile rustflags, which add to RUSTFLAGS instead of being replaced by it, so `--cfg m2v_gpu` lanes and CI's -Dwarnings keep it. - scripts/rustc-wrapper hands each compile to kache where kache is on PATH outside CI, and to rustc otherwise; `RUSTC_WRAPPER=` (empty) builds without it. - CARGO_INCREMENTAL=0 is gone from scripts/device-lane, AGENTS.md and CONTRIBUTING.md. - CI installs the toolchain the file names; both Dockerfiles take the same nightly. What the nightly asked of the code: - Its standard library containers take more trait-solver levels (Box -> BoxRaw, RawVec -> PhantomData), so proving a RenderCommandEncoder `Send` from a program's crate ran past the default recursion limit (tests/consumer_auto_traits.rs failed, a future-incompat lint that will become an error). The encoder now holds its own lowering in `OwnLowering`, whose `Send` impl is written out over a compile-time proof that `RenderLowering` is `Send`, as `LoweringSlot` already was. The runtime crate's own proofs need recursion_limit 256. - New clippy lints: needless_range_loop, single_element_loop, new_instead_of_clear (a false positive on a moved-from Vec: the part's segments are now taken explicitly), needless_borrows_for_generic_args, redundant_closure, unnecessary_lazy_evaluations, manual_range_patterns; AtomicU64::fetch_update is deprecated for try_update (present in 1.98). - Cargo warns that `homepage` equals `repository`: homepage removed from the manifests. - nightly rustfmt formats ir_id! invocations one argument per line. Verified on the M3 Max: `cargo clippy --workspace --all-targets --all-features -- -D warnings` clean on the nightly; `cargo build -v` shows -Zthreads on every rustc invocation and scripts/rustc-wrapper in front of each. |
||
|
|
bc127dbec3 |
Pin the runtime sources after the window of chunks imported ahead
Re-hashes crates/metal2vulkan-validation/runtime-sources.sha256 for the host RAM import window. |
||
|
|
c9bbf3513e |
Bump RUNTIME_VERSION to 1762: a used host RAM's chunks imported in a window ahead of the objects
The device's thread now imports one chunk ahead after a jump and four along a run, not the whole RAM (the cherry-pick of 6d72e50ebb), which changes which chunks a recorded run finds imported ahead, so recorded runs are held to the new version. |
||
|
|
968ccc4af0 |
host_ram: import a window of chunks ahead of the objects, not the whole RAM
What:
- The thread Device::use_host_ram starts now keeps a window of chunks past the one an object
last took imported (host_ram.rs, Window): one chunk after a take outside the window (and the
RAM's first chunk before any take), AHEAD_CHUNKS = 4 once a take lands inside it. It never
imports past the window, never goes back to the RAM's start, and so faults in at most 4
chunks (256 MiB) that no object took for one take, and at most 1 for a take that starts no
run. While its window is imported it waits (Wake: a mutex and a condition variable), woken
when an object takes another chunk or the use ends, holding the device and the RAM only
weakly, as between chunks before.
- Unchanged: the pacing (SCHED_BATCH, yields, MADV_POPULATE_WRITE in 2 MiB steps), imports with
the memory lock released, the stop a quarter short of maxMemoryAllocationCount and the
give-back of untaken chunks.
- Docs: host_ram.rs, Device::use_host_ram, WorkCounts::host_ram_chunks_imported(_ahead),
docs/HOWTO.md ("One run inside one chunk"), with the numbers below and the burst caveat.
Why: reims-vgpu's time to first present on the RTX 5080 laptop went from 11-12 s to 13.9-86.1 s
with the whole-RAM ahead import, worst at low MemFree, the normal state of a Linux desktop
whose page cache fills memory. Reproduced without a VM (release probe, public API: 16 GiB of
fresh memfd RAM under MADV_HUGEPAGE through use_host_ram, an mmap+munmap sampler, CPU-bound and
bandwidth-bound workers, a toucher faulting its own THP memory, vmstat and PSI):
- The whole-RAM import took 40.4 s at 35.4 GB free with only 21 free 2 MiB blocks, and 57.4 s
at 17.1 GB free: pgmigrate 4.1-9.1 M pages, PSI memory "full" 6.6-9.6 s, another thread's
mmap up to 0.96-1.19 s, another thread's 2 MiB faults up to 0.8 s at p99 0.48 s, a CPU-bound
worker up to 51% slower at p50 and a bandwidth-bound one up to 128%.
- 99% of it is the fault-in of fresh huge pages (direct compaction and reclaim, holding the
process's memory map lock): per chunk p50 39-123 ms, worst 1.46 s. The import itself (pin and
vkAllocateMemory) of a resident chunk took 1.7-3.2 ms at p50 (0.56 s for 248 chunks).
- So the thread now faults in only what the objects are about to reach.
Measured on the same laptop (NVIDIA 615.71.09, Linux 7.2), release, one run each, MemFree
1.7-3.0 GB with 82-88 GB of page cache. Pattern: 40 2 MiB heaps at use_host_ram, then 8 bursts
of 128 consecutive heaps (4 chunks) 1 s apart, 2.08 GiB in all, with a toucher writing 1024
2 MiB pages spread over the same RAM (the guest's own faults):
ahead own imports making max (after the first 40) PSI full
adaptive (this) 36 2 26.9 ms 0.97 s
fixed 4 36 2 6.6 / 171 ms (2 runs) 0.48 / 0.97 s
fixed 1 9 26 372 / 614 ms (2 runs) 2.1 / 2.9 s
none (no thread) 0 34 544 ms 1.14 s
whole RAM (cut at 40 s) 138 2 194 ms 14.6 s
The 2 own imports are heaps 0 and 32, made as use_host_ram starts. 16 heaps over scattered
chunks, 300 ms apart: chunks faulted ahead adaptive 16, fixed 1 16, fixed 4 38, fixed 16 46;
making p50 adaptive 99 ms, fixed 1 51-60 ms, fixed 4 61-135 ms, fixed 16 160 ms, none 28 ms
(states vary run to run). A window of 8 or 16 bought nothing more for consecutive heaps and
cost more (16: PSI full 1.5 s, guest-fault p99 134 ms). A burst that runs more than 4 chunks
past the last take waits at each chunk past the window, one fault-in each (45-70 ms at p50 in
that state, at worst 0.34 s).
No DevicePolicy switch: this trades speed for speed, and no measurement favoured the whole-RAM
form.
Tests:
- host_ram::tests::a_take_inside_the_window_opens_it_and_one_outside_gives_one_chunk (the rule)
and ::the_devices_thread_imports_the_window_past_the_last_take_and_no_more (the order: the
start's one chunk, the window past a take, a held chunk passed, nothing past the window or the
RAM's end, nothing back after a jump).
- tests::host_ram_device::the_window_ahead_moves_with_the_objects_and_imports_no_more: fresh
THP RAM of 16 chunks; the first chunk alone before any take; a full window once a heap takes
it; a run of heaps over the window imports nothing on its own thread; one chunk past a jump;
a full window again once the run goes on; nothing past the RAM's end; the skipped chunk never
imported. 14 chunks ahead, 1 by an object, over 259 heap makings, on both devices.
- chunks_are_imported_ahead_so_no_making_waits_for_one and
the_ahead_thread_leaves_the_allocation_limit_to_the_objects now open the window with a heap
over the first chunk; the limit test gives back the 3 chunks no object took.
Negative controls (a temporary build with one defect switched on at a time, M3, release,
--cfg m2v_gpu); each test failed as follows:
- whole-RAM order (next_ahead wrapping as before): the order unit test ("none past the start's
one chunk", Some(1)); the window device test ("the device's thread went on past the window",
16 chunks).
- a fixed window of 4 for every take: the rule unit test (Window { from: 10, chunks: 4 } after a
jump); the window device test (13 chunks ahead after the jump).
- the window one slot off: the window device test ("no chunk past it", 6 live).
- no wake when an object takes another chunk: the window device test ("a full window past the
take", 1).
- no thread: chunks_are_imported_ahead_so_no_making_waits_for_one ("the device's thread
imported the RAM's first chunk", 0).
- no give-back: the_ahead_thread_leaves_the_allocation_limit_to_the_objects ("the untaken
chunks went back", 0).
- with no switch, the same binary passes the window device test.
Verified:
- RTX 5080 laptop, release, --cfg m2v_gpu: the host_ram and allocations tests, 30 passed,
0 failed.
- M3 Max (MoltenVK 1.4.2, macOS 27.0.1), release, --cfg m2v_gpu, under maclock: 28 passed,
0 failed (the two dma-buf tests are Linux-only).
- cargo clippy --workspace --all-targets --all-features -D warnings, plain and with
--cfg m2v_gpu; cargo doc -p metal2vulkan-runtime with -D warnings.
(cherry picked from commit 6d72e50ebb7d52e195fea5062bfed989af2877d4)
|
||
|
|
a0aebfe5a9 |
Re-bless the conformance cost records on the M3 Max at a8346f9a01, with the new event-wait case's cost and timing
Measured on the M3 Max (macOS 27.0.1, MoltenVK 1.4.2), with a debug build of a8346f9a01's tree, each under a maclock hold: - cost --runs 8 --write over the whole set: 1128 cases, the same 9 stopping where their records say. 780 records moved. - cost --runs 8 --alone --write over the 780 moved cases and event-wait-behind-a-running-signal: 781 measured. - times --runs 8 --write over event-wait-behind-a-running-signal. The instrument read this host as busy (other work ran on it), so the figures are advisory. What moved: - event-wait-behind-a-running-signal is newly covered ( |