2137a20004e2b5658aedd0bdfdafc99e043606ce
1530
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
44ae958d95 |
Name the summary a segment's footprint share takes SegmentShare
Taken, the name d862eadd34 gave it, is already imported into command_buffer/mod.rs (rebind::Taken), which failed the build (E0255). Verified: the M3 CPU job's build failed on the clash; the job that follows rebuilds. (cherry picked from commit 5d8a92a68c40604e3d32becc41a11d5d5be989ec) |
||
|
|
44c2bf6614 |
Print the scheduler's passes and the footprints built in each replayed frame
The replayed-frames lane's line gains scheduler_passes and footprints_built, so a frame shows how many passes looked at the held frame and how many footprints they built (CommandBufferShared::footprint keeps each batch's). Verified: cargo fmt; built by the M3 CPU job that follows. (cherry picked from commit 93a920c8cb3321b176566ff6d1d88d78cadbed4f) |
||
|
|
90edf6fd2f |
Keep each batch's footprint for the scheduler's order, built once from what it is built from
The scheduler's order across queues compares a held batch with each later queue's head by their footprints (scheduler/order.rs), and its memo lasts one pass: every pass, one at each commit and completion on any queue, built the held batch's footprint again, copying and sorting every use of its summaries under its command buffer's lock. On the replayed-frames page at 5000 resident pairs on the M3 (macOS sample, 4 s), that was 193 of the scheduler thread's 571 busy samples, and the host step's draws, which take the same lock, waited 137 samples for it. CommandBufferShared::footprint now keeps each batch's footprint (State::footprints) with what it was built from (FootprintSources), and a later ask takes the kept one while that holds: - The recordings' revision. State::recorded is a Parts, whose every mutable access moves the revision (DerefMut), so no change to an encoder's summary, a segment's recording or its bound (a host step's recording, a rebind's encoding again, a submission's scrubs and joins) leaves a kept footprint standing. - The batch's encoders (its range among the recordings). - Which summary each segment takes (Taken: a loop's laying, its recording, or the bound commit gave its host step): what may change while the recordings stand, as a route met since makes the GPU write what a segment's work reads or outgrows what commit recorded for good, or a recording falls due again. A footprint a segment's known uses join (Segment::known_summary, made from the device's aliases as they stand) is built at each ask, as before. A kept footprint is built from uses copied out under the lock (Footprint::gathered) and sorted without it (Footprint::sorted), and is kept only where the revision did not move meanwhile. WorkCounts::footprints_built counts the builds; the scheduler shares the footprint (Arc). Lane: replayed_frames::a_batch_s_footprint_is_built_once_however_many_passes_look holds the page's frame for its host step while a bystander commits on another queue until the frame completes, and asserts at most one build a bystander command buffer and two for each of the frame's batches. Verified: nothing yet; the M3 jobs (clippy, the lanes, the negative control, the page's sample before and after) follow. (cherry picked from commit d862eadd34ac9f218de5c1a0952c2d22a1e5b0b8) |
||
|
|
347b9870c4 |
Keep a host step's chunks only where two steps read the records alike, and copy the residency once an execution
A host step that compared a kept chunk's records and found them changed recorded every chunk apart again, each into a secondary of its own, to keep: on the replayed-frames page at 5000 resident pairs on the M3 that cost 23.3 ms a step where the records changed at each frame, against 18.3 ms recorded inline (one binary, keeping switched off by a temporary patch). Phase timers put the difference in a copy of the residency per chunk and its drop (2.9 ms over 20 chunks), a fresh 11 MB copy of the records (about 1.1 ms more read), resolutions and contexts. Two changes: - RenderExecution::steady decides before recording. A step keeps chunks only where the records hold, chunk by chunk, the bytes a kept recording was made from or else those the last step read, compared whole. Else the execution records inline, as before keeping, and each chunk's records are copied into the bytes the last step read (IndirectCommandBuffer:: written_bytes_into, no new pages after the first), for the next step's comparison; a recording whose records changed is forgotten and counted recorded again. So records that change at each step cost the step one copy of them beside today's inline recording, and a step records apart and keeps only what two steps read alike. The chunk store keeps those bytes per chunk (KeptChunks::look_up_step, read); a chunk recorded apart keeps them as its recording's bytes, copying nothing again. - The chunks an execution records apart carry the encoder's residency from one to the next with the bind state (replay_encoder takes it owned), so an execution copies the command buffer's residency once, as one recorded inline does. The kept-steps lane now counts chunks recorded apart to keep (WorkCounts::kept_contexts_made): the first frame records inline, the second apart, the third runs kept; a records change records inline, then apart, then kept; another input's change records apart at once; and records that change at each step record inline each frame, keeping nothing, each frame drawing what a fresh page draws. Verified: clippy, plain and under --cfg m2v_gpu, on this Mac. The lanes and the page's timings on the M3 follow. (cherry picked from commit b9b1c0aab9728e57e517cb6f0abdfc1df44e9b03) |
||
|
|
bc36a0d0d1 |
Pin the kept-steps identity case's buffers at a granule, and let the replayed-frames lane change the records each frame
The identity case made the indices' buffer at an address the runtime picked (on a 16-KiB page) and pinned the buffer made again at it, which the address space refuses (OffGranule: a pin starts on a 32-KiB granule's first page). Both now pin at one granule address high in the space. REPLAYED_FRAMES_CHANGE_EACH, set with REPLAYED_FRAMES_CHANGE_AT, binds the indices' zero half and their first half in turn from that frame, so every frame's records differ from the frame before's: the case where a kept host step records every chunk again each frame. Verified: clippy of the validation crate under --cfg m2v_gpu on this Mac; the lanes run on the M3 next. (cherry picked from commit f453f57886dda7c0bf7a84f180bf6f061e35b975) |
||
|
|
9e4a72c1b4 |
Start each chunk a kept recording records apart from the bind state the chunk before it left
A chunk recorded apart ran through a replay encoder that started from an empty bind state (Arc::default) and bind memo, so its first draw listed the residency's used resources whole. The M3 run of the replayed-frames page at 5000 resident pairs (an instrumented release build, not committed) put 42.6 ms of the keeping frame's 53.4 ms host step in the chunks' replays, against 9.4 ms with no resident pairs: 20 chunks each paying the listing. A page whose records change every frame would pay that every frame. Now the chunks of one recording hand the bind state and memo on (Carried): the first chunk takes the device's spares, each chunk recorded apart starts from what the one before it left, its encoder ended first (LiveBind::end_encoder, what SpareLiveBinds::give did, now shared), and the last gives them back. The chunks share one residency, so only the first draw lists it. This serves commit's kept chunks of the CPU's records too. Verified: cargo check and clippy -D warnings, all features, plain and --cfg m2v_gpu, runtime and validation crates. Device timing not run yet. (cherry picked from commit e6eb7316454778ef0856eec59a144bffd256394c) |
||
|
|
4c1ee2c921 |
Change the records of the kept-steps lanes to the indices' zero half, which shows in the pixels
kept_steps' records case bound the indices two on, which the M3 run of 83a1365119 found draws the same pixels: the page's 5000 primitives cover the grid's hull either way, so the case's check that the change shows failed though the step recorded both chunks again and drew what a fresh page draws. The indices now hold a zero half after the scrambled one (ZEROS_AT): binding there moves every record's index address inside the same buffer, as before, and draws every primitive at vertex 0. The case of the buffer an index address names makes the second buffer all zeros for the same reason, and REPLAYED_FRAMES_CHANGE_AT binds the zero half too, so its pixel hash moves at the change. Verified: clippy -D warnings, all features, --cfg m2v_gpu, validation crate. Not run on a device yet. (cherry picked from commit 742eb863e2152b19297b07aebc34591b29203cd9) |
||
|
|
5b451a6508 |
Hold a commit's refused recording of a write-resident ICB's records for the host step
A commit that recorded an execution from the CPU's records and found a record it refuses failed there, though a route met after the commit may still write those records before the work runs: another queue's command buffer that the work waits for through a shared event, encoded and committed after this commit. Metal runs what that route wrote (the new probe crates/metal2vulkan-conformance/probes/icb_cross_queue_writes.m, M3 Max, macOS 27.0.1, validation off: `written` completes both command buffers with the kernel's green triangle; `unwritten` completes too, drawing the CPU's mismatched-format command as garbage). Dying there where Metal runs breaks the owner's rule 2. Now, where the commit's recording of a render pass's executions, or of a compute execution, is refused and the command buffer made one of the executed buffers resident for writing (Residency::writable_indirect_command_buffers), the segment is held for its host step (Prepared::held sets Segment::host), prepared as a step's: settled variants and made-ahead pipelines, its footprint bound. The step waits for the work before it, records from the records as they stand then, and fails the command buffer at that batch's submission only where they are still refused. A refusal of another buffer's records, and every valid recording, keep the commit-time path. Counted: WorkCounts::commit_refusals_held (api_signatures row). The lane test write_routes::a_refused_command_another_queue_writes_again_runs_what_it_wrote runs the probe's `written` shape: both command buffers complete, the centre is green, and the counter moved once. docs/API.md states the held refusal. Verified: clippy -D warnings, all features, plain and --cfg m2v_gpu, for the runtime and validation crates; api_signatures/api_surface 15/15. The lane test is not run on a device yet. (cherry picked from commit 83a1365119f1563ce45f97941a335ea119bc9efc) |
||
|
|
8a407884d0 |
Let the replayed-frames lane change the records the GPU writes from a given frame
REPLAYED_FRAMES_CHANGE_AT=n has the encoding pass bind the indices two on from frame n, so the GPU writes other records from then on: that frame's host step records its kept chunks again (WorkCounts::host_step_chunks_recorded_again) and the next keeps them. A measurement knob of the lane alone, as REPLAYED_FRAMES_RESIDENT is. Verified: clippy -D warnings, all features, --cfg m2v_gpu, for the validation crate. Not run on a device yet. (cherry picked from commit e32e3362ddf2cb8ae5c172d9e26f6da20242deb6) |
||
|
|
042ec0a481 |
Keep a host step's recordings of GPU-written render commands, compared with the records
A host step of a render execution whose records the GPU may write recorded every command at every step: about 12 to 17 ms for the replayed-frames page's 5000 indexed draws on the M3, every frame, though the page's records are the same bytes each frame. The step now keeps its chunks as commit keeps the CPU's (render/executions/kept.rs, kept_commands.rs): from a chunk's second step on it records the chunk apart into a context of its own and keeps it with a copy of the bytes of its records; a later step runs the kept recording where the records hold those bytes now, compared whole, and its key is equal, and records it again otherwise. No write forgets such a chunk: the comparison decides. The key is everything the recording reads beside the records: the RenderKey commit's chunks use (inherited pipeline state, pass shape and layout, encoder state, scissors, amplification, attachments among the resident resources, the resident set compared whole once a list), plus the inherited tables' buffers by key with offsets and attribute strides (new: commit's chunks need tables that bind nothing), plus KeptChunk::runs_again's checks (each address named resolves as it did, no no-copy buffer moved, nothing detached, everything held alive). The step keeps only where the commands inherit the pipeline state and the inherited tables bind buffers alone; a record barrier makes its chunk not plain instead of ruling the execution out. Its chunks draw in the large-buffer form, as the step's other draws do. The step's round trip stays: the records are known only once the work before them completed. Counters: WorkCounts::host_step_chunks_kept, host_step_chunks_recorded_again, host_step_records_compared and host_step_compare_nanos (api_signatures rows added). The replayed_frames lane prints them and a hash of the target's pixels per frame (a blit copies the target out); the new kept_steps lane changes one input at a time (the records the GPU wrote, the inherited buffer and its offset, the inherited state, the scissor, the resident set, the buffer an index address names at the same address, the inherited no-copy buffer's pages) and checks a re-record, the pixels of a page that kept nothing, and keeping again after. FAST-PATHS' entry on kept recordings states the host step's. Verified: cargo check and clippy -D warnings, all features, plain and --cfg m2v_gpu, for the runtime and validation crates; api_signatures/api_surface 15/15; fast_paths 19/19; the runtime's kept and indirect-command unit tests 32/32. The device tests (kept_steps, replayed_frames, the ICB lane modules) are not run yet. (cherry picked from commit 9b3d13a6d22fba484cce4923fd87ad503f7bc060) |
||
|
|
c7d79b43ef |
List the queue-switch check among the modules that keep the device's functions
The teardown fix (
|
||
|
|
0f66565039 |
Pin the runtime sources at RUNTIME_VERSION 1765
Verified: pin-compute.py over the tree. |
||
|
|
9d0a6d3dbd |
Bump RUNTIME_VERSION to 1765: guest RAM copies on the GPU, and the device's teardown on the program's thread
- BlitCommandEncoder::copy_from_host_ram and copy_to_host_ram gather and scatter 4 KiB runs of a HostRam straight from its chunk imports (one bind::pages_copy_module dispatch per chunk), taking each chunk as an object over it does, so the import window moves past it. New counters host_ram_copies, host_ram_copy_bytes and host_ram_copy_dispatches. - The queue-switch check holds no device handle, and a device's teardown stops it within one step, so the program's last drop tears the device down on its own thread (RTX 5080: the teardown lanes ran the destroy on m2v-queue-switch-check before). - The GPU hazard tests' opt-in cfg changes no runtime behaviour. Verified: see the cherry-picked commits (HostRam copy: M3 33/33 and RTX 5080 35/35 host_ram device tests; teardown: 8/8 teardown_threads three times on each of the RTX 5080 and the M3). |
||
|
|
de2554f1ac |
Hold no device handle in the queue-switch check, so the program's last drop tears the device down
On the RTX 5080 Laptop GPU the teardown lanes failed: a device that made a command queue and went at once could be torn down on the m2v-queue-switch-check thread after the program's last drop returned. The check upgraded a weak handle for its run (a few milliseconds), so a program that dropped its own handle in that window left the check holding the last one; a consumer that adopted the VkDevice destroys it after its last drop returns, and Vulkan requires every object made from it destroyed first and host access to it externally synchronized (VUID-vkDestroyDevice-device-05137). What: - The check's thread holds the parts of the device it works with (queue_switch_check::Parts: shares of its functions, VkQueues, parking, counts, fences, loader word, sharing state and the shader cache's content store, and the family, round robin, pair, clock and driver identity it reads at the start), never a device handle. QueueUses lets a queue's use reach those parts without a Device. - The teardown stops the check before it goes on (QueueSwitch::stop): the check reads the flag before its objects' making, before each round and before it reads the timestamps, so the teardown waits at most one step, then for the check to release its objects (verdict Unchecked, nothing recorded) and drop its shares. QueueSwitch::began/ended bracket the thread from before its spawn; stop_waited reports the wait. - A new device test, a_running_queue_switch_check_leaves_the_device_to_the_program_s_thread, holds the check between two rounds, drops the device, and asserts that the teardown ran on the program's thread before the drop returned and that its wait for the check stayed within the release bound. It runs only where the check runs (two VkQueues with timestamps). Verified (cargo nextest, --cfg m2v_gpu, the hazard filter, -E 'test(/teardown_threads/)'), three runs each: - RTX 5080 Laptop GPU, NVIDIA 615.71.09, at 344351d867: 8 tests run: 8 passed, 1637 skipped, in each run; the new test ran and printed "the last drop took 225.70356ms, of which the wait for the check 2.273443ms" (then 127.5 ms / 1.38 ms and 205.2 ms / 10.83 ms). - M3 Max, MoltenVK 1.4.2, macOS 27.0.1: 8 tests run: 8 passed, 1620 skipped, in each run; the new test is skipped there (no queue-switch check runs on that device). No negative control against the old code: the test's hold between rounds is a hook this change adds. (cherry picked from commit 0c27be02fd4014b2ff3e31fdf26ecdc183c72882) |
||
|
|
cc4c44bd7e |
Make the GPU hazard tests opt-in under --cfg m2v_gpu_hazards
Owner's rule (11-05): tests that fault a real GPU, hold one for long, or allocate toward its limits never run in sweeps, lanes, stress loops or gates; they run only when that feature is tested, on request. On the M3 Max a GPU fault's recovery fails other processes' command buffers in flight (.config/nextest.toml has the measurement). #[ignore] is not enough, since lanes run --run-ignored all, so the gate is a cfg: on a real GPU a hazard compiles only under --cfg m2v_gpu --cfg m2v_gpu_hazards. Under --cfg m2v_cpu_icd it compiles and runs as before, so lavapipe CI keeps them. Gated (each doc comment now says which hazard it is): - runtime_lane::host_memory::a_gpu_fault_fails_its_command_buffer_and_the_queue_runs_on and ::a_lost_device_s_command_buffers_let_go_of_their_pools_after_the_driver_s_completion: GPU writes into read-only host pages, real page faults (2 and 3). - host_memory::a_no_copy_buffer_s_pages_are_imported_when_it_is_made: no-copy buffers of 1 to 16 GiB. - vertex_strides::vertex_fetches_past_4_gib_of_a_buffer_are_refused and stage_in_strides::stage_in_fetches_past_4_gib_of_a_buffer_are_refused (and their `Large` helper): 4 GiB + 4 KiB buffers. - heaps::the_largest_heap_lies_in_one_allocation: a heap of the device's largest allocation, up to 4 GiB. - cross_queue_shadows: the three tests whose spin holds one command buffer for 1.5 s. - framebuffer_fetch::storage_forms::a_steady_stream_takes_the_storage_form_at_its_first_lone_commit: a single-dispatch spin of up to 1 s that only its cap ends on Apple GPUs. - detach::table_3_a_detach_waits_for_running_work_then_refuses: single dispatches calibrated to 500 ms (up to 2 s loaded), the cap alone ending them on the M3 Max, where Metal ended some 0.5 s dispatches as hung. - runtime tests::detach_lost: one dispatch of 2^25 loads (about 4.5 s on the M3 Max) whose word the GPU does not see raised. Made safe instead of gated: - mesh_draws::object_grids_run_as_metal_runs_them: on a GPU without the hazards cfg, grids past 2^20 object threadgroups are skipped (printed), as a CPU ICD already skips them; the 70k to 262k grids and the past-the-watchdog discards still run. The 4.6M grid took 12 s in one command buffer on the RTX 5080 Laptop GPU. - detach::a_resident_buffer_no_command_reaches_fails_its_submission_once_detached takes the spin kernel without calibrating a cap (`spin_kernel`): its word is raised, so the cap never mattered, and the calibration's unraised runs are bounded only at 16 x 50 ms. - cross_queue_shadows::an_encoder_after_a_signal_reads_what_another_queue_wrote_after_it no longer calibrates a spin it never ran. The cfg is declared for unexpected_cfgs in the runtime, validation and conformance manifests. docs/VALIDATION.md says what a hazard is and how to run one; CONTRIBUTING.md and .config/nextest.toml mention the cfg. The device lane is unaffected: its builds set RUSTFLAGS to --cfg m2v_gpu alone. No product code changed (no RUNTIME_VERSION bump; the runtime-sources pin skips test modules). Verified on this Mac (no test run on any GPU): cargo fmt --all; cargo clippy --workspace --all-targets --all-features -D warnings clean plain, under --cfg m2v_gpu, --cfg m2v_gpu --cfg m2v_gpu_hazards and --cfg m2v_cpu_icd. cargo nextest list -p metal2vulkan-runtime -p metal2vulkan-validation --all-features --run-ignored all: under --cfg m2v_gpu 5022 tests, under --cfg m2v_gpu --cfg m2v_gpu_hazards 5034, and the difference is exactly the 12 gated tests; all 12 are listed under --cfg m2v_cpu_icd (5000 tests). (cherry picked from commit 7b57d9a87a3dd8275a2ece547fc0bd9b9cb6808c) |
||
|
|
ca19864eb3 |
runtime: a device test that a copy takes its chunks as an object does, moving the window ahead
On a device whose thread imports a RAM's chunks ahead (no `hold_host_ram_imports`), a gather from the RAM's first chunk finds that chunk imported ahead and opens the full window past it, and a scatter into the chunk past the window imports that chunk itself while the thread imports nothing past the RAM's end: the copy goes through the objects' one import path (`RamOnDevice::chunk`, `By::Object`) and moves the window as an object's take does. A RAM of six chunks (`AHEAD_CHUNKS` + 2), anonymous memory; the test's helpers gain a sized RAM and an unheld device. Verified: see the commit's evidence in the port's report (potluck jobs on the M3 and the RTX 5080). (cherry picked from commit 2ad02572ea64482f821c48cd9985a001fd382a98) |
||
|
|
a0bebe78f1 |
runtime: copy runs of a guest RAM to and from a buffer on the GPU, from the chunk imports
`BlitCommandEncoder::copy_from_host_ram(ram, runs, destination, destination_offset)` gathers runs
of a `HostRam` the device uses into consecutive bytes of a buffer, and
`copy_to_host_ram(source, source_offset, ram, runs)` scatters them back (a runtime extension:
Metal has none). A surface that is a scatter of guest pages is copied straight from the RAM's
64 MiB chunk imports, with no view mapped per surface (one mmap per run) and no import made per
surface.
How: adjacent ascending runs merge, descending neighbours stay apart; runs are cut at chunk ends;
the 4 KiB pages become a table in the command buffer's upload arena, and each chunk the runs touch
takes one dispatch of the new `bind::pages_copy_module` (more only past the storage-buffer range
or the workgroup count). A chunk not imported yet is imported, or its pending import waited for,
as an object over it does.
Ordering: each chunk a copy uses gets a resource key placed over the chunk's host bytes in the
host-alias placements, the way no-copy buffers and heaps are placed, so the copy's chunk uses
(joined to at most 16 ranges per chunk) order against other copies and against every no-copy
object over the RAM's own addresses, in one encoder and across encoders; the buffer side is
tracked like any blit. A scatter's writes reach the RAM's dirty log as the GPU's in place, so a
copied backing over those pages takes them in at its next commit. Objects made over another
mapping of the pages (a view resolved through `with_runs`) are not ordered against the copies.
Refused with `Problem::HostRam`: an empty run, one off 4 KiB, one outside the RAM, a RAM the
device does not use, buffer bytes off a 4-byte word; no host import is `Unsupported`; bytes past
the buffer are `RangeOutOfBounds`. Replayed at rebinds (`BlitCall::HostRamCopy`). New counters
`host_ram_copies`, `host_ram_copy_bytes`, `host_ram_copy_dispatches`. README, HOWTO, the
API signature rows and docs/REFUSALS.md updated.
Verified:
- On this M3 Max (MoltenVK), --cfg m2v_gpu under nextest: the five new device tests
(`tests::host_ram_copy_device`: round trips byte for byte over ascending, descending, adjacent,
repeated and chunk-crossing runs into Shared and Private buffers; CPU writes before the commit
gathered and a scatter's bytes in the pages after completion; the two hazard cases in one
encoder and across encoders; a copied backing over the pages taking a scatter at the next
commit; the refusals) and the ten `tests::host_ram_device` tests: 15 passed.
- Negative controls, each a saved build: merging descending neighbours fails
`adjacent_ascending_runs_merge_and_descending_ones_stay_apart` and
`a_gather_and_a_scatter_move_every_runs_bytes_in_order` ("the gathered bytes"); not placing the
chunk keys over the host bytes fails
`copies_are_ordered_against_a_no_copy_buffer_over_the_same_pages` ("a later reader sees the
scatter"). The first control found the test pattern repeating every 1 KiB, so a page swap
went unseen; the pattern now differs per page.
- The `host_ram::copy` unit tests (merge, refusals, chunk cuts, the plan, the joined uses) and
`consumer_auto_traits`; clippy --workspace --all-targets --all-features -D warnings, plain and
--cfg m2v_gpu; rustdoc -D warnings; `signatures.py --check` after the bless; the refusal
surface `--check`.
- The ignored release bench `tests::host_ram_copy_bench` on the M3, a 3840x2054 BGRA8 surface
(31,549,440 bytes, 31,551,488 in whole pages) scattered over 1 GiB of shared RAM: 7703 4 KiB
runs (5490 descending neighbours, 7279 runs after the merge) take 16 dispatches, 0.35 ms of CPU in the call, 0.59 ms of GPU and 0.64 ms from commit to completion
for a gather (scatter 0.37 / 0.58 / 0.64). The view path at the host's 16 KiB page (1926 runs:
a view mapped run by run, a buffer `with_runs`, a buffer-to-buffer copy, the release) takes
1.58 ms to map, 2.36 ms to make the buffer, 0.99 ms commit to completion and 0.78 ms to
release; the gather of the same 1926 runs takes 0.14 ms CPU and 0.60 ms commit to completion.
Ported onto gate/stack27, where the device's thread imports a window of chunks ahead of the
objects (paced, with the memory lock released, short of maxMemoryAllocationCount and giving back
what no object took). The conflict was `RamOnDevice`'s fields alone: the copies' `ChunkKeys` sit
beside the window and its wake, and the old cursor is gone. The copy still takes each chunk
through `RamOnDevice::chunk(.., By::Object)`, the objects' own path, which now moves the window
past it, wakes the thread and clears the chunk's untaken mark; there is no second import path. The
copy module docs and HOWTO say so. The ignored release bench waited for every chunk imported
ahead, which the window never does; its warm-up copy now imports the chunks the runs touch.
The verification above was on the old base; this tree's is in the commit that follows.
(cherry picked from commit 923718777c198bef526dd07f701fc71a71e07b00)
(cherry picked from commit fa00224f7b29ab0359c8305a47da9c9273fc5d37)
|
||
|
|
014d1d4c0b |
bind: a gather and a scatter of 4 KiB pages by a table, for the runtime's copies
A new owned compute module, `pages_copy_module(device, PagesCopy)`, built with the typed SPIR-V builder like the other `bind` modules. It moves whole 4 KiB pages between a scattered buffer and a consecutive one by a table of page pairs: workgroup g takes entry `first_entry + g`, whose two words name the scattered page and the consecutive page (counted from `first_word`); its 128 invocations copy the page's 1024 words, eight each. `Gather` writes the consecutive side, `Scatter` the scattered side. Local size 128 is the Vulkan 1.2 floor of maxComputeWorkGroupSize[0]. The runtime uses it to copy runs of guest RAM to and from a buffer straight from the RAM's chunk imports (next commit), in one dispatch per chunk rather than one copy region per run. Verified: the module's interpreter tests (valid on every committed device profile; a gather from a non-zero first entry and first word over descending and repeated pages; a scatter), the `owned_divisions` listing, `api_surface` and the blessed `api_signatures` rows; clippy (--all-targets --all-features, plain and --cfg m2v_gpu) clean; rustdoc -D warnings clean. (cherry picked from commit 03e1d0046e908f46b21e33423e45d7e541927a91) (cherry picked from commit 7167c05e8ef2b012c023f50e2910bea4ec00e9dc) |
||
|
|
aae542957b |
Hold the draws class's wasted creation pipelines at 86: the pass-start family's 39
The re-recorded costs give the pass-start-barrier family's 13 cases their first cost records, and the per-class creation-prediction ceiling then failed (cost::the_creation_prediction::neither_prediction_wastes_more_than_it_does_today, potluck m3-max-613): draws and no dispatch read 86 predicted pipelines no command took against 47. Every one of the 39 more is those 13 rows: comparing each recording's creation_pipelines_made and creation_pipelines_drawn before and after the re-record, only those 13 rows changed (none had a record before), each 5 made and 1 to 3 drawn. They are cases that draw, so this is a misprediction, an open bug the ceiling's doc now names with its suspect; its fix lowers the ceiling back to 47. The table of what the recordings read is updated to 528 rows. Verified: the comparison over all 528 recordings (13 changed rows, all new); the suite is rerun on the M3. |
||
|
|
908ba3dbf2 |
Re-record the conformance costs for stack 27
Stack 27 adds the resident_textures_looked_at count and moves two gated bounds, so the cost check against stack 26's records failed (m3-max-528): resident_textures_looked_at newly gated in 14 cases (seen in 246), pipeline_layouts_made 2 -> 1 and shader_modules_made 4 -> 3 in render-state-render-barriers, pipeline_layouts_made no longer gated in render-state-heap-residency, resident_textures_looked_at 2 -> 4 in frame-length-chain, and the 13 pass-start-barrier cases held no record. This re-records every case: a whole-set `conformance cost --runs 8 --write`, then `cost --runs 8 --alone --write` over every changed case (693), so each record carries its contrast, and AFTER_THE_LAST_RUN is empty again. Verified: the re-bless on the M3 Max (potluck m3-max-574): 693 cases measured, 0 the venue could not measure. |
||
|
|
d19da8bfce |
Bless the golden tables for the ICB vertex-encode fixture
icb_vertex_encode_indexed (from the ICB steps) is new: its printout, its three inventory rows and 114
golden-hash cells. Reviewed: ive_encode, ive_vertex and ive_fragment translate on every profile with
BufferDeviceAddress and ShaderInt64, and ive_encode is an honest Unsupported{GpuEncodedIndirectCommands}
on lunarg-desktop-baseline-2023, roadmap-2022, swiftshader and vk12-floor.
Verified: on the M3 (potluck m3-max-431) bless_engine_inventory, the air_input printout and
bless_golden_hashes, then the five failing tests (inventory order, golden printout, golden hashes,
llvm_as part 7, metal_as part 2): 5 passed.
|
||
|
|
43a04fc8a1 |
Pin the runtime sources at RUNTIME_VERSION 1764 after the copy-beside-import comment
The cherry-picked docs commit changes a comment in copied.rs, a hashed runtime source. Verified: pin-compute.py over the tree. |
||
|
|
03d4e53238 |
Record the copy beside another storage mode's import as a GPU-to-GPU gap
What: copied.rs's GPU-to-GPU note and docs/FAST-PATHS.md's known gap now also name a copy beside a live import of the same bytes for the other storage mode (a Managed buffer's import, then a Shared buffer over the same bytes whose import the gate refused): two memories that agree only through the pages, as overlapping copies do. Why: a buffer lies in a live import of its own memory class, else in a live copy of either class; a copy made while only the other class's import lives is a second memory. Lying in the other class's import instead was left out: it would change which memory type the buffer's import takes. Verified: docs only (cargo fmt). (cherry picked from commit 9f473f8f10f82e59864fd5abb74615b65c3b2e14) |
||
|
|
6b8b6e7310 |
Pin the runtime sources at RUNTIME_VERSION 1764
No Degradation variant, WorkCounts field or method is removed by this stack (api_signatures.tsv
loses no line against development
|
||
|
|
33a73fdb9e |
Bump RUNTIME_VERSION to 1764: copied surfaces joined, resident uses noted once, replayed executions bounded
Runs of unchanged artifacts and plans behave differently under this stack: - a no-copy buffer whose import is refused or fails joins its copy to the memory as an import is joined, so a later buffer of the same kind over the same bytes lies in the live copy (one copy, one hazard key), and the copy's key list is bounded; - a draw's uses of what its encoder made resident are checked against the attachments once and noted once while their identity holds, a pass-start list holds a covered range as noted, and a rebound draw patches its buffer-slot uses through a list of them; - an execution of inherited buffers is bounded by the bindings it inherits, the resident textures are looked at once per change, and a render state's recent bind shapes are kept and found without listing its used resources; - the render-pass-split notice names a draw's read behind a barrier as its cause. |
||
|
|
03d6145055 |
Name the encode closure type of the replayed-frames hold check
Clippy's type_complexity fired on the check's cases array under --cfg m2v_gpu; a type alias for the encode closure (Encode) states it plainly. Verified: cargo clippy --workspace --all-targets --all-features -- -D warnings with RUSTFLAGS='--cfg m2v_gpu' passes on the M3. (cherry picked from commit 04115e977fb3a51d2b7ac06f3e2cc9927e7571e9) |
||
|
|
9d232bf142 |
Bind the recent shapes' iterator mutably where a lost shape is looked for among them
RecentShapes::find called Iterator::find on an immutable binding, which did not compile (E0596), so 977d728ec3 left the runtime unbuildable. Verified: cargo clippy --workspace --all-targets --all-features -- -D warnings passes on this tree, plain and with --cfg m2v_gpu (with the next commit's lane fix), on the M3. (cherry picked from commit ec98e5b5ca796142bb139864d950ccb632ecc2a8) |
||
|
|
ba3e45f1d5 |
Keep the bind shapes a render state took lately, found without listing its used resources
A render encoder keeps one bind shape per state (`LiveBind`), lost at every change of a field the shape reads. Draws whose calls alternate such a field lose it at every draw: an indirect command buffer's replayed draws that cycle through the primitive types flip the viewport compensation (points against the rest) and the band. Each loss found the shape again through `GraphicsState::kept_shape`, whose comparison builds the used resources' shape (`BindState::used_shape`, a map over every resource made resident): N x K for N replayed draws and K resident resources. A state now keeps the shapes it took since it last listed other used resources (`live_bind::RecentShapes`, at most `RECENT_SHAPES` = 5, one per Metal primitive type, the call's one input that varies from draw to draw and that a shape reads), set aside and taken with the state. Each was the state's shape while it listed the used resources it lists now, so a lost shape is found among them by comparing every other field (`BindState::has_shape_beside_used`, new and public in the translator, with its `api_signatures.tsv` row), at the cost of the slots and fields, not the resources. `refresh_bind_state` forgets them where the used resources change. Draws that alternate more shapes find the one kept longest replaced and take the drawing state's settled shapes as before. The replayed-frames lane bounds the bind shapes a warm frame makes or finds at `WARM_SHAPES` (32), against 5000 replayed draws, and prints the count. Unverified: not compiled, not run (parked before the build). Next: cargo check, clippy, api_signatures, the debug lanes, the replayed-frames lane with the bound, and its negative control (RECENT_SHAPES = 1 must fail WARM_SHAPES). (cherry picked from commit 977d728ec3358f3c3ae77ee81a76c0b0231c72bc) |
||
|
|
a1d400d111 |
Look at the resident textures once per change, not at every draw
Two scans over every texture an encoder made resident ran at each draw, so a pass that draws N times while K textures are resident paid N x K: on the replayed-frames page (5000 replayed draws), the host step grew by about 26 ns per draw per resident pair. - The shadowed textures a draw uses (`RenderLowering::draw_resident`): the resident textures' shadows' copies are now kept in the encoder's `LiveBind` as a `shadow::ResidentShadows`, listed again only where the residency's generation or the count of usage shadows made moved, as a compute encoder already keeps them (`compute/live.rs`). They hold the copies, so `SpareLiveBinds::give` lets them go as the encoder ends. The bound textures are looked at as before, then the resident ones, in the same order. - Whether a resident texture maps addresses (`address_map::sampler_maps`): `Residency` keeps `maps_addresses`, set as such a texture is made resident. A texture's address-mode map is fixed at its creation: `ViewRecord::address_mode_map` is set only where the record is made (from the descriptor, or a view's from its texture's record, `view_plan.rs`) and the record is immutable behind the texture's `Arc`; no setter changes it, and a residency never makes a texture non-resident, so the flag is exact. Unverified: not compiled, not run (parked before the build). Next: cargo check, clippy, the debug lanes (the 39 ICB modules, write_routes, replayed_frames, the runtime hold and ICB unit tests), then the release K sweep. (cherry picked from commit b1179279b115ad2252d574324bfb577ca1c18317) |
||
|
|
578532c98a |
Bound an execution of inherited buffers by the bindings it inherits, not by everything
An execution of indirect commands that inherit the encoder's buffers, recorded by a host step for what the GPU may write, had no footprint for the scheduler's order across queues (`DeferredPass::bound` and `Execute::bound` answered `None`), so `tracker::ordered` put every later batch of any other queue that makes a tracked use behind it: behind the gate and the whole host step, a device-wide hold. On a page whose vertex function writes 5000 indexed draws, the presenter's and an unrelated queue's command buffers waited the step's seconds. Its footprint is now what the step's recording may reach that Metal orders: the resources made resident (useResource, useHeap) with their usage, the records the step reads, and the bindings the commands inherit (`ArgumentTable::bound_uses`: each bound buffer whole and each bound texture's image, read and written in every stage), aliases included. `None` stays where reach is truly unknown: an inherited visible-function table, tile memory, a lent visibility query, shadowed textures, command predication. The replayed-frames lane gains a check, `a_replayed_execution_holds_only_what_shares_its_resources`: while the frame is held for its host step, a bystander filling its own buffer and a presenter copying out a texture the frame only reads are not held behind it (`heads_held_for_earlier_commits` unmoved), and a presenter filling a buffer the commands inherit is. The measurement prints the hold counters too, and its execution's pass binds that inherited buffer. Verified (debug, --cfg m2v_gpu, Apple M3 Max): see the message to the coordinator for the run; negative controls: the bound back to None fails the bystander case, and the bound without the inherited bindings fails the inheriting presenter's case. (cherry picked from commit 828425b1e7a721500328bb8bbceebd889521325e) |
||
|
|
20747c70a1 |
Measure a replayed execution of commands a page's vertex function wrote, among many resident resources, while two other queues commit
What: the owned fixture icb_vertex_encode_indexed (ive_encode, a vertex function that encodes one draw_indexed_primitives of 6 16-bit indices per draw, of primitive type iid % 5) and the measurement lane runtime_lane::replayed_frames: a rasterization-off pass sets ive_encode's state and draws one point 5000 times, each instance writing command i of an indirect command buffer that inherits the executing encoder's state and buffers; a second pass executes the 5000 commands, making REPLAYED_FRAMES_RESIDENT buffers and textures resident besides (as a page's bind groups); meanwhile a presenter queue blits from a texture the page made resident and a bystander queue fills a buffer of its own, each one command buffer at a time. It prints per frame the frame's time, the host step's time, pipelines made and records read, and the other queues' largest and mean commit-to-completion times. Why: the consumer's renderBundles page took 15 to 20 s a frame on an RTX 5080, each host-replayed execution stalling the display. This is that shape. How verified: release, --cfg m2v_gpu, M3 Max under MoltenVK (the host step's time; the presenter's and the bystander's largest waits): 0 resident: 13 ms, 18 ms, 18 ms; 1000 of each: 195 ms, 200 ms, 200 ms; 5000 of each: 1.3 s, 1.31 s, 1.31 s, 5000 records read and no pipeline made a warm frame. (cherry picked from commit 074bef7d78795bf30444cfff4e368c5215e89c5c) |
||
|
|
bf1055e10e |
Count a test run's primary as begun when its encoder took it begun ahead
draws_after_texture_and_sampler_changes_rebind_what_every_step_binds failed now and then with begin_command_buffer 0 against 1 in the commands two runs recorded. The runtime behaves as designed: the thread that completes a command buffer begins one of its pool's primaries ahead for the next command buffer when no thread waits for it (spares.rs; command_buffer/mod.rs checks gate.awaited()). Whether draw_again::run's wait was already waiting when the GPU's completion came is a matter of timing. Where it was not, the next run's encoder took the primary begun ahead (WorkCounts::encoder_primaries_begun_ahead) and made no vkBeginCommandBuffer in the window the test counts. Where it was, the encoder began its own. draw_again::run now counts a primary its encoder took begun ahead as a begin_command_buffer, so the commands of a run are the same either way. The new run_on runs on a given queue and, where asked, polls the status instead of waiting. A new test, a_run_counts_its_primary_begun_by_its_encoder_or_ahead_alike, forces the race's rare side: - a run that completes while no thread waits; - the begin ahead it leads to; - a run on the same queue, whose encoder takes the primary begun ahead (asserted). It compares that run's commands with those of a run whose encoder began its own. The same queue is needed because a pool serves its queue family alone and a new queue may lie in another family: on the M3 a run on a new queue made a pool rather than take the one begun ahead. Verified on the M3 Max, debug, --cfg m2v_gpu, potluck job m3-max-203: - runtime suite 1621/1621; - the flaky test and the new one, 200 stress iterations each: 200/200 pass. Negative control, the begun-ahead count left out of run (job m3-max-203): the new test fails in 200/200 iterations, and the flaky test fails in 4/200 (iterations 180, 183, 189 and 200) with begin_command_buffer 0 against 1, as before. Test-only change. (cherry picked from commit 0710167f2ac664e3f83fd5c611d790184b99d468) |
||
|
|
e4d238a31d |
Patch a rebound draw's buffer-slot uses through a list of them
patch_buffer_uses found the uses of the buffer slots a call changed by walking every use of the kept draw past its resident ones and looking up each one's resource use to learn its slot. CommandUses now keeps, in uses a caller keeps (command_uses_into), the slot and position of each use of a buffer slot (`slots`), filled in the loop that makes the uses; patch_buffer_uses walks that list alone. Uses that command_uses makes whole (dispatches, tile dispatches, GPU-executed commands and the debug check's) list nothing, since nothing patches them, so they make no allocation more: a first version that listed slots in every CommandUses failed frame_costs' debug draw allocation bound (20.04 a draw, over 20) through the debug check's whole uses. Builds with debug assertions check the list against the uses before each patch (slot_uses_listed) and count the patches and the uses they looked at (patched_slot_uses). Verified on the M3 Max, debug, --cfg m2v_gpu: - New test draw_again::draws_rebound_after_an_offset_moved_patch_that_ slot_s_use_alone: draws of tob_sample with the texture and sampler bound once and vertex buffer 0's offset moving; each patch looks at one use, the vertex buffer's. Negative controls, each failing that test: listing every slot class trips "a command's uses of buffer slots other than it lists"; counting every use past the resident ones (what the old walk looked at) gives 21 uses over 7 patches against 7. - Runtime suite 1620/1620 (potluck job m3-max-155); the validation lanes over residency, draws and notices 248/248 (m3-max-157). draws.10k (reims-vgpu's draw_cost harness, release, M3 Max, 3 rounds interleaved, job m3-max-168), runtime leg per draw: - instructions 8337.5 / 8334.8 / 8334.3 against 8375.3 / 8386.3 / 8380.2: -44 (-0.5%); - CPU ns 430.6 / 432.5 / 430.3 against 422.6 / 432.1 / 429.5: no change beyond the noise. The base binary is 43be622f72, whose tree differs from this commit's parent only in noted_apart.rs's d2.1 variant; the two variants measured equal at draws.10k (8386.5 / 8381.0 against 8382.4 / 8383.9). (cherry picked from commit dbf5576dc25c7ee2bcb3e709c2b786758763aa1e) |
||
|
|
71e9c43319 |
Hold a range a pass-start list covers as noted, so a merge keeps a draw's resident uses noted
A render pass's lists of the bytes its fragment stages wrote and read, and its other stages
wrote (render/pass_start_reads.rs: Written), took a range unless they held one equal to it, and
merged a key's ranges into their hull past 16. A draw's uses of what its encoder made resident
were noted once per identity only while no list merged (PassStartReads::add_draw), as a merge
dropped the ranges taken equal. Draws that each bind bytes of their own in a resident buffer,
as the resident-draws lane's entry draws bind their table's entry for their fragments, merge
that buffer's list every 16 draws: each such draw noted all of the encoder's resident uses
again, O(N/16) whole walks of N uses a pass.
What the lists answer is whether a range overlaps one they took (Written::overlaps, the only
question asked of them besides emptiness). A range inside one they hold adds nothing to that,
so they now take a range only where none they hold covers it (covers), and a merge's hull covers
each range it replaces: every range taken stays held, by one that covers it, until the lists are
cleared. The memo of add_draw no longer counts merges (Written's merge count goes, and its
change count counts the ranges taken no range covered, which the check's memo reads as before),
so a draw that begins with the uses the last began with notes none of them again until the
pass's lists are cleared. Builds with debug assertions check each skipped use held, by
coverage, as before.
Tests (with debug assertions):
- render::pass_start_reads::tests::a_draw_notes_its_resident_uses_once_though_a_list_merged_their_ranges
(was ..._again_once_a_list_merged_...): 18 draws reading the same resident bytes and bytes of
their own each, the 17th range merging the list, walk the resident uses at the first draw
alone, and again after the lists are cleared. With covers answering only for an equal range
(the old rule), the debug check fails at the draw after the merge ("a pass noted a draw's uses
by their identity less than its uses").
Verified on the M3 Max (macOS 27), through potluck, this tree:
- the runtime's suite (--cfg m2v_gpu, debug): 1619 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): 248 passed;
- clippy on the runtime (all targets and features, --cfg m2v_gpu, -D warnings): clean;
- the negative control above, run: fails as described.
Measured, the resident-draws lane on the M3 Max in release (whole-process instructions over 5
frames, 2 interleaved rounds, the parent then this):
entry own encoder N 2000 2.349e9 2.327e9
N 5000 8.408e9 8.264e9 (frame median 89.4 ms, 87.8 ms)
entry own write N 5000 9.648e9 9.505e9
and its counters at N 500 over 2 frames: resident_uses_against_fragments 33132, now 2008 (a
check and a noting of the 502 resident uses a frame), what the frame drew hashing the same.
Plain draws (reims's draws.10k) are measured apart from this commit.
(cherry picked from commit 43be622f72ee63738edac6b323a734710b8f59d8)
(cherry picked from commit 4642f4a7128dd3425e5e442a21cf8adee32b81c2)
|
||
|
|
669b2df593 |
Note a draw's uses of what its encoder made resident once while their identity holds
A draw noted its uses apart (EncoderCore::note_reaching) by comparing every one with the last
draw's (NotedApart::holds, NotedApart::fresh), recording those that differed, touching each
(EncoderCore::touch_reaching) and copying them all for the next draw (NotedApart::note): 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 that
was 46% of the samples after the uses were kept.
CommandUses gives, with that identity, one of the keys the uses reach through the resident set
alone, given where those are worked out again (settle_resident, where it made uses of what the
encoder made resident), and the stages of those uses, folded where they are made:
CommandUses::reaching_prefix (binding::ReachingPrefix), None while a use added since took one of
those keys. render.rs's draw path and a rebound draw choose by it: a draw without one is noted by
note_reaching as before; one with one by EncoderCore::note_draw, which
- answers whether it is noted already by the identities and its uses past them
(NotedApart::holds_draw), records the uses past them that differ from the last's at their place
where the last began with the same (NotedApart::fresh_draw; every use otherwise),
- touches only the uses past them where the last such draw of the encoder began with the same
while the device's buffers over host pages stand as they did (NotedApart::touched,
EncoderCore::touch_draw), as the keys a draw touched stay kept, and named, while the encoder is
open,
- and keeps the identities and its uses past them alone (NotedApart::note_draw).
A command noted whole after it finds it not noted already (NotedApart::holds checks that the last
was noted whole). NotedApart::uses, which a draw again notes its fresh reads by, is a kept draw's,
which begins with no use of what its encoder made resident (checked with debug assertions).
Counted: WorkCounts::resident_uses_noted, the kept uses a draw's noting walked: 0 at a draw that
begins with the uses the last noted, by identity. WorkCounts gains that field, so a struct literal
of it must name it; the signature table is blessed. Builds with debug assertions keep the whole
uses too and check holds_draw, fresh_draw and touch_draw against them.
Tests (--cfg m2v_gpu, with debug assertions):
- tests::noted_apart::a_draw_beginning_with_the_same_resident_uses_compares_only_its_others and
tests::noted_apart::a_draw_s_resident_uses_are_touched_once_by_their_identity;
- 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 noting walked.
Verified on the M3 Max (macOS 27), through potluck, as b3ddf2c122, this same tree:
- the runtime's suite (--cfg m2v_gpu, debug): 1619 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): 248 passed;
- negative controls, each run and failing:
- NotedApart::fresh_draw taking any identity of the same count for the last's:
tests::noted_apart::a_draw_beginning_with_the_same_resident_uses_compares_only_its_others
fails its assertion of the uses found fresh;
- NotedApart::touched taking any identity of the same count for the last's: the debug check
fails ("a draw touched by its uses' identity less than by its uses") in
tests::noted_apart::a_draw_s_resident_uses_are_touched_once_by_their_identity, and
tests::resident_uses::draws_keep_the_uses_of_what_their_encoder_made_resident_until_it_or_their_plan_changes
fails its count;
- NotedApart::holds_draw comparing the uses' identity alone, not the resident keys': the unit
test above fails ("!noted.holds_draw(stages, (&first, &resident, other), into)").
Measured on the M3 Max:
- Plain rebound draws (reims's draws.10k, no resident uses; the runtime leg's instructions a
draw, median of 9 runs, two interleaved rounds, potluck job m3-max-136): the stack-26 gate tip
|
||
|
|
ec85bf8938 |
Check a draw's uses of what its encoder made resident against the attachments once
While AttachmentReadInPlace would be announced (never yet on the device, or at each occurrence),
each draw's check for memory an attachment of its render pass renders
(Device::degrade_attachment_reads, render_target::shares_attachment) walked its uses for each
attachment: 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, with the earlier steps, that was 12% of the samples.
render.rs's draw path and a rebound draw choose by CommandUses::prefix: a draw whose uses have
no identity is checked by degrade_attachment_reads, as before (its notice now made by
attachment_read_notice, which both share). One whose uses have one goes through
Device::degrade_resident_attachment_reads. Where a check of its whole uses finds that they share
no memory with an attachment, CommandUses keeps their identity and count with the version of the
pass's layout (CommandUses::apart_from): the next draw that begins with the same, in a pass of
that layout, checks only its uses past them (CommandUses::apart). An attachment's memory is its
texture's image or bytes, which no call changes, and a layout of one version is the same layout
(Versioned). A layout of a draw's own (attachments stood in for, render.rs) has no version, and
its draws check their whole uses. Where they share memory with one, every draw checks them, as
before, so a device that announces each announces each.
Counted: WorkCounts::resident_uses_against_attachments, the kept uses a check walked: 0 at a draw
that begins with the uses found to share none. 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 that of the whole uses.
Tests (--cfg m2v_gpu, with debug assertions):
- tests::resident_uses::draws_announce_each_read_of_an_attachment_their_encoder_made_resident:
draws whose encoder made their pass's attachment resident each announce AttachmentReadInPlace
at each draw (announce_each), the later ones keeping their uses. With the identity kept where
the uses share memory with an attachment, the debug check fails ("a draw's uses checked
against the attachments 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 check walked: 0 at each draw that kept them.
Verified on the M3 Max (macOS 27), this tree (committed when the work was parked):
- the runtime's suite (--cfg m2v_gpu, debug): 1592 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 11389.8 and 11384.1, this 11390.2 and 11376.5.
- 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.413, this 0.434 (draw_offset is bimodal by process: 0.409 to
0.454 over this one's runs); draw_compositor d1 0.978, the last commit 0.974, this 0.982.
- 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.317e9 (6.5) 1.335e9 (6.5)
N 1000 2.511e9 (19.0) 2.539e9 (19.8)
N 2000 7.296e9 (66.0) 7.410e9 (69.6)
N 5000 39.12e9 (393.0) 39.82e9 (399.1)
entry own write N 5000 40.69e9 (456.7) 41.39e9 (481.8)
one round each. This step saved nothing on the lane: about 5.6 instructions more a resident
use a draw at N 5000. An earlier form of it (degrade_attachment_reads itself choosing by the
identity) saved about 19 a use on the same lane. The cause is not investigated: UNVERIFIED
whether the lane's draws check against the attachments at all once their kind is announced,
and whether the identity is kept across them.
(cherry picked from commit 5634c84266d2de065b92822ec1d50610b74e2c22)
|
||
|
|
c0151d5175 |
Take either code nearest rt6_half's half step in command_render_states, where the color writes are not Metal's
What: `commands_that_do_not_inherit_render_states_draw_with_the_encoder_s` compares the encoder's draw against Metal's texels through `metals_texels`: a channel Metal stores as 0x80, its code for `rt6_half`'s 0.5 (127.5 codes, a half step), may hold 0x7f on a device without `VkProperty::MetalColorWrites`; every other channel compares exactly, and so does the command against the encoder's own draw. Why: the device converts a fragment function's float to the attachment's codes, which Vulkan leaves to it at a half step, and the RTX 5080 stores 0.5 as 0x7f, recorded by the pipeline as `PrecisionNote::DeviceColorConversion` (docs/API.md's catalogue names this very case). On the 5080 the case "less, behind a draw" read (127,127,127,127) in all 16 texels against Metal's (128,128,128,128), at development |
||
|
|
62325fb38f |
Take either code nearest a half step in the clear-reach lane's cleared red, where the clear is not Metal's
What: the clear-reach lane's color passes clear to (0.5, 0, 0, 1), whose red is 127.5 codes of an 8-bit unorm channel, a half step. Its texel checks (`Lane::assert_texels`) now take either nearest code, 127 or 128, in that channel of a cleared texel on a device without `DriverFact::ColorClearIsMetals`, and Metal's 128 alone on one with it (MoltenVK on an Apple GPU). Every other channel, and every texel the pass drew or kept, compares exactly; a failure names how many texels differ and the first one's coordinates instead of printing both images. Why: Vulkan leaves the conversion of a half step to the device (the float-to-unorm conversion takes either of the two closest codes), and the RTX 5080 stores 127 where Metal's clear stores 128. The runtime already announces it, as `device-color-conversion` for a clear whose rounding is in question (`render_pass::degrade_clear_conversion`, `clear_value::rounds_apart`; the `renders` lane holds such a clear within a code of Metal's and announced). The four tests that failed on the 5080 (`a_clear_reaches_past_the_render_area_as_metal_s`, `colors_whose_clears_reach_alike_record_inline_over_their_reach`, `depth_stencil_and_multisampled_clears_reach_past_the_render_area_as_metal_s`, `a_pass_that_changes_no_texel_records_nothing`) failed on that code alone (measured by the staging stream); the reach and the inline recording they check are unchanged. How verified: builds (--cfg m2v_gpu, debug). Not yet run on the 5080 or the M3. (cherry picked from commit b72f2059747aa688194f967e1aee546d63f7ebee) |
||
|
|
ba4ca15574 |
Declare the RTX 5080's linear clear copies on the pass-start barrier rows over a buffer
What: the five small pass-start-barrier rows over a buffer declare `linear-attachment-clear-copies`, and the module docs say what the RTX 5080 Laptop announces. Why: the 5080 renders a target over a buffer's bytes as a linear image (`VK_NV_linear_color_attachment`) and clears it through an image of the device's, announcing the notice on those five rows; it was their only difference there. Every texel was accepted (the Mac2 answer on the barrier rows), `render-pass-split` and `shared-in-system-memory` fired as declared, and the display row's read took no split. How verified: the 5080 replay at 8ce6ed8262 (potluck m3-max-55, exact and default policy) named exactly these five rows at case/notices; the unit tests of the case and the suite's recording, cost and timing checks pass (7/7). A 5080 replay with this declaration is not yet run. (cherry picked from commit e9a0d7e0eef5a4e8061f42b14c8d0ea132cd2d23) |
||
|
|
215a9f7583 |
Time the pass-start barrier family on the M3 Max, and count it in the conformance coverage
What: `conformance times --runs 8 --write` over the 13 pass-start-barrier cases keeps both legs' figures in their recordings, and docs/CONFORMANCE-COVERAGE.md is regenerated (scripts/conformance-coverage/coverage.py): 1141 recordings in 153 case modules, and `MTLBarrierScopeRenderTargets` now compared. Why: `times::every_case_carries_its_timing` holds every case to a timing record, and the coverage doc is derived from the recordings and the suite's sources. How verified: potluck job m3-max-37 on the Apple M3 Max, debug build, exit 0: 13 cases carry their timing; 4 within 10x, 9 unmeasured because our leg announces render-pass-split (and the display row two more), so its work is not Metal's. The host's load was 188 while Metal's leg ran, so the margin is reported, not judged. coverage.py --check passes. (cherry picked from commit 8ce6ed8262789fb7887794bb7073eb63dbed249e) |
||
|
|
88eeb91987 |
Record the pass-start barrier family again on the M3 Max, in runs of rows
What: the 13 recordings, taken again on the Apple M3 Max (macOS 27.0.1, 26A434), plain Metal and the validated leg, with the texels in the family's runs-of-rows encoding. Why: the encoding changed in the commit before. The chain's recording goes from 1.46 MB to 26 KB; the family's 13 from about 1.9 MB to 435 KB (the display row's grows from 151 KB to 230 KB: its mask's code changes every row inside the scissor, so its rows do not repeat). How verified: `conformance record` exited 0 (potluck job m3-max-24). Decoding the old runs and the new rows, every texel site of every recording holds the same bytes as the recording at 724afbf80b, and every other site but the inputs is unchanged. (cherry picked from commit 66ede219fefe99ced5ee8771bb7a819a176d323b) |
||
|
|
8e8ee31288 |
Record the pass-start barrier family's texels as runs of rows, and declare its notices
What: each target's texels are recorded as runs of equal rows, each row as its runs of equal texels (`texel_rows`, lossless; `the_rows_rebuild_the_bytes_they_came_from` holds it over every answer the rows state and an image with no two equal neighbours). The cases declare the notices the runtime announces for their shapes: `render-pass-split` on every row with a barrier, and `dont-care-load-tiles` and `shadowed-texture` on the display row (its earlier `DontCare` pass, and its mask over a buffer's bytes). Why: a read through a scissor changes the answer twice a row, so runs of texels alone held two runs a row: 1,042 per target of the chain, a 1.46 MB recording for three targets. The notices are the only differences the replays found: Apple M3 Max (MoltenVK) and lavapipe (LLVM 23.1.1), exact policy and defaults, at 724afbf80b, with every texel accepted (the Mac2 answer on the barrier rows, Metal's on the others). How verified: builds. The recordings are in the old encoding until the family is recorded again on the M3, in the next commit; unit tests not yet run. (cherry picked from commit 1e56926a709bce4f0f7e3658f0b705a1e7de1d52) |
||
|
|
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) |