155f97fbfdd67019bb35d3a3265cc5d94ce11da5
189
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
3369c52a3c |
Windows: dead fd/dma-buf helpers unix-only; examples' pages and CPU times on Win32
The fd and dma-buf helpers, fields and test hooks that only unix code reaches are compiled on unix alone, so the Windows build carries no dead code. The examples' anonymous pages use VirtualAlloc/VirtualFree/VirtualProtect on Windows and their thread and process CPU times GetThreadTimes/GetProcessTimes. Verified: cargo fmt; the Windows and Linux clippy rounds follow as jobs. |
||
|
|
7ba0cd9fe6 |
RUNTIME 2343: GPU times placed by a calibration still beyond 20 us are announced and counted
A calibration pair is read again while the smallest deviation so far
states more than 20 us (`gpu_time::SETTLED`), four readings at most
(`least_deviation`). Where the least of four still stated more (93 and
125 us on the RX 7900 XTX under full parallel suites: a reading's
deviation holds the time its thread spent off the CPU), the runtime
placed the command buffer's GPU times by it, inside the command
buffer's life, with up to that error, and said nothing. Owner rule 2:
a near-equivalent is recorded and announced.
`GpuClock::span` now answers `Placement::Loose { deviation }` where the
pair places both times inside the life and its deviation exceeds
`SETTLED` (a pair outside the life is still set aside as before).
`Placement::read` gives the notice for every placement the first read
of a command buffer's GPU times announces, counting a loose one:
- new kind `Degradation::LooselyCalibratedGpuTimes`,
`loosely-calibrated-gpu-times`, class Precision, announced once per
device at the read (the site `uncalibrated-gpu-times` uses), its
reason stating the deviation; not `uncalibrated-gpu-times`, whose
cost says the times are placed by the completion, where these are
the pair's, the duration exact;
- new `WorkCounts::loosely_calibrated_gpu_times`: command buffers
whose times a read found placed so, counted at the read that
announces, so the count is nonzero exactly where the kind was
announced.
Tests: `tests::gpu_time::a_pair_still_beyond_the_settled_deviation_is_
announced_once_and_counted` feeds `least_deviation` a fake source of
four readings above 20 us (Loose, the kind with the deviation in its
reason, each read counted, announced once) and settled ones (Iris
Xe's 165 then 7.6 us; 20 us exactly: Calibrated, nothing), and a loose
pair outside the life (Disagreed, the uncalibrated kind, not counted).
The lane's `gpu_times` expects the kind exactly where counted, and holds
the count nonzero exactly where `calibration_deviation_most` exceeds
the slack (no disagreement); `read_kinds` adds it where counted
(mesh_draws), `disagreeable_kinds` allows it (first_use); a site const
`LOOSE_GPU_TIMES` takes it. The conformance cases that read GPU times
(`command-buffer-facts`, `empty-command-buffers`) allow its notice:
the host's load decides it, and every value still compares exactly.
docs/API.md's catalogue lists the kind; api_signatures.tsv blessed.
|
||
|
|
744dfd4d9d |
RUNTIME 2314: A host step's rate-map probe runs in parts, each on the GPU while the host records the next
A rate-mapped pass whose records the GPU may write is recorded by a host step that fans its triangles out to the map's regions after a probe: every command's draw recorded once more through the probe variant, submitted, and waited for before the routes are recorded. The host recorded the whole probe with the GPU idle, then sat idle itself for the probe's whole GPU time. On a 3D renderer's frame on an RTX 3090 (pin 91b) that wait was 23-35% of host_step_nanos, 5-7 ms of a ~22 ms step, three steps a frame. Now the probe is recorded in parts: at least 32 commands a part and at most 8 parts a probe (DeferredPass::probe_parts). Each part is submitted with its own fence once recorded, so the GPU runs it while the host records the next, and the host waits once, for every fence, after the last part (CommandBuffer::submit_fenced / wait_fenced, the halves of rerun::submit_waited, which the predicated loop's runs again keep using). A part may hold commands of several executions; its draws take the flag words one recording would give them (the index carried from part to part, each command's slot by its place among its execution's commands that run), so the probe's words, the routes and the pixels are the same in any parts. A probe that stops (a barrier, a draw that writes memory) stops for the rest of its execution; a part recorded in more than one run sends the execution region by region, as one recording did. Every part submitted is waited for before the step goes on, a failed later recording's too. Ordering: the parts go on the command buffer's own VkQueue, in order, and each part's primary begins with the segment's full barrier (EncoderCore::segment), as the one probe's did, so part k+1 follows part k and the pass follows the last; no semaphore and no other queue's edge is added. Cost: up to 7 more submissions and probe render pass instances a step (load and store in GENERAL, no fragment). WorkCounts::rate_map_probe_parts counts the parts; rate_map_probes stays one a step; rate_map_probe_gpu_nanos sums the parts' times; rate_map_probe_wait_nanos is now the host's one wait after the last part. Test: tests::rate_mapped_fan_out's a_host_step_probes_many_commands_in_parts: 72 commands (the eight's pattern nine times) probe in 3 parts with the same flagged, fanned-out and parted draws, each 9 times the eight's, and the encoder's pixels; the eight-command test asserts one part. The workload takes its command count. New WorkCounts field: rate_map_probe_parts (api_signatures blessed). No new Degradation kind. No RUNTIME_VERSION bump (main does it at landing). Also in this landing: the icb_reads example's --rate-map and --wide-every W (the A/B shape); the parts' recordings joined once, after the wait; and the split fenced wait reaching the device's functions inside each exit-guard section (a predicated loop's run again on the loop thread). RUNTIME_VERSION moves: a host step's probe of an unchanged artifact is now recorded and submitted in parts. Verified (lane icbstep2, msi lavapipe): - m3-max-30234 at c41586a13d: clippy -D warnings plain and cpu_icd (runtime, all targets, all features) exit 0; 63/63 for rate_map|rerun_arenas|indirect_command_buffer|icb_|host_step| fan_out, among them the ordering tests a_flagged_draw_s_parts_take_each_triangle_once_in_order, a_host_step_s_instances_follow_their_commit_in_the_program_s_order, a_recovery_s_carry_waits_for_a_write_without_the_lock and an_unshared_head_at_its_host_step_goes_before_work_whose_room_came_after_its_commit; the new a_host_step_probes_many_commands_in_parts reports probes [1,36,36,36], 3 parts and 5 submissions, with the encoder's pixels. - Negative control m3-max-30241 (one part a probe): the new test fails, "the probe's parts of 32, 32 and 8 commands, left: 1 right: 3", with the same probe counts. Expected, not yet measured: the 3090 release A/B (host_step_nanos and rate_map_probe_wait_nanos a step) follows. The consumer's renderer run at the next pin is the workload proof. |
||
|
|
483b4650d1 |
fixed_index_draws example: a frame of indexed draws whose indices a dispatch before each draw writes
What a GL-on-Metal layer's frames cost the GPU where a compute dispatch before each draw fixes up that draw's index buffer (each dispatch writing a Private buffer of its own, in serial compute encoders of 256 dispatches, then render passes of 26 indexed draws, 4 passes a command buffer), beside the same frame with the indices written once before (prefixed) and the compute encoders alone (dispatches). The defaults follow a GL benchmark's per-second counts on the runtime (about 470 compute encoders of 256 dispatches, 4,650 passes of 26 draws, 1,270 command buffers). The kernel and the draw's functions are a new owned MSL fixture, fixtures/public/examples/fixed_indices.metal, compiled by regen-air-fixtures --dir examples. Release measurement on an RTX 5080 Laptop GPU (b5080 entry glfix-framesplit-124152; GPU busy per frame, union of command-buffer spans, median of 60 frames; a frame of 1280 draws): - fixed: 0.526 ms; - prefixed: 0.404 ms; - compute encoders alone: 0.116 ms (0.09 us a dispatch). fixed minus prefixed equals the dispatches' own time, so the compute-to-render transitions and the extra command buffers cost about 0.006 ms a frame. No runtime source changes; the runtime pin moves alone. Verified: msi m3-max-30123 at 195f2073fd: - runtime crate clippy -D warnings --all-targets --all-features, plain and --cfg m2v_cpu_icd: 0; - release build: 0; - a lavapipe run of all three shapes: the index check passed after each. |
||
|
|
160837e4e0 |
Rebound draws gather shadow uses that differ from the kept draw's instead of stopping
A draw rebound that was not carried in went on only where its uses of shadowed
textures (ShadowUse::used_as: the shadow, writes, area, own-pixel read bounds)
equalled its kept draw's, since it gathered nothing into its instance. Another
shadow at a changed slot, or own-pixel bounds that follow a restated scissor,
stopped it, and the draw took every step. That is the largest rebind stop in the
780M desktop walk (draws_rebind_stopped_arguments_shadows 62,642 of 98,870
stops; Launchpad 24.1k, Mission Control 26.6k).
Now such a draw gathers its own shadow uses into its instance as every step
does (shadow::join, through InstanceShadows::add, or InstanceShadows::join for
a narrowed draw), as a carried draw already did, and keeps them as the uses the
next draw rebound compares with. It still stops where it uses some and its kept
draw used none, or the other way: Kept::again follows that. A new check stops a
draw that reads a color's copy after a barrier inside its instance (counted
_checks): every step splits there or weighs the spare, and only the shadow stop
kept such draws out before. The debug rebound check compares a ninth part, the
draw's shadow uses against its every step's.
kept_shadowed_draws: the kept frame's commands recorded (every kind) and copies
equal the every-step frame's; its second-target and scissor draws rebound
instead of stopping; a lane of draws of other arguments (base instance
alternating) rebinds every draw after the first; a lane across a barrier stops
at the new check, with the split and texels of every step.
Also: examples/draw_costs gains a "backdrops" shape (every compositor draw reads its pass's colour
at its own pixel under its own scissor), which the A/B below uses.
No new WorkCounts field or Degradation kind. No RUNTIME_VERSION bump: the commands, copies and
pixels are those every step records. The runtime pin moves alone.
Verified (msi lavapipe):
- Base repro m3-max-29949: the kept frame had as_before 2, rebound 0, stopped 2.
- kept_shadowed_draws, 4 lanes. Each compares the kept frame with an every-step frame on pixels,
copy counts with copied texels, and the recorded command map. At the tip:
- plain lane: stops 2 -> 0;
- other-arguments lane: _arguments_shadows 2 -> 0;
- a lane where the rebound draws are the last to use a shadow: _shadows 3 -> 0;
- barrier lane: _checks 1, with 1 split.
- Negative control m3-max-30008, by hand:
- restoring the stop fails 3 lanes (_shadows 2/2/3);
- removing the gather fails 3 lanes on copied texels (1124 vs 2048) and on the last-use lane
(copies 1 vs 2, texels 525 vs 1313).
- Release A/B m3-max-29983/30002:
- base
|
||
|
|
e0744825a5 |
A replayed draw walks its plan's heap members and its resident uses once, not at each draw
A plan's descriptor writes and uses number one for each resource its heap
reaches (every texture an encoder made resident, in each heap array), and a
draw's uses begin with those of everything its encoder made resident. Three
per-draw checks walked them at every draw, though their answers are fixed for
the plan or for the resident uses' identity, so a host step's replay of an
indirect command buffer paid every resident texture at every command:
- binding::binds_own_zeros (every write of the plan) is now a fact of the plan,
worked out as its pipeline state settles it (PlanFacts::own_zeros);
- the read-twin slot proofs (read_only_slot / read_only_buffer_slot, a walk of
the plan's uses and writes for each slot) are worked out once for the plan,
the first time a draw asks on a device with read twins, and kept in its facts
(binding::TwinProofs, which replaces TwinSlots::of with TwinProofs::slots); a
command's own uses name no slot (debug-asserted), so the proofs are the
plan's alone. A dispatch works its out per dispatch, as before; a test's
device that binds twins unproven proves them at each command;
- EncoderCore::note_draw's check for a write of a read twin walks the uses of
what the encoder made resident once for their identity (ResidentPrefix,
process-unique; the same uses wherever it is) and the draw's own uses past
them at each draw (refuses_twin_write_past).
render.rs and render/draw_again/rebound.rs change one statement each at their
call sites (facts.twins().slots, facts.own_zeros()).
Test: tests::resident_uses's
draws_walk_their_plan_and_resident_uses_once_however_many_textures_are_resident
counts, on a device with a read twin, the plan walks and twin-write checks of
each draw with 0 and 64 more textures made resident: the first draw walks
more with more, every later draw the same and nothing of its plan.
Also: examples/icb_reads gains a gpu-step shape (`icb_reads --only gpu-step --heap-textures H
[--no-twin] --runs 9`), a host-stepped execution of textured draws a kernel writes, reading its
textures through a material argument buffer over a heap. It prints host_step_ns_per_command.
No RUNTIME_VERSION bump: the same commands and answers, worked out fewer times. The pin moves
alone. No new Degradation kind or WorkCounts field; the walk counters are test-only.
Verified:
- msi m3-max-29962 at be9eff60d2 (runtime crate, --all-features --all-targets, -D warnings):
- clippy plain, --cfg m2v_cpu_icd and --cfg m2v_gpu: 0;
- rustdoc: 0;
- 134/134 touched tests on lavapipe: resident_uses, draw_again, read_twin_device, twin_reads,
twin_flights, shadow_twins, host_step_neutrals, icb_carry_race, icb_records_home,
indirect_command_buffer and its device suite, kept_heap_uses, carried_draws,
neutral_zeros_shared.
- Negative control by hand (m3-max-29957): the count test fails. Per draw, 147 plan entries walked
and 11 uses checked with 0 extra textures, against 531 and 75 with 64.
- Release A/B (m3-max-29960, msi lavapipe):
- base 5608c77dbb md5 65c9a10d, tip 0aae380fcc (this fix before its clean rebase) md5 197ac4e6;
- own target dirs, P-cores, 3 interleaved rounds, 8192 commands a step, medians of 9.
Host-step ns per replayed command, base -> tip:
- H=8: twin 3851 -> 3839, no twin 3866 -> 3811;
- H=512: twin 4676 -> 3881, no twin 4268 -> 3864;
- H=2048: twin 7533 -> 3991, no twin 5845 -> 3981.
At the tip the cost is flat in H.
|
||
|
|
73b97e1e0c |
A draw after scissor rectangles alone restates by them alone
A render-state call drew one fresh stamp, so a kept draw's next draw after set_scissor_rect(s) ran restate_kept in full: the route and DrawSettings again (compared by value), the pipeline clone, the fragment tests, the depth/stencil descriptor, the shape-memo lookup and clone, and two FixedState compares, only to take new Vulkan scissors, which none of those read. Compositor shapes and the walk set a scissor before nearly every draw. What changed: - The encoder's render-state stamp is now a pair (`Stated`): `set`, drawn afresh by every render-state call, and `beyond_scissors`, drawn afresh by every one but set_scissor_rect(s) (`log_restating_scissors`). - `Kept::restates_by_scissors`: whether the kept draw's route meets every condition a restate asks (no failing state, no hidden depth/stencil, no restart strip, provoking vertex as-is or native), set where every step keeps the draw and where a full restate succeeds, so the debug Kept comparison holds. - A draw whose kept draw's stamps differ in `set` alone, of such a route, takes the encoder's scissors into its kept recording's draw state (as a draw that finds its state in the shape memo takes them) and derives nothing else; every other restate is unchanged. New WorkCounts field: draws_restated_scissors (counted at each such restate, a debug check turn's too). No new Degradation kind. Test: draws_after_scissor_rectangles_alone_take_them_alone (runtime tests/draw_again.rs): 8 draws again after scissor sets alone restate by them alone, rebound, with the same commands, state commands and pixels as every step; a viewport set before one draw takes the full restate, still rebound. In debug builds every second rebound draw takes every step and compares the draw state the restate left. Verification follows on msi (lavapipe, potluck). Recorded commands are unchanged (the draws rebound record the same commands, state commands and pixels as every step), so RUNTIME_VERSION stays and the runtime-sources pin alone moves. Verified (msi, lavapipe): m3-max-29822 clippy plain and --cfg m2v_cpu_icd 0, 103/103 of 20 touched modules incl. draw_again::draws_after_scissor_rectangles_alone_take_them_alone; negative controls m3-max-29825: fast path off reads 0 against 8; stale scissors trip the debug rebound check. Release A/B m3-max-29845 (7 interleaved rounds, medians a draw): compositor 57,172 -> 55,820 instructions, 8.81 -> 8.64 us (1216 of 2237 restates by scissors alone); pass17 33,003 -> 30,783, 4.48 -> 4.18 us. |
||
|
|
7325cef772 |
Spare command pools: take before making, in sections too, each pool up to 32 of a level
A command buffer whose pools handed out every VkCommandBuffer of a level they held now takes the spare holding the most of that level from its first hand-out on (before: only past 16 handed out, making the rest in its first pool), and inside a section of the exit guard (the scheduler's barrier command buffers, a host step's recording) it takes a spare whose command buffers need no reset (before: no spare at all). Where no spare holds one, it makes it in its last pool, up to POOL_HOLDS (32) of the level there, past which it takes a pool for more (a spare holding none of the level, or a new pool). HELD stays the hard bound; idle sheds and recent-uses frees are unchanged; no new switch. Why: under command buffers of fenced one-dispatch compute encoders split into parts (a guest's fluid simulation's shape), the barriers' command buffers, made in sections, were 64% of the allocations and the first-pool makes 34%; the pools grew past what was in use at once to HELD, and each give-back shed the oldest pool whole, which the next takers made again (45,914 made over 30 rounds of 200, about 1,250 a round, on lavapipe). On RADV each made VkCommandBuffer is a new buffer object with cleared pages. New WorkCounts field: command_buffers_made (vkAllocateCommandBuffers' count), POOLED in the conformance cost table. Tests: tests::spares unit tests take `settled` and a new one checks a section takes only a spare that needs no reset; the device test of a small and a large command buffer now asserts none is made where the spares hold them; tests::spares_parts (device): fenced command buffers 16 in flight make none once warm and hold at most the in-use bound; a load that falls sheds down. No answer, refusal or recorded command changes (only which VkCommandBuffers the spares hand out), so RUNTIME_VERSION stays 2305 and the runtime-sources pin alone moves. A/B (msi lavapipe release, m3-max-29720, spares_compute_parts: 200 command buffers a round of 2-120 fenced one-dispatch encoders, 48 in flight, rounds 6-30, two interleaved runs): command_buffers_made 1,498/1,448 a round -> 8.8/4.3; spare_command_buffers_shed 1,460/1,447 -> 0; spares held pinned at HELD -> 3,251/3,263; committing thread CPU per command buffer -7%/-6%, scheduler -4%/-8%, queue waiters -12%/-9%, free thread to 0; anonymous RSS at round 30 187/190 -> 71/74 MiB. Control (sections take no spare): 2,189/2,305 made a round, fails the steady test. Verified (m3-max-29776 at 2a5db4d65e, msi): clippy runtime+conformance plain and --cfg m2v_cpu_icd 0; tests::spares and spares_parts 26/26; conformance cost 0; signatures 0. |
||
|
|
d8666d430f |
RUNTIME 2302: render encoders record into the VkCommandBuffer of the encoders before them
A render encoder took a VkCommandBuffer of its own at every open, so a compute, render and blit step began 2.71 and submitted 4 VkCommandBuffers per step (dispatch_chain renders, lavapipe). A render encoder with a log of its calls now takes part in the encoder fold: - One whose pass records at its end (draws in a secondary) joins the group before it; one whose first instance records inline joins none and may lead a group. - No barrier records inside a pass: a joined render encoder records one barrier from everything of the group's earlier encoders (FoldOrder::everything) at its open, counted in command_barriers. - Color groups, rasterization-rate maps and a depth attachment out of GENERAL take no group; segments, fence updates and Overwrites end the group after the encoder. Logless devices keep one VkCommandBuffer per render encoder. - A folded member's layout moves go before its group's first part (GroupPlaces). - A check splits a group with a render member at its pass's submission (as RUNTIME 2297 does for blits). - A group's order is built as its second encoder joins, not as its first ends. A/B (lavapipe, dispatch_chain, per step, base vs tip): renders 2.71 -> 1.35 VkCommandBuffers begun, 4 -> 2 submitted, GPU 119.5 -> 97.7 us; renders-apart 3.71 -> 1.00, 4 -> about 0, 143.6 -> 94.6 us; passes unchanged in buffers, the encoder's open about 250-480 ns more on the host (the group an inline pass begins), the whole pass within the host's noise. Tests: tests::render_fold (device), tests::held_depth, shadow_runs' rebind expectation (a rebind encodes a group whole). Docs: encoder_fold.rs, API.md, FAST-PATHS known gap and ANV row. Verified (msi, lavapipe): the full runtime suite 2683/2684 at c502efba29, the one failure the race test fixed in ca5042567b; clippy plain and --cfg m2v_cpu_icd, rustdoc, fast_paths 0. Negative control (the explicit order removed, renderfold-negctl): the hazard tests fail on their barrier counts; lavapipe shows no wrong texel because it completes each command as it runs, so the texel proof is a GPU that overlaps work. |
||
|
|
8b20339b4b |
draw_reads and dispatch_chain: commit-to-completion time beside the GPU time
Examples only (neither is a consumer's example). Both now also print, for the runtime's shapes, the median time from the commit to the command buffer's completion on the host: draw_reads as wall_us_per_draw, dispatch_chain as wall_us_per_dispatch. That time also holds the GPU work the runtime records before the command buffer's own, such as host calls' staged copies (command_buffer/submit.rs), which the command buffer's GPU time does not show. draw_reads also takes --idle MS, which leaves the device idle that long before each run's encoding, and prints each run's encoding time (encode_ms, median and most): on a GPU that powers down when idle (the RTX 5080 laptop GPU after about 20 s) an encoding that waits for it to wake shows there. These are the figures the arena mirror experiments were judged by; the mirror itself was dropped (its A/Bs on the 3090 and 5080 left a measured shape slower in every form). Verified: msi build and clippy follow. Verified: msi m3-max-29465: release build of both examples 0; clippy -p metal2vulkan-runtime --all-targets --all-features -D warnings 0. |
||
|
|
eed5f3d84b |
SEMANTICS 2111 / RUNTIME 2296: indirect command buffer GPU work touches only the bindings a descriptor counts
A record holds 128 buffer bindings (4 stages x 32 slots, 2 KiB) whatever its descriptor counts. The draw replay's preprocess read all 128 of every command to refuse a binding set past its stage's count, the compute replay all 128 for its inheritance check, and a GPU reset (air.reset_*_command) wrote all 2248 bytes of the record. On a discrete GPU those reads crossed the link. A binding past its stage's count is zero in every record: the storage is made zero, an encoder's write past the count faults and writes nothing, the CPU's setter refuses one, a compute command has no other stage's setter, and a copy takes a source of the same descriptor. So: - the render preprocess reads a binding only below its stage's count and writes a slot table entry past it as null, unread; - the compute replay reads the kernel bindings below the header's count alone (clamped to 32) and writes the entries past it null; - a GPU reset writes the command's words (64 B), the bindings below each stage's count (16 B each) and the words past the bindings (136 B). The replay's check of a binding set past the count goes: it never applies. Tests: interpreter (metal2vulkan) render and compute cases with garbage past the counts draw/dispatch as without it, the same garbage in a counted slot is refused (negative control); a reset clears the command words, counted bindings and tail and leaves a mark past the counts, where no reset leaves every stale byte (negative control). Runtime device test: a GPU reset, an encode of the even commands and an execution leave the odd commands empty and draw the even cells alone; without the reset every command keeps its earlier draw (control). icb_reads gains a gpu-reset shape. Verified: msi m3-max-29281 at the tip: clippy -D warnings (all targets and features) 0, interpreter tests 72/72, lavapipe ICB/indirect 34/34, m2v_gpu build 0. 5080 (b5080 entry, at the change before a test-only lint fix): device ICB/indirect 34/34; icb_reads 8192 commands, GPU us a command, two alternated rounds: gpu-shared execute 0.0295/0.0171 -> 0.0109/0.0109, gpu-reset encode 0.0143 -> 0.0031 and execute 0.0130 -> 0.0109, gpu-private execute 0.0169 -> 0.0107, cpu-shared unchanged. The 780M A/B follows. |
||
|
|
5dd3668a4f |
RUNTIME 2294: indirect command buffer records are placed by first use on discrete GPUs
On a device without unified memory, an indirect command buffer's records lived in host-visible system memory. A kernel writing 8192 records and the render encoder executing them both crossed the PCIe link: on a 3090 behind an x4 link, 17 ms and 26 ms a frame at the link's ceiling, where device memory takes about 0.004 and 0.03 us a command. Now the first use decides where the records live: - a GPU use (an encoder executing, encoding through an argument buffer, or a blit resetting, copying or optimizing it) places them in device memory, written with a header and zeroed flags through the staging queue; - a Shared buffer's first host access moves them to host memory once, while no unfinished command buffer holds them: an empty move when the GPU wrote nothing, else one copy waited for; - a host access while a command buffer holds them, and every host access of a Private buffer, is staged through the staging queue (read back, written back), counted and announced once per device as the new `staged-indirect-records` (performance) degradation. The host never writes device memory. Every encoder use takes a hold that its command buffer drops at completion. Counters: icb_records_moved_to_host, icb_record_bytes_moved, icb_records_staged_accesses. docs/API.md has the catalogue entry; the API table is re-blessed. Tests: src/tests/icb_records_home.rs (GPU-encoded Shared records stay on the device across executions; CPU-encoded move once with no bytes; a getter after a GPU encode moves the bytes; Private records never move; a held buffer stages until its holder completes; a blit reset between GPU encodes keeps them on the device, with a reset-then-execute negative control) and a runtime-lane test for the Private form's notice. Verification: the msi build, clippy and the lavapipe and 5080 runs follow in the next commits' messages. Also: examples draw_reads (the GPU time a draw pays for reading its own data: bytes, a bound buffer, a pointer resolved in the resident set) and icb_reads (an ICB's records' cost on the GPU and host, GPU- and CPU-encoded, Shared and Private). Follow-ups folded in: placing fills only the storage's bytes; a setter's in-place access allocates nothing and its batch carries the access in two words. New Degradation kind: staged-indirect-records (Performance, once per device; docs/API.md catalogue: touch a Shared ICB from the CPU before the GPU uses it, or use Shared rather than Private for CPU access). New WorkCounts: icb_records_moved_to_host, icb_record_bytes_moved, icb_records_staged_accesses. api_signatures.tsv re-blessed; refusal surface unchanged. Verified (arenavram): msi m3-max-29217 at bd9994a6a3: clippy plain (runtime + validation, all targets/features, -D warnings) 0; lavapipe ICB/indirect/degradation/carry tests 65/65. m3-max-29188 at 0980b78c47: clippy plain/m2v_gpu/m2v_cpu_icd 0, rustdoc 0, lavapipe 65 + icb_records_home 6 + catalogue/sites + 30 lane tests, api tables 15/15. 5080 (m3-max-29179) at 87ea86309b: 95/95 incl. the 6 icb_records_home tests (GPU-encoded Shared stays, 0 moves; CPU-encoded moves once, 0 bytes; getter after a GPU write moves with bytes; Private never moves and is staged; held then staged then moved; blit reset between GPU encodes, with a negative control) and runtime_lane::blits::private_indirect_records_follow_the_memory_model. 3090 A/B m3-max-29178 (base 17a0355935 md5 cac5b460 / tip 87ea86309b md5 4322acb2, two alternated rounds, 8192 commands): GPU-encoded Shared encode 0.448 -> 0.0039 us a command, execute 3.03 -> 0.031; link rx about 3-4 GB -> 12 MB a shape run; tip counts moved 0, staged 0. CPU setters on lavapipe: base vs tip within noise at bd9994a6a3 (not separable; not shown zero). The suites run after landing. |
||
|
|
12cd9c6f79 |
RUNTIME 2293: blit encoders fold into the shared VkCommandBuffer as compute encoders do
A command buffer that mixes compute and blit encoders (the image workloads:
Photo Filter, HDR, RAW) began a VkCommandBuffer for every blit encoder, which
also ended the compute encoders' fold: dispatch_chain's blits shape (200
one-dispatch compute encoders each followed by a blit copy) went to the queue
as 799 VkCommandBuffers in one vkQueueSubmit (542 begun) on lavapipe, against 1
for compute encoders alone. On ANV each begin costs 16-20 us of host time.
A blit encoder now joins the group of encoders its command buffer's tail holds
by the rules compute encoders follow (encoder_fold.rs): same batch, the earlier
member one part with no segment, no fence update and nothing failing, no
command predication yet, the encoder trail off, protection options 0; a
compute encoder joins where the group's compute encoders are of its dispatch
type (Joining::{Compute, Blit}). Blit commands take the per-command FoldOrder
barrier through track(). What differs for blits:
- Blit encoders now always log their calls (replay.rs), as compute encoders
do, so a failure that splits a mixed group encodes its running members
again apart.
- A blit encoder ends a unit of command predication, so a group can hold two
units' compute encoders: an unbalanced record whose left-out work begins
past the group's first encoder (State::left_out_from, set by
leave_out_ended) now splits the group at the commit as a partial failure
does, the shared VkCommandBuffer never submitted. split_failure and the
rebind's encoded_together take one check, State::encodes_again_apart: no
predication, a non-compute encoder, or Predication::alone. A rebind in a
command buffer that used predication now encodes a group again where each
member is alone, where before it refused (EncodedUseRebound).
- An encoder whose part writes an ASTC carrier (its second twin's decode goes
after the part) or notes an Overwrite (judged by its part's summary, which
a group widens) ends its group. A folded blit's Overwrite goes to the
group's first part only where every earlier member is a blit encoder that
named nothing of the texture (Fold::overwrites_join), which is what
first_overwrites decided before folding.
- Spares tests that need one VkCommandBuffer per blit encoder update a fence
in each.
Tests (tests::encoder_fold): a compute/blit/compute chain is one
VkCommandBuffer with every copy and read right; an event signal, a dispatch
type change across a blit, predication, a whole-texture overwrite and an ASTC
carrier write each end a group; failures inside a mixed group run exactly
the encoders they leave; an unbalanced End past a group's first encoder
splits it; a rebind encodes a group again in a predicated command buffer.
Also: dispatch_chain gains the `blits` shape (a blit copy after each one-dispatch compute encoder)
and the `copies` shape (a command buffer of blit encoders only).
Verified (blitfold, msi lavapipe): m3-max-29164 at 5845456c61: clippy (runtime, cfg m2v_cpu_icd,
all targets/features, -D warnings) 0; 185/185 including the encoder_fold tests and
a_rebind_encodes_a_group_again_in_a_command_buffer_of_command_predication (the narrowed refusal:
words right, reencodes_refused 0; REFUSALS.md regenerated, unchanged). A/B m3-max-29165 (own target
dirs, md5 c2157758 base 45fdc3e601 / a2214763 tip, ABAB): VkCommandBuffers begun/submitted per Metal
CB, 200 dispatches: blits 542/799 -> 1/1, copies 271/399 -> 1/1, encoders 1/1 -> 1/1; lavapipe GPU
us a dispatch blits 54.98 -> 37.35, copies 9.25 -> 2.36, encoders unchanged; host thread CPU blits
~-1.1 us a dispatch, copies even (logging ~+300 ns a blit encoder paid back by no new
VkCommandBuffer and a shorter commit). No WorkCounts field or Degradation kind. Negative control,
lint in the other configurations and the suites run after landing.
|
||
|
|
20f7e82bbe |
Runtime example shared_files: settle the submission checks first, print residency releases
The 780M run of the example (job m3-max-29062) reported 1,935 pieces joined in its 1,000-a-file phase where 999 were expected, and none extra in the 8-a-file phase before it. The import-tax verdict that turns on the residency's most of 64 releasable imports (`pointer_imports_tax_submissions`) is false until the device's submission check answers, and the example never waited for it: the check answered between the two phases, so the 1,000-a-file phase released the 936 (1,000 - 64) buffers past the most while they were made, and each joined its file's import again as its address was handed out. The first phase also ran beside the check's own work. The example now waits for the submission checks (Device::settle_submit_checks, 60 s) before its first phase and prints their verdict, and each line adds the imports released past the most and those imported again (host_imports_released_over_most, host_imports_reimported), so every join is accounted for. Verified: cargo fmt only here; build and clippy in the msi job that follows. Verified (dmagroup, msi m3-max-29088 at 633613136f): clippy -p metal2vulkan-runtime --all-features --all-targets -D warnings plain 0 and m2v_gpu 0; the example builds (release). Example only: no RUNTIME bump. |
||
|
|
045ae9caa8 |
RUNTIME 2290: pieces of a shared dma-buf file bind in one import of the file
On RADV every guest no-copy buffer and heap is a dma-buf import of its own
(the shared mapping's pointer is refused), and RADV lists every import in
every submission: the 780M's vkQueueSubmit cost ~0.45 us per live import
(the consumer's Super Resolution: ~1,010 imports, p50 531 us a submit).
The lever agreed with the consumer: a source answers pieces of files it
shares, and the runtime imports each file once.
- DmaBufChunk is { file: Arc<OwnedFd>, offset, length } (was { fd, length }).
A chunk at offset 0 whose Arc the runtime alone holds (Arc::try_unwrap) is
a dma-buf of its own, imported exactly as before; any other is a piece of
a shared file (dma_buf.rs Piece).
- DmaBufRequest gains `alignment` (the host page, a plain dma-buf buffer's
memory alignment, asked once, or the granule where the request may split)
and `shared_files` (false for an image's dedicated import, a guest RAM's
chunk and its probe, and a list of runs: those take a dma-buf of its own
at offset 0, as before). A misaligned piece, or one past its file, is
misuse (Invalid, Problem::DmaBuf).
- Each device generation keeps DmaBufFiles: the address of the file's Arc
(never the inode) -> Weak<DmaBufFile>, one import of the whole dma-buf,
dedicated to nothing, made with no lock held and entered under a leaf
lock (a racer's import freed). Each buffer's DmaBufPages holds one Arc
per piece; the last holder takes it out of the map under the lock
(Arc::into_inner) and frees it through its own device handle.
- A plain buffer binds at its piece's offset (Placement::dma_buf takes the
offset), a sparse one each piece at its memory offset.
- Residency keeps pieces: a dup of an own descriptor (counted against the
fd budget, as before), an Arc clone of a shared file (no descriptor).
- import_dma_buf borrows the descriptor (it always handed the driver a
dup).
- WorkCounts: dma_buf_pieces_joined, dma_buf_shared_imports_live (new);
dma_buf_imports counts imports made (own chunks and first pieces).
Tests: tests/dma_buf_pieces.rs (Piece classification, the map's holds, no device);
tests/dma_buf_shared_files.rs (device: four buffers over one file -> one import, three joined,
bytes and fills in their pieces, freed with the last; the negative control of own files; two pieces
of one file in a sparse buffer at their offsets; release and import again; a misaligned piece
refused). Example shared_files: the 780M submit-cost A/B (own files, 8 a file, 1000 a file).
Docs: dma_buf.rs module, with_dma_buf (a shared-file import is never dedicated: where a device
needs that, the buffer is a copy, the source not asked again), HostRam::with_dma_buf, HOWTO,
runtime README; api_signatures.tsv; REFUSALS regenerated (unchanged).
Public API change (runtime): DmaBufChunk { file: Arc<OwnedFd>, offset, length } (+Clone), was
{ fd, length }; today's behaviour is `file: Arc::new(fd), offset: 0` with no clone kept.
DmaBufRequest gains `alignment` and `shared_files`. No Degradation kind.
Verified (dmagroup, msi): m3-max-29050 at 51e7f6b569: tests 72/72 on lavapipe (--cfg m2v_cpu_icd;
Mesa 26.2.4 takes the no-pointer dma-buf route with /dev/udmabuf), clippy -p runtime -p validation
--all-features --all-targets -D warnings plain 0 and m2v_cpu_icd 0, example builds (release). Seen:
4 buffers over one file -> imports 1, joined 3, shared live +1; own files -> imports 4, joined 0;
sparse reverse-order pieces -> one import, bytes in order; misaligned (2048 vs 4096) -> Invalid
DmaBuf, nothing imported. The 780M submit-cost A/B runs after landing.
|
||
|
|
59fb0f9c93 |
RUNTIME 2289: Compute encoders keep a dispatch's instantiated commands with their bind state
A program that opens a compute encoder for each dispatch (Geekbench's compute workloads, and dispatch_chain's encoders shape) instantiated every dispatch's commands again. The dispatch memo goes when its encoder ends. The textures such a program binds in turn change the bind state at every dispatch, though a compute plan's commands read no texture binding except a texel buffer's range, a texture's in-place planes or a handle table's member. At development |
||
|
|
4308685df4 |
RUNTIME 2285: a compute encoder's memory barrier records the least barrier; a later uniform or indirect read takes its own
memoryBarrierWithScope: (buffers or textures) and memoryBarrierWithResources: on a compute encoder recorded Barrier::between_dispatches: COMPUTE_SHADER's SHADER_WRITE before COMPUTE_SHADER | DRAW_INDIRECT with SHADER_READ | SHADER_WRITE | UNIFORM_READ | INDIRECT_COMMAND_READ. On the 5080 that wide destination costs ~5 us a dispatch against 2.92 for the least barrier. - They now record Barrier::memory_barrier (COMPUTE_SHADER's SHADER_WRITE before its SHADER_READ | SHADER_WRITE) and note the rest (tracker::OWED: UNIFORM_READ, and INDIRECT_COMMAND_READ in DRAW_INDIRECT) as owed. Each later command of the encoder whose uses name one of those accesses joins one barrier from the shader writes to what it names, once per memory barrier (tracker::Owed::pay). - In a folded encoder the memory barrier no longer records the fold's everything barrier first: it touches no memory, and each later command takes its own order after the group's earlier encoders. - Metal's contract is kept: every access Metal makes visible after the barrier is made visible before the command that makes it. The runtime's indirect dispatch reads Metal's arguments in a compute preprocess, and its own dispatch-indirect after that keeps between_dispatches. - dispatch_chain gains --idle, raw-uniform, raw-indirect and the `barriers` shape. No Degradation kind or WorkCounts field. Verified (barriers): msi m3-max-28955 at 9e60497c42: clippy -p metal2vulkan-runtime --all-targets --all-features -D warnings 0; tests::tracker 82/82 including four new tests (least masks; folded first dispatch takes a serial encoder's barrier; indirect after a memory barrier takes DRAW_INDIRECT/INDIRECT_COMMAND_READ; uniform read takes UNIFORM_READ). Negative control (nothing owed): exactly the indirect and uniform tests fail (80/82). 5080 m3-max-28962, GPU us per dispatch median: raw-barrier 2.92 / raw-uniform 2.92 / raw-indirect 5.57 / raw-wide 5.83; the `barriers` shape base (md5 60b8244b) 5.82 -> tip (md5 37da5b03) 2.92, same command counts, words exact. Lint in the other configurations and the suites run after landing. |
||
|
|
aa6209cb10 |
RUNTIME 2281: dispatch tracking: a part's first command waits to be ordered; host aliases through the quiet
Two exact cuts of the host CPU a compute dispatch spends tracking its uses (compenc's profile of the
Geekbench-shaped one-dispatch-per-encoder chain, --heap: command_reaching/track ~1 us a dispatch).
- tracker.rs EncoderUses: an ordered encoder's part takes in its first command lazily. With nothing
before it, depend() over the empty map answers no barrier, so the first command keeps a copy of
its uses and reach and is admitted (inside_uses + admit, barrier none, as before) only when the
part's second command asks for a barrier; split() drops it. A one-dispatch encoder builds no
compare list, kept list or inside map. New WorkCounts::commands_ordered_inside.
- encoder.rs track(): each command works out its host-alias uses once, through the encoder's Quiet
(keys dropped exactly when the aliases' version moves: join, place, unplace, remap) into its kept
vector, as draws already did; plan_shadows / shadows_used augment only when the shadow sync reads
the uses (ShadowSync::reads_uses). host_alias_lookups 3.0 -> 0 a dispatch in the steady shape.
No accuracy trade (the same barriers and entries); no Degradation kind.
Verified (hosttrack, msi lavapipe, at b91091c75b = this content on
|
||
|
|
80b34d316c |
RUNTIME 2277: compute encoders bind through a bind memo kept with their bind state
compute::record bound every dispatch with no memo, so each dispatch worked out every view, sampler
description and host-page placement again. Render already binds through binding::BindMemo. Now a
compute encoder's own dispatches do too: the memo lives on LiveDispatch (compute/live.rs) and goes
on with the per-device spare LiveDispatches to the next encoder, holding its textures, sampler
states and host cells weakly. ICB executions and host steps stay memo-less.
- WorkCounts: bind_samplers_worked_out and bind_spaces_read (new); bind_views_worked_out now also
counts memo-less binds. api_signatures.tsv (+2). buffer.rs: KeptSpaces::of counts a miss.
- tests::compute_bind_memo: a moved views epoch, another sampler state (nearest vs linear on a 2x1
R32Float at u=0.5), and a rebound no-copy buffer each work their entry out again and read right.
Verified (bindmemo, lavapipe on msi, release dispatch_chain, one run each side):
--binds tex, 2300 dispatches: dispatch 3945 -> 2664 ns, encode 7153 -> 5254, thread CPU 7479 ->
5534 ns a dispatch (m3-max-28774 base
|
||
|
|
2af00f020b |
dispatch_chain: --heap-churn, --heap-kept, --live and --binds ptr, timed per command buffer
The host's time takes --heap-churn K: each command buffer makes K buffers in
an automatic Private heap of the example's own before it encodes, its
dispatches take them as the two read-only buffers, and they are let go after
it completed, as a program that takes a command buffer's scratch from a heap
does (Geekbench's Super Resolution, through MPS: about 3.3 heap buffers made
and 2.8 freed a command buffer). --heap-kept H places H more buffers in that
heap and --live L makes L of the device's own, living through the runs.
HOST-CB prints the calling thread's ns per command buffer by phase (make,
place, encode, commit, free) and each thread group's CPU, the scheduler's
among them. (--heap, compenc's, places the words and zeros in a heap over
host pages; the two combine.)
--binds ptr runs bump_ptr, bump_wide with its first zero buffer read
through an address the dispatch sets as bytes (a Holder of one pointer, as
an argument buffer holds it): its command buffers take a root table, and
the device's resident set of its live buffers resolves the load
(live_buffers.rs), so the live table is made at each command buffer while
the list changes each one.
These are steelbrain/livebuf's a4709341d7 and 9a6dceb14b on development,
renamed beside compenc's --heap (
|
||
|
|
bc1580095c |
dispatch_chain: --heap places the buffers in a heap over host pages beside the RAM's buffer
The consumer places a guest's buffers in a heap over the guest's RAM, beside a no-copy buffer over the RAM, so each use of the heap's bytes takes a use of the RAM's key too (host_aliases.rs's placements): the host-pages path reims's perf -a names per dispatch (HostAliases::augment_into, HostCell::lying, host_residency::Residency::exposed). --heap gives the host's time that layout, as draw_costs's --heap does. |
||
|
|
d166086d92 |
RUNTIME 2270: an encoder's open looks at the encoders ended since the open before, not every earlier one
Every compute and render encoder's open built what it starts with (the shadowed textures its command buffer's ended encoders made resident) from scratch: the command buffer's joined residency, then each ended encoder not joined yet, one shadows_onto each. The joined residency advances only where the command buffer's own work reads it, so a command buffer of n compute encoders walked n(n-1)/2 ended encoders: at Geekbench Fluid's ~2300 one-dispatch encoders a command buffer, the open grew to ~2.9 us a dispatch on lavapipe (866 ns at 6 encoders), and reims's decodeperf profile (M3, MoltenVK) put inherited_residency and shadows_onto at 762 of open_compute's 874 samples. The command buffer now keeps what its next compute and its next render encoder start with, with the number of ended encoders it took in (State::inherits): an open takes in the encoders ended since, each once, in the order they ended, and hands out a copy (a count: the residency's resources are shared until one copy changes). It is let go of where the joined residency or an ended encoder's residency may change: joined_residency (every read that joins, the heaps' textures made since, the first submission, a re-encode) and a re-encode's splice of an encoder's residency. The result is the one the walk made: the joined residency's shadows first, then each ended encoder's onto them in order, usages and stages joined as before. Counted: WorkCounts::ended_residencies_looked_at (an ended encoder's residency looked at for an open's inherited shadows). Tests (tests::joined_residency): 64 encoders with a read of the residency after the 32nd look at 62 residencies (the walk: 992); a shadowed texture made resident for reading, then writing, reaches the next encoder with its usage widened. RUNTIME_VERSION 2270: an encoder open inherits residency incrementally (the same result). Also (compenc): dispatch_chain gains --host (each encoder call and the commit timed on the calling thread, commit_and_submit, per-thread CPU on Linux), --binds 4|tex (four buffers, or the Geekbench compute shape: 2 textures, a sampler, an output buffer and setBytes) and --pages (buffers over host pages). Verified (compenc, msi lavapipe): touched tests 165/165 (m3-max-28544) incl. tests::joined_residency: 64 encoders with a residency read after the 32nd look at 62 ended residencies; a shadowed texture made resident READ then WRITE reaches the next encoder as written. Negative control (drop the slots every open, m3-max-28547): 992 vs 62, fails. Release dispatch_chain --host --only encoders --dispatches 2300 --binds 4, ns a dispatch: open 2862 -> 573, encode 7332 -> 5004, thread CPU 7532 -> 5205 (jobs 28534/28545); ended_residencies_looked_at 1.00 a dispatch. SR-like (6 encoders a CB) unchanged (866 -> 913). Clippy x3 and rustdoc run after landing. Squashed from steelbrain/compenc d0d524b6de..84b304c5e3. |
||
|
|
dd286c7304 |
RUNTIME 2268: record consecutive compute encoders of a command buffer into one VkCommandBuffer
A command buffer of N one-dispatch compute encoders went to the queue as 2N - 1 command buffers (each encoder's primary and a kept barrier command buffer before it). A compute encoder now records on in the tail of the compute encoder before it where nothing needs a boundary: same dispatch type and logging, same batch (no event wait or signal, no host step), the earlier encoder one plain part (no segment, no fence update, nothing failing or faulting), no command predication, encoder trail off, protection options 0. The barrier between the two is recorded per command by the tracker's own rule between two encoders of a batch (encoder_fold::FoldOrder), joined with the encoder's own serial barrier into one vkCmdPipelineBarrier. The folded encoder's uses and fence waits join the group's first part's summary, so the batch's plan orders the group as a whole; its own part keeps its fence updates alone. A rebind encodes a group again whole or not at all; a failure that fails one encoder of a group fails the group (docs/API.md section 10, "A command buffer committed as failed"). Counted: WorkCounts::encoders_folded. FAST-PATHS: the ANV command-buffer row notes folded encoders begin none. Also: the dispatch_chain example (gbkern, dchain): a chain of dependent dispatches by how a command buffer holds them (encoders, serial, raw barrier, raw split), with each shape's first command buffer's counts. RUNTIME_VERSION 2268: compute encoders fold into one VkCommandBuffer. Verified (dchain, at d7e4a9ce51, the same diff before its rebase): - lavapipe (m2v_cpu_icd): 40 tests incl. 8 new tests::encoder_fold (dependent chain, independent encoders take no barrier, dispatch-type change, fence update ends a group, commit_failed inside/at a boundary, rebind re-encodes a group whole). - RTX 5080 (m2v_gpu, b5080): 190 touched-family tests; FOLD-CHAIN folded 23, begun 1, barriers 17, 0 wrong words. - 5080 dispatch_chain, encoders shape, GPU us a dispatch: 1000: 8.41 -> 2.92, 2300: 7.43 -> 2.92 (raw barrier 2.92); vkQueueSubmit per command buffer at 2300: 1007 -> 44.6 us; command buffers submitted 2N -> 2. Owed after landing: the negative control (fold barrier removed reads wrong words), clippy x3, rustdoc, the full lavapipe runtime suite at the rebased tip (m3-max-28507), the 780M and XTX before/after. Squashed from steelbrain/dchain f51ba34c37..2f2000cfbc. |
||
|
|
1443135ad8 |
RUNTIME 2264: readers after a barrier of a texture without feedback-loop usage take leading snapshots, weighed by area and learned coverage
On NVIDIA's drivers a linear image takes no feedback-loop or input-attachment usage, so a draw that read such a color at its own pixels after a memory barrier split the pass and copied the texture's scissor box (the whole surface for a guest that sets no scissor) before the new instance: in a consumer's autoscroll on an RTX 2080 about 21 readers a present each copied a 3648x2038 surface, ~29 ms of a 45 ms take-to-show. Such a reader now splits the pass with no copy: its snapshot draws record in an instance of their own ahead of the reader's (LOAD/STORE_NONE, empty masks), a "leading snapshot". The device enables VK_KHR_load_store_op_none, else VK_EXT_load_store_op_none, below Vulkan 1.3 (the runtime's instance is 1.2, so STORE_OP_NONE was core on no device); the version comes from the device's properties. A leading snapshot reads the texture at every pixel its draw covers, so over host pages it is not cheaper than the split at every area: on an RTX 5080 Laptop GPU (split_parts, 8 readers a frame over a 2648x1658 surface over host pages) whole-surface readers took 22.98 ms a frame leading against 17.99 split, quarter-surface readers 6.06 against 8.55; the forms cross near half. weigh_snapshot takes whether the reader leads and skips over_bytes for it, so the area rule weighs its first pass and, where the device measures readers (occlusionQueryPrecise), learned coverage decides from the second: a reader keeps the leading form within the existing bound (SNAPSHOT_PIXEL_COST 20: 20% of a 4-byte color) and splits above it. A rebound kept reader weighs with the same flag. New WorkCounts: reading_draws_snapshotted_leading, reading_draws_leading_covered_within / _to_half / _over_half (where the guest's readers fall against the bound). docs/FAST-PATHS.md's row records the 5080 A/B. Also: the split_parts lane (ignored by default, run by name) measures what split readers cost and reads its fixtures from the crate directory the runner names. From steelbrain/nvscroll (81915c28de..3cdbfe9256, 11 commits). Verified on potluck at 3cdbfe9256: clippy gpu (28377), cpu_icd and plain (28379) 0; rustdoc -D warnings 0; api_signatures and api_surface 15/15; lavapipe 478/478 (copy form unchanged there). 5080 A/B nvscroll-ab-233300 (kind t). The tip's 5080 device test and lane (b5080 batch 28393) are pending; the 2080 and XTX runs wait for um790. |
||
|
|
54b8b75d45 |
queue_share: a pairs mode, a game's two command buffers a frame beside a compositor's queue
A consumer's game on the RX 7900 XTX (RADV, one graphics VkQueue) ran a frame of two command buffers (about 9.5 ms and 0.3 ms of GPU time, two frames in flight) at 22 ms a frame against 9.9 ms of GPU time, its batches held 5.5 ms a frame for the compositor's unshared queue (WorkCounts::batch_hold_nanos, heads_held_for_unshared_isolation). This mode runs that shape on the runtime alone: the frame period, GPU time and GPU idle share, each command buffer's commit to kernel start, the GPU gap before each frame, the completion's lateness, and the device's hold and scheduler counts a frame, under either UnsharedIsolationPolicy, with the compositor's queue committing nothing or a draw every --period-ms. Verified: cargo fmt; built and run on the XTX in the following jobs. |
||
|
|
a3214f16f7 |
RUNTIME 2237: a skipped inert dispatch still names what it binds, so its command buffer copies Managed buffers in
RUNTIME 2228 ( |
||
|
|
574d199d67 |
RUNTIME 2236: a managed synchronize decides its copy as it is encoded and records it in place
RUNTIME 2231 split the guest's encoder at each synchronize of a Managed buffer into its own deferred segment (Deferred::SyncOut): every command buffer holding one paid an extra continuation VkCommandBuffer and a segment VkCommandBuffer, its batch could no longer fold its end (an extra VkSubmitInfo), and the copy was decided at submission. On the consumer's 2080 Geekbench walk that showed as ~1 extra no-dispatch command buffer per synchronize. Now the copy is decided at encode, from the kept writes of other command buffers plus this command buffer's own writes before the synchronize, and recorded in place with only the written regions; an unwritten synchronize records nothing. The copy is whole where an earlier segment is unknown, the command buffer writes memory no use names, or the buffer was handed out. At submission, settle_syncs_out adds a top-up command buffer just before the part holding the copy, covering only writes from other command buffers noted after the encode, between two all-stage barriers (WorkCounts::managed_synchronizes_topped_up, new). The SyncOut segment is gone (deferred.rs is back to its |
||
|
|
c7d652ca5e |
RUNTIME 2232: the scheduler loses no wake for a batch held behind an unshared queue or a kept group
A guest's commitAndWaitUntilSubmitted could stay unanswered until the next commit (reims, XTX
RADV at pin 71, 2 of 77 runs under load: "A was never submitted"; the GPU idle; the scheduler
asleep with the batch held for 10 s; an empty commit on another queue released it at once).
Cause (reims's finding, /tmp/xqtest/m2v-finding.md): on a host whose one graphics VkQueue an
unshared queue also holds (RADV, ANV; WindowServer's queues are unshared), batch A behind H was
held by held_for_unshared() while H was in the Flight. QueueSlot::completed publishes `completed`
(fetch_max) before waits.completed takes H out of the Flight. When H completed between those two
steps, the hold read a stale Flight and gated on completed + 1, which nothing meets.
Fix:
- Unshared hold: QueueWaits::hold_ahead reads the published completed value under the waits lock;
Flight::ahead(ran, completed) counts batches at or below it as gone; Room::Hold { after, through }
carries the oldest still in flight; await_unshared_room gates on `through`, fences, and reads
again (completed >= through wakes it at once). No reorder of QueueSlot::completed.
- Kept group (submit_ready, Group::keeps read before gate_on): sets the gate, fences, then reads
again (Group::pending_through), the protocol gate_heads and check_heads use.
- A WAIT_SLICE that ends with a batch held makes a pass, as the module docs promise, counted in
WorkCounts::scheduler_slice_rescues (0 wherever every wake comes). api_signatures and host_ab
updated.
Verified (perdraw5, msi 26135, lavapipe, at 3bd14c83ac on
|
||
|
|
d38b5c4ef6 |
RUNTIME 2231: a managed synchronize copies out only the bytes the GPU wrote
On a device without unified memory, synchronizeResource: copied the whole Managed buffer (or a
texture's whole span over one) to its host copy every time. The runtime now keeps the GPU's
writes for each buffer that has been synchronized once (managed_sync.rs: GpuWrites, SyncCopy,
SyncOut), stamped in the scheduler's submission order across all queues. The copy-out is its own
segment (Deferred::SyncOut), decided when its batch is submitted, so it covers the writes of
earlier batches, of earlier encoders in its batch and of its own encoder, including a write
encoded after the synchronize but committed before it. Completion of the command buffer holding
the copy drops only the writes noted before the copy. It copies nothing when the GPU wrote
nothing since the last copy, and still copies the whole buffer where the writes cannot be known:
an untracked buffer; one whose VkBuffer was handed out or whose memory is exported; a buffer's
first synchronize; any batch since the last copy, not yet complete, that may write memory no use
names (State::writes_unnamed); and a synchronize recorded in place (a predicated loop's laying, or
no VkCommandBuffer could be made). Every barrier is still recorded. Pages no import maps copy back
only the regions copied. Textures over buffers take the same path (an image range counts as the
whole buffer). Touches command_buffer/submit.rs (record_syncs_out after record_scrubs) and
command_buffer/mod.rs (the footprint loop skips SyncOut segments), encoder.rs, tracker.rs,
deferred.rs, device/mod.rs. New WorkCounts: managed_synchronizes_unwritten,
managed_synchronizes_whole, managed_bytes_unwritten_skipped. FAST-PATHS managed bullet, API.md
managed section and the runtime README updated. No speed-for-accuracy choice.
Why: on the RTX 2080 the guest's Background Blur spent 0.90 s of GPU time copying out 3.5 GB
over 800 synchronizes (~176 MB a command buffer, the 2080's x4 link), whole resources each time.
Verified (mansync; step codes read inside the jobs):
- clippy --all-targets --all-features -D warnings, workspace: plain 25924, m2v_cpu_icd 25927,
m2v_gpu 25928, all 0; rustdoc -D warnings 25935 = 0 (at b72228629c).
- RTX 2080 (um790) at ac0887e7f5, 25942: 41/41 (managed_copy_device, detached_contents,
kept_padding, device_memory_overflow; hazard tests excluded). Counts (copied, skipped,
unwritten, whole), both Import and Pages: first synchronize (1048576, 0, 0, 1); after no write
(0, 1048576, 1, 0); after a fill in an earlier command buffer (16382, 1032194, 0, 0). Every
byte checked after each step, including a write committed before the synchronize's command
buffer but encoded after it, and a CPU write named by didModifyRange.
- Negative control (throwaway e1542d94c4, 26010): imports copy whole and pages drop kept writes;
both legs fail.
- Release, 2080, examples/managed_sync_out (40 no-copy Managed buffers of 4,399,104 B, 176 MB
synchronized a command buffer), median GPU ms over 20, base
|
||
|
|
769410c51a |
pass_costs: fresh primaries per pass, untrimmed and trimmed, and --begins
Two shapes allocate each pass's primary and free it once its frame completed: per-pass-fresh leaves the pool untrimmed (Mesa's common pool recycles a freed command buffer), per-pass-fresh-trimmed trims it, so each allocation makes a new command buffer with no command stream memory yet. --begins times each vkBeginCommandBuffer and each instance's begin alone. They test whether a fresh primary's command stream memory is the walk's 6.8 us vkCmdBeginRenderPass, which the reused primaries do not show. Verified: cargo fmt; the build and the run are the next potluck job. |
||
|
|
4018fe2122 | pass_costs: print whether the attachment is cleared (ash's load op has no Debug here) | ||
|
|
933d0030b0 |
pass_costs: --extent W,H and --clear, the attachment's size and load
The walk's vkCmdBeginRenderPass took about 6.8 us each (profile), the bench's 1024x1024 loaded instance well under 1 us: the extent and a clear load are the first two of the walk's passes' differences to measure. |
||
|
|
1f7c3be6e9 |
pass_costs: the primaries' shapes without a shared prefix, as clippy asks
clippy's enum_variant_names on Buffers (lint3 job m3-max-25117, its only error under all three configurations; rustdoc and the API tables green). |
||
|
|
b6534e8fe8 |
pass_costs: what a render pass instance costs the driver's CPU, by how it is recorded
A bench of its own Vulkan 1.3 device, no runtime: 150 passes a frame of one draw each, 6 to a vkQueueSubmit (the walk's averages), recorded as the runtime records them (a primary per pass, its 17 dynamic states set, a VkFramebuffer made per pass for vkCmdBeginRenderPass) and as the alternatives: a primary per submission, a framebuffer kept, dynamic rendering. It prints each shape's CPU time a pass to record, submit and reclaim, and the differences between shapes that differ in one thing: the costs of the structural items in one run on one device. Verified: cargo fmt only so far; built and run in the 780M job. |
||
|
|
b37489e9e2 | draw_costs: --worker, render lowering on the device's lowering thread | ||
|
|
312b1b2d78 | draw_costs: --states N, the small passes' plain states | ||
|
|
3beb899549 | draw_costs: the small passes rotate over six plain states, so a pass's first draw takes every step | ||
|
|
5373c76697 | draw_costs: a window server's small passes (pass1, pass17) | ||
|
|
5039015420 |
An import several no-copy buffers over the same bytes lie in stays releasable
A no-copy buffer made over exactly the bytes a live one covers lies in that
buffer's import (host_aliases.rs, "One memory, one import"). Until now its
making read the import apart (ReadApart::SecondBuffer), which keeps a
releasable import imported for good. Such a buffer reads the import the way
the first one does, through the import: its blits take the import's objects,
imported again where released, and any other read of it exposes the import
just as a read of the first buffer would. So the import now stays releasable
while every read of each buffer in it was a blit's, or there was none. A
buffer that is never read, made only to keep the bytes imported, keeps the
import no more than a buffer read only by blits does.
Why: on the RX 7900 XTX (RADV), a guest's 3D benchmark kept 1,000 to 1,330
dma-buf imports live. RADV lists every one of them in every kernel submission,
at 0.43 to 0.44 us each (docs/FAST-PATHS.md, known gaps). Of those imports,
1,262 were held for good, and every held one had a second buffer lying in it.
The consumer keeps a holder for each view of guest pages: a no-copy buffer
over the whole view that nothing reads, with the block's buffer lying in its
import. The frames named about 0.6 imports per command buffer, while the
scheduler thread spent 0.63 to 0.90 s of each second in vkQueueSubmit, at
0.835 ms per call. Our own blocks on that device are plain VRAM, which RADV
makes local and lists in no submission.
What still keeps such an import imported for good:
- a no-copy heap's own bytes lying in it: the heap's placed buffers'
addresses are the heap's, handed out without any read of the import noted;
- a rebound buffer lying in it, as a rebind's own import is kept;
- a buffer bound inside its memory with a VkBuffer of its own;
- a buffer made to share its buffer's range (BufferDescriptor::range_of),
which is handed that buffer's address.
Counters: the gauge host_imports_read_apart_second_buffer is split into
host_imports_read_apart_inside, _shared_range, _heap and _rebound. The new
host_imports_joined_releasable counts the buffers that came to lie in a
releasable import beside another and left it releasable; a walk shows the
path ran when it is non-zero. host_residency.rs ("Several buffers in one
import"), host_aliases.rs, the WorkCounts docs, docs/HOWTO.md and the API
signature table say so.
Test: tests::host_residency::an_import_two_buffers_lie_in_is_released_while_idle_and_read_right_again.
It makes a never-read holder and a second buffer over the same 4 pages of a
udmabuf-backed memfd. Joining keeps the import releasable (nothing held for
good, no read apart) and imports nothing new. Read by a blit, the import is
released. The file's writes made while it is released are read by the next
blit through the second buffer, imported again from the kept descriptors. It
is released again. Then a kernel binds the second buffer, makes the holder
resident (useResource:, as Metal reaches a no-copy buffer through an address
only once a command buffer used it) and loads the holder's Metal address from
set_bytes; the binding imports the import again for good. The words the kernel
reads through the address, and the words it writes through it, are checked
against the pages. The source is called once, and the import leaves the gauges
once its buffers go.
host_import_counts now expects a second buffer over the same bytes to read
nothing apart.
Verified (the runtime's debug test binary, --cfg m2v_gpu, not a release build):
- m3-max-23710 (msi-laptop): cargo clippy --workspace --all-targets
--all-features -D warnings, the runtime's clippy under --cfg m2v_gpu, and
the runtime's rustdoc with -D warnings: clean.
- m3-max-23713 (msi-laptop): the API signature tests, 16 passed; the
runtime's suite, 1502 passed, 6 skipped; on lavapipe (--cfg m2v_cpu_icd)
the host_import_counts, host_residency, pointer_residency and host_aliases
tests, 39 passed.
- m3-max-23761 (Radeon 780M, RADV PHOENIX): the host_residency and
host_import_counts device tests, 15 passed, the new test among them ("1
chunks of two buffers released twice, imported again twice"). The negative
control, the same binary with a joining buffer reading the import apart as
before, fails the new test at "the second buffer kept the import for good"
(held for good 1, expected 0).
The lint and suite jobs ran one commit before the test's last change (the
holder made resident before the kernel reads through its address), a
test-only change that the 780M run's binary carries.
|
||
|
|
dc859fee56 |
Residency: host_imports_resident counts releasable imports alone; host_imports_held_for_good the rest
What: an import a read other than a blit's keeps for good (Residency::held_for_good) leaves the host_imports_resident gauge and joins a new gauge, host_imports_held_for_good, as it already left the device's count against its most (Shared::resident). Every move of an import's memory (a release, an import again, let_go, the drop) now goes through one place, Residency::holds_memory, which counts it as releasable or as kept for good, by the flag under the state lock, as the most was counted. WorkCounts docs, host_residency.rs's Counted list and HOWTO.md say so; the API table and host_ab's list name the new field. Why: host_imports_resident's doc said 'the imports the device may release', but it went down only at a release, a let_go or a drop, so it also counted every import kept for good. A guest walk on the RX 7900 XTX showed about 1,040 'resident' beside a cap of 64 releasable imports, which read as the cap failing. The two gauges show both numbers without subtracting. Verified: the dma-buf and pointer residency tests now check the exposure step moves the import from one gauge to the other, and that a gone import leaves both (job ids in the report). |
||
|
|
c6fa636665 |
Hold large pipeline makings to one large compile at a time
A guest's run on RADV made kernels of up to 4.5 M SPIR-V words several at once; on the Radeon 780M one such making alone peaks at 3.6 to 10.3 GiB resident (1.9 to 4.5 M words). Nothing bounded how many large modules the driver compiled at once beside the budget's turns, which count makings and not their size. The process now keeps a limit of SPIR-V words in flight (pipeline/compile_memory.rs): a making whose stages hold 65,536 words or more holds its words around its driver call, the counted makings in flight holding at most 4,194,304 words, a larger one alone. One that does not fit waits for those in flight, lending its turn (budget::without_turn) and taking one again after; the waiters go in their turns' rank order and none passes one waiting before it, so a large making never starves. The compute making (objects.rs) holds its kernel's words, a whole render pipeline its stages', a pipeline library its own part's. Each module carries its words. WorkCounts counts the makings that waited (makings_held_for_compile_memory) and their wait (compile_memory_held_nanos); the conformance cost half reads the count with the other making counts. Unit tests: a making below the floor is not held; two that do not fit never hold at once; no counted making passes a waiting one, waiters going in rank order; a waiter lends its turn and takes it again. |
||
|
|
70d85cd94f |
draw_costs: the scene's materials sample textures of three sizes, each with its levels
A 3D engine's materials bind textures of other sizes and level counts, which their bind states' shapes tell apart (TextureShape's level count) though their plans do not (BindShape::for_plan). Material m's textures are now 64x64, 32x32 or 16x16 as m goes, each with its whole mipmap chain, so a material change reshapes the bind state as such a frame's do. |
||
|
|
b8e1a678ec |
draw_costs: scene and rebinds, a 3D engine's passes over four color targets
Two shapes of a 3D engine's frame as a layer over another graphics API issues it: 8 command buffers of 10 passes of 24 indexed draws over the same four color targets, each draw at its own slots of a transform and a material scale (buffer offsets moved), drawing one of 64 pieces of a mesh read through a vertex descriptor. Every 4 draws a material of 6 binds its pipeline state, 8 fragment textures and 8 samplers. In rebinds, each draw binds its material's textures and samplers again, the same objects within a run. The functions are draw_costs_scene_vertex and draw_costs_scene in draw_costs.metal. Steps gain Begin (a pass of a descriptor), the two offset setters and the texture and sampler range setters, each tallied by --calls. |
||
|
|
c8d8a2063d |
An A8Unorm texture over a buffer that only reads takes R8Unorm's linear image, read through (0, 0, 0, R)
Where the device reports A8_UNORM's linear tiling without what its optimal tiling has for the texture's usage, and R8_UNORM's linear tiling with all of it (vkGetPhysicalDeviceFormatProperties2's linearTilingFeatures and optimalTilingFeatures, read through linear_plan::linear_lack), an A8Unorm texture over a buffer's bytes that only reads (no RenderTarget, ShaderWrite, ShaderAtomic or BlockWritesOnly usage; one level, one sample; its alpha not read as one, not rotated) is made as an R8Unorm texture's storage over the same bytes: the image in place over host pages, an image aliasing the buffer's memory, or that texture's shadow where it would be one. Its record reads the image as R8Unorm through the swizzle metal::format::swizzle_over composes ((Zero, Zero, Zero, Red) composed with the texture's own), as an A8Unorm view of an R8Unorm texture is read (ViewRecord::read_as): the same byte, the same filter, the channels moved by the view's component mapping. NVIDIA's linear A8_UNORM has no sampling, linear filtering or transfer features (the consumer's RTX 2080 walk kept 195 glyph-sized A8Unorm textures over Shared buffers as shadows): those are now in place where an R8Unorm texture's image is. A texture that renders or is written keeps the A8_UNORM route. Buffer::texture_placement answers the same route. Counted: WorkCounts::alpha_textures_held_in_red (api_signatures.tsv regenerated). a8_over_buffers asserts no shadow and the device's own A8Unorm texture's reads; device runs pending. |
||
|
|
c539698eb0 |
draw_costs: count each draw's L1 data read misses and cache misses on Linux
What a draw's memory touches cost the encoding thread, which its instructions do not show: the thread's user-space PERF_COUNT_HW_CACHE L1D read misses and PERF_COUNT_HW_CACHE_MISSES (the L2 on Zen, the last-level cache on Intel), opened beside its instructions and cycles and printed as DRAW-COST l1d_read_misses and cache_misses a draw. Built and run in the next step's jobs. |
||
|
|
4b3eb3b253 | draw_costs: the compositor's plan walks its passes' sizes, as clippy asks | ||
|
|
2a485c9b9e |
A shadow made before its verdict moves in place with its usage shadow of the bytes
A texture over host pages (or the device's pooled memory) made before its class's in-place verdict is a shadow that moves in place at a quiet commit once the verdict passes. The move was refused for good where a binding or a pass had taken a usage shadow of the texture. In a compositor's frame, a draw that reads its own pass's color attachment at its own pixel (an attached read) takes that usage shadow in the first command buffer. So every target made before the verdict stayed a shadow for the process's life. Over host pages, each command buffer then copied back every texel that its passes wrote: on the Radeon 780M, the whole 3840x2400 framebuffer, 9.2M texels a command buffer, in reims's first session. A usage shadow of a texture over a buffer holds the buffer's bytes as its truth (ShadowSource::Bytes). An image in place over those bytes is the same truth, and an aliasing image's uses are uses of those bytes. So such a usage shadow serves the moved texture exactly as it serves one made in place. Now only a render shadow, or a usage shadow of another truth, keeps the texture a shadow (ShadowCopies::copies_bytes). draw_costs' compositor shape now settles the in-place check after making its surfaces. A run with a fresh shader cache then measures a first session after its verdict. Test: runtime_lane::in_place_textures::a_texture_an_attached_read_copied_before_its_verdict_moves_in_place_too. |
||
|
|
27bca2eeab | draw_costs: a pass step's arm answers as the other steps' do | ||
|
|
e74e1b70d9 |
draw_costs: the consumer's compositor frame as a shape, shadow lines on stderr
The consumer's per-draw table on the Radeon 780M measures a window compositor's command buffer: five passes that load a layer's surface and draw 4 quads each, then a pass that clears a 3840x2400 framebuffer surface and draws 15, every surface a texture over its own buffer's IOSurface plane. Its draws cost about 12 us each and its pass ends about 39 us on that host, against draw_costs's 1.9 us: its surfaces are shadows. draw_costs had no shape of it. - compositor: 8 command buffers of that frame (6 passes, 35 draws, 21 indexed), each pass opened with set_viewport, each draw setting a pipeline state where its kind changes (plain, masked, backdrop; blended), two vertex buffers and a fragment buffer at moving slots of one no-copy buffer over host pages, one or two fragment textures (a backdrop draw reads its own pass's color attachment at the fragment's pixel), a sampler and a scissor rectangle. Surfaces over Private buffers, or with --pages over host pages. - Steps: a Pass step opens a compositor pass (a command buffer of other steps opens the bench's one pass as before); fragment textures take an index; indexed draws; the calls set_viewport and draw_indexed_primitives counted apart with --calls. - With METAL2VULKAN_LOG_SHADOWS=1 the sink prints the shadow log's lines and each degrade notice's text on stderr. - draw_costs.metal: the compositor's quad functions, written for this example. Verified: the build and the 780M run follow in the next jobs (the metallib is compiled on the M3 Max). |
||
|
|
99c40c6e28 |
draw_costs: a damage shape and a shadowed, loaded target
A guest's compositor pass loads its window surface, a texture over guest pages, and draws inside damaged rectangles, so the pass's end plans a shadow's copy back and counts its tiles against its draws' scissor rectangles (count_colors, DrawnArea::covered_tiles). draw_costs had neither: its target is a cleared Private texture and its clips shape takes two rectangles. - damage: as clips, each draw after a scissor rectangle of its own, the next cell of a 25 x 20 grid of 20x25 pixels (500 rectangles a pass). - --shadowed: the target is a texture over a no-copy buffer of host pages at its packed rows, loaded, the device opened with HostPageTexturePolicy::Shadow so it is a shadow on every device. - The host-page mapping is one helper (host_pages) for the chunks and the target. Verified: built in the next commit's job; the before/after numbers are in its message. |