e453efbf0aab4107aea4f18866b16ff00a80eccf
125
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
e453efbf0a |
RUNTIME 2309: a texture whose rows are in place makes its shadow at the first reach of its image
A device-gap texture over a buffer (its image refused for a reason that leaves its rows in place: format, pitch, placement, source, dma-buf) was a shadow made at new_texture: its VkImage, memory and views, its notice and shadow-log line, and its slot in the texture table and every heap set. A slot whose function only reads, writes or asks its size binds the rows in place, so a texture only ever bound that way paid for a shadow no command used (reims's gbs91 on the 780M: hundreds of such textures, 8 to 52 MB each). Now such a texture (rows in place, no pending in-place verdict, not over a heap's buffer) is made with its shadow left unmade (texture/lazy_shadow.rs): the storage accessor makes it at the first reach, once, under a lock, with the making's notice, log line and counts, then places its slot (its resource ID reads the neutral until then). Paths that must not make it read the recipe instead (rows binding, placement and heap-set writes, CPU copies, blits on the bytes, shape and plan questions, logging). The reaches that make it: a slot that binds the image (before the command's copies are planned from its uses), use_resource, a pass's attachment, an execution of commands inheriting the bindings, a view, its VkImage handed out. An out-of-memory making fails the reaching call, as new_texture did. WorkCounts::shadows_left_unmade and shadows_made_at_use count both halves; docs/API.md says when the shadowed-texture notice is given. Not in scope: two kinds still make their shadow at new_texture. A texture waiting on its pages' in-place verdict may move in place. A texture over a heap's buffer is made resident by use_heap through a path that checks the shadow. RUNTIME_VERSION moves because the run's announcements change. The shadowed-texture notice and the shadow-log line come at the making, and a texture only ever bound through its rows gives neither. A resource-ID read of an unmade texture gets the neutral. No new Degradation kind. No FAST-PATHS row: the copy work follows uses, not the shadow's existence (an unbound shadow was copied 0 times per commit before and after), so no accuracy is traded. The saving is the making: the VkImage, its memory, views and heap-set slots. Test: tests::texel_rows_device::a_shadow_is_made_at_the_first_reach_of_its_image, on a copied buffer, since over the pages lavapipe lays the rows in place. Three cases: - a written-only texture: shadows_left_unmade +1, none made, shadowed_textures 0, shadow_copies 0, texels inverted in the pages; - a rows write then a sample in one command buffer: made at the sample, copies > 0, pixels equal to a device-own texture's; - use_resource: made at the call. joined_residency's helper asserts shadows_bytes() where it asserted the shadow at new_texture. Verified, msi m3-max-30024 at 088a73d3b7: - clippy -D warnings, runtime crate, all targets and features: plain and --cfg m2v_cpu_icd exit 0; - lavapipe 206/206: texel_rows, shadow*, read_twin*, joined_residency, padding/kept_padding, exported_*, first_host_texture, surface_shapes, attached_read*, copied_device, fresh_pages, texture::*; - translator api_signatures, api_surface and fast_paths: 47/47; - the negative control in the same job (lazy = false): the test fails at "Copy: left unmade", (0,0,1) against (1,0,0). |
||
|
|
88f577d11c |
A split keeps the encoder's kept draws: re-homed into the instance after it
A draw that recorded into a later render pass instance after a split (a read of a color attachment's texture after a barrier over the render targets, the walk's reader) kept nothing, and a draw that keeps nothing forgets every kept draw its encoder set aside: each later draw of the pass's other states took every step again. A draw recorded into an instance recorded inline after a split (render/inline_splits.rs) was never kept either (draws_unkept_other). What changed: - render.rs: `split_alone`, set where a draw keeps nothing only because it began a later instance after a split (no continuation, no stand-in's arrival), of the shape, views and formats of the instance before, its other steps a plain draw's. Then `rehome_aside` keeps the kept draws set aside with other states' bind states into that instance, but those that read the pass's colors other than through snapshots of their own, readers through snapshots, draws carried in and not drawn since, and those whose `Under` (moves, residency, sampler slots, rebinds, aliases) differs, which it lets go. - draw_again.rs: `Kept::rehomed_into` marks a kept draw re-homed (`rehomed`): after draws of other states, under a render state of another stamp, through no record, so its next draw is rebound. - rebound.rs: a re-homed draw's uses are made whole and its shadowed textures' uses gathered into its new instance where it uses them as its kept draw did, as a carried draw's are. - A plain draw into an instance recorded inline after a split is now kept (`plain` no longer requires no room). A kept draw's next draw there is always rebound (draw_again's room guard), and its recording goes into the room (`record_rebound`), recorded at the group's end through the pass's record as every step's; `settled` stays None there. - The debug check compares `rehomed` as the every step it takes keeps it. New WorkCounts field: kept_draws_rehomed. No new Degradation kind. Test: tests/split_keeps.rs, kept_draws_set_aside_are_rebound_past_a_split (A sampling, B adding, a barrier, a reader of the target that splits, A and B of other bindings, B twice again with no call between): 2 kept draws re-homed, the draws after the split rebound (drawn_alone(4)), none unlike or stopped, no draws_unkept_other, the same commands, state commands and pixels as every draw taking every step, and the pixels of the draws after the split those of what they bound. tests/draw_again.rs: `run_into` (a run into a given target) split out of `run_on`; `checks_ended` and `drawn_alone` shared. No RUNTIME_VERSION bump: the commands, state commands and pixels are those every step records. The runtime pin moves alone. Verified on msi (lavapipe): - m3-max-29952 at 15ba7cf939: clippy -D warnings, plain and --cfg m2v_cpu_icd, exit 0; 143 of 144 tests in 35 touched modules passed (draw_again, inline_splits, inline_continues, carried_draws, kept_*, snapshot_reader_*, attached_read_*, learned_coverage, leading_snapshots, shadow_runs and others). The one failure was the new test. Its first draw ran before any fragment buffer was bound, so that draw's rebind stopped, which is correct. The test now binds fragment buffer 0 first, as the walk does. - m3-max-29958 at e8daf89d87 (test code only since 15ba7cf939): clippy --cfg m2v_cpu_icd exit 0; split_keeps passes. - In debug, the re-homed draw and the draw in the room take the every-step check and pass it. |
||
|
|
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. |
||
|
|
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. |
||
|
|
a397a8b366 |
RUNTIME 2260: a rate-mapped pass of one piece times its piece
The pieces' GPU times (WorkCounts::rate_map_piece_gpu_nanos) counted only
passes recorded in two or more pieces, so a frame's single-piece
rate-mapped passes were untimed: on the Iris guest frame only about half a
multi-piece pass a frame was timed, and the Offscreen time outside the
pieces could not be split from the counters.
PieceTimes::take now times any piece count above zero, and the executed
pass's recording takes it only for a rate-mapped pass (one of its
executions has a map), so a pass without a map still writes no
timestamps. Two timestamps a pass, where the device times pieces at all.
Test: rate_mapped_pieces' uncut execution now asserts its one piece timed
where PieceTimes::timed_on; verification follows on potluck.
Also: the pieces lane gains the wide frame without a map and each frame's host steps (e640147b9a),
and the pieces device test loads its fixture where the run's manifest lies, so it runs from a
carried archive (1c01beec35; it failed so on the 780M, m3-max-27994).
Why: on the Iris guest's rate-mapped sample (asp78-iris) about 93 ms a frame of the Offscreen
pass was untimed, because rate_map_piece_gpu_nanos timed only passes cut into two or more pieces;
the next Iris run splits the whole pass.
Verified at 1c01beec35: clippy plain exit 0 (m3-max-28152); lavapipe 6/6 rate_mapped device
tests, the uncut pass's one piece timed ("pieces 12 timed 13") (28151); release m2v_gpu archive
builds (28150). clippy under m2v_gpu and m2v_cpu_icd and rustdoc passed on the tip that carried
these same changes.
|
||
|
|
76855fc0ba |
SEMANTICS_VERSION 2106, ARTIFACT_FORMAT_VERSION 522, RUNTIME_VERSION 2256: GPU-written indirect command buffers that inherit the encoder's buffers run on the GPU; write routes reach the indirect command buffers of their own command kind
A GPU-encoded indirect command buffer whose records inherit the encoder's buffers took the host step: the render GPU form refused inherit_buffers (DrawReplayRule::InheritedBuffers) and the compute GPU form had no inherited-bytes path, so every frame read the records back and replayed them on the host (gameload's icb: 8,192 indexed draws, ~44 ms of host step a frame on the Iris against 0.29 ms natively). - Render (da75a4602f..f3745fd69c): a draw replay's variant takes the encoder's vertex and fragment buffers by index as its parent buffers, resolved to device addresses past the parent's record; inline bytes (set*Bytes) are planned at their slots; an unaddressed inherited buffer keeps the host step with its cause named (parent_entries refuses it rather than writing a zero entry). The executor's draw preprocess binds the encoder's vertex buffers. - Compute (7c148c3995..0a68ac5f15): a GPU-written buffer of dispatches that inherits the encoder's kernel buffers runs on the GPU the same way; the new fixture icb_inherited_dispatches (our MSL) and its golden. - Route kinds (2d9f4ac597..2e206952c2): every route of a command buffer joined every indirect command buffer it made resident for writing, so a compute ICB's writer (DISPATCH|RESET) refused the render ICB's GPU form in the same command buffer (DrawReplayRule::Operations): gameload -b's render ICB host-stepped although nothing refused its own shape. A write route now reaches only the ICBs of its command kind (render or compute); CommandWrites carries the kinds (ARTIFACT_FORMAT 522). - host-replayed-indirect-commands is announced once per cause instead of once per device (a660b2fe8d), naming the rule that keeps a pass from the GPU form, as copied-host-pages announces per reason; no new Degradation kind or WorkCounts field. Verified on the branch (steelbrain/icbinherit2 at a660b2fe8d): clippy plain, m2v_gpu and m2v_cpu_icd and rustdoc exit 0 (27886); runtime suite 1538/1539, the one failure the catalogue text RUNTIME 2253 already fixed on development (27884); lavapipe ICB and notice lanes 214/219 with render_inherited_buffers, compute_inherited_buffers, write_routes, written_commands and the beside test (inherited and own buffers: cold (8,8,0), warm (8,8,0,0), pixels as alone) passing, the 5 failures failing the same at the branch's base (27926, 27927); before route kinds the beside test fails as designed, (0,0,8) against (8,8,0) (27764); XTX 90/101 at 60c85035e3 (27853), the 11 failures fixture paths under msi's compile-time path only, all 11 passing on lavapipe (27807). |
||
|
|
8c89e236d0 |
SEMANTICS 2100 / RUNTIME 2248: a rate-mapped pass's parted run is drawn only into the regions its blocks reach
A flagged draw's runs (blocks of 64 triangles around the triangles the probe flags) were drawn region by region into every region of the map's plan. With the consumer's rate-map sample on the Iris Xe that was most of the frame: rate_map_piece_gpu_nanos 382 of 441 ms a frame at pin 74 (232 runs into 2074 regions, 83k run triangles). Now the probe ORs each 64-triangle block's bounds, widened as before, into 16 x and 16 y buckets (bind::fan_out::BOUND_BUCKETS, PROBE_BOUNDS_AT, BLOCK_SET, STRADDLE_SET, fn bucket; PROBE_SETS 6 -> 7), and a run is drawn, through the region-copy route as before, only into the regions its blocks reach, as consecutive ranges in table order. A triangle crossing w = 0 is bounded by its part where w > 0: per axis its positive-w vertices' coordinates, plus infinity on each side where an edge crosses w = 0 (the side is the sign of w_a*v_b - v_a*w_b; within 2^-16 or NaN, both sides). A run whose bounds reach every bucket draws into every region, as before. The route, its clip distances and the Equal-depth identity are unchanged. New counters: WorkCounts::rate_map_run_region_draws, rate_map_runs_every_region, rate_map_straddling_triangles. FAST-PATHS row 50 says so with its numbers. Verified (blotch, d141fe9096..b277d4df9e on |
||
|
|
b741f93b9e |
SEMANTICS 2098 / RUNTIME 2244: a rate-mapped pass's region-by-region draws copy each region in the vertex function, scissored, so Equal depth matches the fanned-out route
Under RateMapRegionPolicy::FanOut a draw was drawn two ways: fanned out (a geometry stage's copy of each triangle per region, window position a*x + b*w through one viewport), or region by region (each region through its own Vulkan viewport). The two rounded a vertex's window position differently, so a pass testing depth Equal against depth the other route stored failed along whole surfaces: the consumer's black blotches on lit surfaces in Apple's Modern Rendering sample on the RTX 3090. The depth-Equal repro left 44,666 of 89,483 pixels red on lavapipe whenever the prepass and the Equal pass took different routes; 0 under Exact or on one route. Now on a fanning device the region-by-region draws take a region-copy variant (RegionFanOut::RegionCopies), with no geometry stage. Its vertex function computes region RegionFirst + DrawIndex of the table, stores its position through the region's line and four clip distances by the one emitter the fan-out stage's copies use (pipeline::link::fan_out::region_copy: NoContraction arithmetic, Position and ClipDistance Invariant), and its draw index as ViewportIndex. Each recording sets as many viewports as one multi-draw takes, every one the fan-out's over the render area, with each region's scissor at its index (bind::fan_out::scissors), so off-region triangles are scissored, not clipped. The settle keys the pipeline with the same viewport count (fan_out::copy_viewports). The variant replaces the regions variant, so no pipeline is added per state. A device without multiViewport, shaderOutputViewportIndex and shaderDrawParameters keeps the per-region-viewport route (FAST-PATHS known gap). Exact is untouched. New: bind::fan_out::scissors, WorkCounts::rate_map_region_copy_draws and rate_map_region_copy_recordings, PushField::RegionFirst; cache codec variants (artifact format). Verified (blotch, steelbrain/blotch 1fd68a45c0..16d5c2404f): - lavapipe at 16d5c2404f: rate_mapped_depth_equal + rate_mapped_fan_out 4/4, 0 red in all 10 depth-Equal lines (mixed pairs included), 0 pipelines made at the host step; clippy CPUICD, GPU and plain 0; rustdoc 0. Translator suite at 8ad673ffba 3562/3563, the one failure golden_hashes (re-blessed on development). - 780M and XTX at 8ad673ffba (differs from the tip by the settle fix only): 0 red in all 10 lines. E->E GPU cold/warm: 780M 4.99/4.97 ms against Exact 1.68/1.65; XTX 1.14 ms/650 us against 569/265 us. Creation (shader cache off): 780M 1.32 ms/state (Exact 0.92), XTX 1.30 (Exact 0.68). - Owed: the same numbers at development's tip without this change (the GS fan-out), the clip-distance probe, and the 780M/XTX runs at 16d5c2404f. SEMANTICS_VERSION 2097 -> 2098, ARTIFACT_FORMAT_VERSION 518 -> 519, RUNTIME_VERSION 2243 -> 2244. |
||
|
|
a308b1b409 |
RUNTIME 2241: kept draws survive fence updates and waits and resource and heap uses; the calls that let them go are counted
On the consumer's XTX Launchpad walk ~40 inline render encoders a present end keeping nothing
though none of their draws was counted unkept (keepdraws' read of lp72-xtx): every logged call
but a direct draw, a bind, a pipeline state set and a render state set forgets the encoder's kept
draws (render/replay.rs log -> forget_again), and the guest orders its heaps between encoders
with fences (updateFence after the last draw, useResource(s)/useHeap(s) before).
A kept draw, and those set aside, now survives:
- update_fence: it records nothing;
- wait_for_fence where the encoder used no shadowed texture (a wait over a shadowed texture marks
it written, so later commands take its copy again: that wait still forgets);
- use_resource(s) / use_heap(s), but a memoryless use (which fails the command buffer): a use
that changes the residency gives it a new generation, which Under holds, so the next draw takes
every step; a repeat use changes nothing.
Every other logged call still forgets. New WorkCounts: kept_draws_kept_across_{fence,use},
kept_draws_let_go_{fence,use,barrier,store_action,visibility,other} (the kept draw a logged call
let go, by kind), encoders_last_draw_empty.
Verified (keepdraws, 77437d3277 on adaccf2367): lavapipe debug 64/64 over kept_across_calls,
draw_again, carried_draws, snapshot_reader, deferred_calls (26714); the new
tests::kept_across_calls 2/2 (draws after updateFence, waitForFence, a new useResource, the same
use twice, a new useHeap, the same heaps, updateFence, against the same calls plus a forgetting
call: pixels and commands equal; kept across fence 3 and use 5, drawn again 3, unlike_kept_under 2
for the two residency-changing uses; a barrier test let_go_barrier 1, encoders_last_draw_empty 1).
Negative control (26721: a draw again recording its Vulkan draw twice) fails the pixel test (48
vs 36 a channel). clippy plain / --cfg m2v_gpu / --cfg m2v_cpu_icd and runtime rustdoc 0 (26715).
An XTX run follows on development.
RUNTIME_VERSION 2240 -> 2241.
|
||
|
|
041038a914 |
RUNTIME 2230: a reader through snapshots forgets only the kept draws that read its color
A direct draw that reads its own attachment through snapshots (not the in-place form) used to keep
nothing and forget every kept draw, those set aside for other pipeline states included. When it
records into its instance as it stood, on the encoder's own layout (no stand-in), and none of its
uses writes except its snapshots, it now forgets only the set-aside kept draws that read its
colors: one that reads a color's texture through its copy (Kept::through_copies), one that reads
it at narrowed levels (reads_attached), and one whose uses meet a color's memory
(render_target::shares_attachment, against that state's last-draw uses, which are the kept draw's
own). No kept draw can read a snapshot: only a reader binds one, and a reader never keeps. The
surviving draws keep their epoch and are "between", so their next draw is rebound; the reader's
snapshot writes are images, so pass_start_reads.fragments_wrote() stays false. Every other unkept
draw still forgets everything. LiveBind::forget_kept_where, RenderLowering::forget_readers, and a
snapshots_alone flag set where the draw's instance is decided; draw_again.rs documents it.
Why: on the XTX Launchpad walk 53% of draws (280 a present) take every step and none is carried,
because nearly every encoder holds a snapshot-reading draw that forgot every kept draw. A rebind
costs about a fifth of every step (~9 us saved a draw). Expected: fewer draws_none_kept and more
draws_rebound on the walk (about 21.6k of 24,947 snapshotted readers per 8 s qualify); not yet
measured on a walk.
Verified (imgleak, at e1a6c07dd8 on
|
||
|
|
791035345b |
SEMANTICS 2093 / RUNTIME 2227: a rate-mapped draw draws only its blocks that hold a flagged triangle region by region
For each flagged triangle, the fan-out probe's geometry stage also sets the bit of its block of
BLOCK_TRIANGLES (64) in a sixth set of 32 words (PROBE_BLOCKS 1024, PROBE_SETS 6; the last block
also takes every triangle past 65,536). A flagged draw in parts is drawn as its runs of flagged
blocks region by region: the first run cut to the first flagged triangle, the last to the last,
everything before, between and after the runs fanned out. Runs less than RUN_GAP (170 =
REGION_DRAW_WORK/3) apart are joined; a draw has at most MOST_RUNS (4) runs, the nearest joined
first. WorkCounts::rate_map_region_runs counts them. Exact is unchanged. FAST-PATHS row 50 edited
in place; api_surface gains BLOCK_TRIANGLES and PROBE_BLOCKS.
Why: on the pieces lane's wide frame, 23 flagged draws with 36 flagged triangles drew 106,519
triangles region by region (whole spans from first to last flagged triangle). Now 8983 in 35 runs,
and the frame splits into 2 pieces instead of 8.
Verified (ratemap, release, command-buffer GPU time on the wide frame, base
|
||
|
|
758ed9348b |
The fan-out probe counts each draw's flagged triangles
A flagged draw drawn in parts draws its triangles from the first the
probe flagged to the last region by region
(rate_map_parted_region_triangles), but nothing said how many of those
are flagged themselves: the probe kept only the first and the last.
That density decides whether drawing blocks of flagged triangles apart
would cut the region-by-region triangles.
The probe's geometry stage now adds one, for a flagged triangle, into
the word its PrimitiveId picks of a fifth set of PROBE_COUNT_WORDS after
the flag (PROBE_SETS = 5, PROBE_DRAW_WORDS = 1 + PROBE_SETS *
PROBE_COUNT_WORDS, the only place the word count is stated). The
runtime sums that set (Probed::flagged_triangles) and counts it at the
probe: WorkCounts::rate_map_flagged_triangles. The pieces lane prints
it beside the parted draws' region-by-region triangles and checks it
is non-zero exactly where draws were flagged, and no more than those
triangles.
Tests: the probe's link test counts two atomic adds (the copies', the
flagged count's); the probe words' unit test sums the fifth set; the
fan-out device test checks its four flagged triangles.
The probe's GPU time, verified on lavapipe (LP_NUM_THREADS=1, as CI)
by the fan-out device test (rate_mapped_fan_out::a_host_step_fans_out_
the_commands_the_probe_does_not_flag, one probe of 8 draws, 4 flagged),
release runtime binaries under --cfg m2v_cpu_icd at
|
||
|
|
dad0470c2e |
A flagged fan-out draw is drawn in parts: only its flagged range region by region
Under DevicePolicy's RateMapRegionPolicy::FanOut the probe flags a draw that has a triangle crossing w = 0 or reaching more regions than the geometry stage's copies. The whole draw was then recorded region by region, once per region of the map (2074 for a 61 by 34 map), however few of its triangles were flagged. The probe now also records each flagged draw's first and last flagged triangle. A flagged list of triangles of one instance, whose pipeline reads no [[primitive_id]] and writes no memory (the conditions under which a draw is already cut into index ranges), is drawn in up to three parts in its place: the triangles before the first flagged one fanned out, those from it to the last region by region, and those after fanned out. Each part is a range of the draw's vertices or indices, so each triangle keeps its vertices, vertex_id and order. Parts of a 16-bit index list begin at even triangles, so their ranges start 4-byte aligned as the draw does. Any other flagged draw is drawn region by region whole, as before. The probe words grow from 1 + 2*32 to 1 + 4*32 per draw (bind::fan_out::PROBE_DRAW_WORDS). For a flagged triangle the probe raises one of 32 words to u32::MAX - PrimitiveId and one to PrimitiveId + 1, picked by PrimitiveId as the counts are, so no single word takes every atomic. The wide marks that choose the variant of four copies now come only from triangles the probe does not flag, so the fanned-out parts can take that variant. Also: WorkCounts::rate_map_probe_wait_nanos sums the host's wall time from each probe's submission until it saw it complete, so a walk can split host_step_nanos into the probe's round trip and the host's own recording. rate_map_parted_draws and rate_map_parted_region_triangles count the draws in parts and their triangles drawn region by region. An earlier attempt drew a flagged draw through a geometry stage of 32 invocations, each taking a block of up to 16 regions, in 5 passes over the map. On the pieces lane's frame with wide triangles it made no GPU gain on an RTX 2080 (41.0 against 42.9 ms warm). On a Radeon 780M (RADV) it went from 182 to 1900 ms, with one piece of 1.1 s. That attempt is not in this change. Tests: render::fan_out's unit tests check that the parts take each triangle once, in order, with no flagged triangle in a fanned-out part, and that the probe's words decode to the first and last flagged triangle. The link test checks the probe's two atomic raises. The runtime's rate_mapped_fan_out test adds two commands that draw the grid with one triangle over half the target, one indexed and one without indices, and a triangle across w = 0 over the whole target. Under FanOut all four flagged draws are drawn in parts and the frame is compared pixel for pixel with the encoder's region-by-region frame. The pieces lane's wide frame checks that every flagged draw is drawn in parts. |
||
|
|
bbf86acd0e |
The encoder trail names each execution's GPU form, and its line reads the form's scratch while pending
The 3090 hang's rerun (its trail line, read in place) named a pass whose two executions of indirect commands, both through ranges a buffer holds, carried no host-step note: commit recorded them for good in their merged GPU form (render/executions/gpu.rs), where the trail noted nothing, so the line could not tell what the GPU read. encoder_trail.rs: - GpuForm: an execution's GPU form, its shape (recorded at commit or by its host step, merged or a draw per command, indexed, primitive type, the commands its preprocess runs over and from where, and the range buffer's offset), with its scratch region, layout and the command buffer's status words. - Named: a part's (and a batch's) trail text with the GPU forms its executions took; the line's front batch is described with each form's scratch read now: the range the GPU copied, the merged draw's two VkDrawIndirectCommands, the commands whose arguments draw, their vertices or indices times instances and the most of them (its index entry where indexed), and the status words. The last-completed batch keeps its text alone. - Step carries forms through a host step; commit's recording of each segment runs under a Step of its own (CommandBuffer::noting_forms), whose forms alone it keeps, joined to the part that holds the segment (State::trail_forms). upload.rs: Upload::glimpse, volatile u32 reads of a region of the host-coherent chunk mapping, read-only, no lock, no wait. completion.rs: the line's names are taken under the pending lock and formatted (and the scratch read) after it. Off, nothing changes: no note is made. Test: tests::trail_gpu_forms (device): four CPU-written triangle commands through a range buffer of [1, 2], recorded at commit merged; after completion the form reads the range 1+2, the merged draws [2147483646 x 0; 48 x 1 from vertex 2^31], 2 drawing arguments (7x2, 12x3), the most command 2's, no fault. |
||
|
|
47ee9f4806 |
Fan a rate-mapped draw out through four copies where its triangles reach at most four regions
A host step's fanned-out draw went through one geometry-stage variant that
declares the output of the most copies (up to 16) for every triangle, though
most draws' triangles touch only a few regions. The declared output size is
what the 780M's geometry stage pays for.
- The translator: RegionFanOut::DrawFew, the draw variant whose loop emits
at most FEW_COPIES (4) copies and whose geometry stage declares 3 x 4
output vertices; its codec name and compile-key word (" region_fan_out
few"); the link and engine tests cover the three modes.
- The probe: each draw's words grow to 1 + 2 x PROBE_COUNT_WORDS (65): its
flag, the 32 count lanes, and 32 wide lanes, where a triangle whose
widened pair count exceeds FEW_COPIES stores 1 (picked by PrimitiveId
mod 32, as the counts are). The host reduces them to (flag, copies, wide).
- The runtime: a fanned-out draw no triangle of which is wide draws
through DrawFew, else through Draw; commit's settle begins the three
variants (probe, few, most). Counted:
WorkCounts::rate_map_fanned_few_draws.
- The pieces lane prints the count. The runtime test's 8 commands add one
whose triangle covers four tiles a side (more regions than four, no more
than the most copies), drawn through the most copies, and assert the
other 6 fanned-out draws took four; the pixels are still the encoder's
region-by-region draws'.
- docs/FAST-PATHS.md: the fan-out row names the variant and its count, and
its cost cell carries the numbers below. bind/fan_out.rs: FEW_COPIES's
numbers.
Verified, release binaries, runtime_lane::rate_mapped_pieces and
tests::rate_mapped_fan_out, the command buffer's GPU time, cold then warm:
- Radeon 780M (Mesa 26.2.6), m3-max-24369, this change plus a scratch
switch (never landed) drawing every fanned draw through the most copies,
interleaved in one job: 4 copies 40.2/29.7 and 43.9/30.8 ms; the most
copies 61.9/36.8 and 62.7/34.5 ms. Warm about 5.4 ms (15%) less.
64 of 64 draws of four copies.
- Iris Xe (Mesa 26.2.6), m3-max-24317: 47.7 ms cold, 40.0 ms warm (40.5
warm through the most copies in an earlier run); 64 of 64 of four copies.
- RTX 3090 (NVIDIA 620.70.06), m3-max-24316: 28.6 ms cold, 6.1 ms warm
(6.2 ms before); 64 of 64 of four copies.
- tests::rate_mapped_fan_out on all three: 3 passed, 6 drawn of few
copies, the fan-out's pipelines 3 ready plus waited, 0 made at the step.
The Iris and 3090 runs are of the same change at base 9c30ffd263; the
780M's at
|
||
|
|
1ba15206d0 |
The trail's draw note takes the record's primitive type as it is: clippy's useless conversion
The after-merge check m3-max-24293 failed clippy (useless_conversion) on the two primitive-type .into() calls of render/executions.rs's trail_draw: the record's field is a u32 already. Verified: clippy, all features and under --cfg m2v_cpu_icd, in the check job. |
||
|
|
3a3c2fb3fd |
The encoder trail names each host-stepped draw's route, and the pipeline pool at a stall
For the 3090 hang, where a shadow pass's host step and a rate-mapped pass's fan-out ran in the same second: the trail now counts, per host step, the route each draw took (plain, the fan-out probe, fanned out, region by region) and the executions recorded in their GPU form, and its stall line names the device's pipeline pool's makings waiting and under way, so a driver compile running beside a hung batch shows. Default off. Verified: encoder_trail::tests and tests::stall (the line names the pool) in the check job. |
||
|
|
abacc1222e |
The encoder trail names what a host step drew: ranges read, draws, the largest, kept chunks
A stalled host-stepped render encoder's trail line named its states but not what its step recorded from the records and range buffers the GPU wrote, which is where a wrong count would come from. With the trail on, a host step now notes each range it read from a buffer (location and length as the bytes held them, and the commands it ran), its draws, their vertices or indices times instances summed, the draw of the most of those (primitive type, count, instances), and the kept chunks it ran again, whose draws it did not read. Default off: nothing is read or formatted with the trail off. Verified: the trail unit test (encoder_trail::tests) covers the line's new part. |
||
|
|
05a0efbede |
Key a settled regions variant's pipeline by its multi-draw viewports, as the step does
A host step that draws a rate-mapped pass's regions several at a time (VariantKey::region_viewports) keys the draw's VkPipeline with as many viewports as each multi-draw command sets (MultiDraws::batch); the commit's settle of an execution keyed it with the encoder's one. The key missed at the step, which made the pipeline itself on the first frame of a state: under RateMapRegionPolicy::Exact for every command, under FanOut for a draw the probe flagged. One function now decides the batch for both (render.rs region_batch), and the settle keys the viewports by it. The device tests a_host_step_fans_out_the_commands_the_probe_does_not_flag and exact_regions_draw_every_command_region_by_region check that the host step makes no pipeline (WorkCounts::host_step_pipelines_made); before this change each made one on the RTX 3090, the Iris Xe and the Radeon 780M (m3-max-24111, 24112, 24113, the FanOut test's flagged draw). Verified on an Iris Xe (Mesa 26.2.6; build m3-max-24241, run 24278, with the next commit): both device tests passed, the step making none; the pieces lane's cold frame under Exact made none at its host step (27.1 ms; 33.4 ms and one made before, m3-max-24112), under FanOut none (9.8 ms). Clippy of the runtime, validation and conformance crates (m2v_gpu, m2v_gpu_hazards): 0 messages (m3-max-24242). |
||
|
|
6a6327e772 |
Begin the fan-out's probe and draw pipelines at commit's settle
A host step that fanned a rate-mapped pass out made the probe's and the
fanned-out draws' geometry-stage pipelines itself on the first frame of a
state, on the step's thread, inside the command buffer's GPU window: 82.1
of an RTX 3090's 88.6 ms cold fanned-out frame in the pieces lane, while
the commit's settle had already begun the regions variants on the
device's pool.
RenderExecution::settle now also settles, where the pass's host step fans
out (DeferredPass::fans_out: the policy and features, no memoryless
attachment, no shadowed texture; an execution over a map, without
shadows), each foreseen state's draws under the probe's and the fanned-out
draw's fan-out, beginning their VkPipelines on the pool. settle_draw_of
takes the encoder's fan-out through fan_out_asked and settles nothing for
a draw the fan-out does not take. Those makings are kept apart from the
ones the host step waits for before it records the pass, each once
(Pending::same: a strip's and a list's draw settle to one key where the
topology is dynamic): fan_out_routes takes them made or waits for them
(hastened, as Pending::wait does) and counts each
(WorkCounts::rate_map_fan_out_pipelines_ready, _waited). A pass the step
does not fan out leaves them.
The device test a_host_step_fans_out_the_commands_the_probe_does_not_flag
checks that the commit began at least the probe's and the draw's pipelines
and that the FanOut step makes as many pipelines as the same frame's under
Exact (one: the regions variant, which the settle's key misses at the
step under either policy); before this change it made two more.
Verified once on each GPU under the default pipeline waits, the copy loop
of the next commit included (m3-max-24007 RTX 3090, 24008 Iris Xe, 24009
Radeon 780M; counts before each making was counted once): the device test
passed on all three, the step made no pipeline of the fan-out's. The
pieces lane's cold fanned-out frame: 3090 command buffer 44.2 ms (was
88.6), the step 37.7 ms waiting for its two makings, commit 7.4 ms; Iris
47.3 ms (was 110.4), both found made at the step, commit 2.1 ms; 780M 42.3 ms
(was 84.3), commit 1.8 ms. Warm: 7.5, 40.6 and 29.4 ms.
At the landing tip one rebase earlier (440f133b4b, on
|
||
|
|
efcb6851ce |
The encoder trail: name the encoder a stalled GPU stopped in, and the last one that completed
A GPU hang (a CTX SWITCH TIMEOUT on an RTX 3090) left the runtime with no way to say which encoder never completed: encoders share batches and grouped submissions, and neither METAL2VULKAN_LOG_PASSES nor METAL2VULKAN_QUEUE_TIMES logs anything at a stall. METAL2VULKAN_ENCODER_TRAIL (env_vars.rs), or DeviceOptions::encoder_trail for one device, is a default-off diagnostic (encoder_trail.rs): - Each encoder, and each part of one a host step splits off, ends its batch (Batches::alone), and no batch waits in a group, so each goes in a vkQueueSubmit of its own that signals its queue's timeline. When work goes to the driver changes; what it computes does not. - Each encoder notes what it was: its kind, its command buffer's object ID, its place, a render pass's area, samples, attachments' formats and sizes, instances and rate map, its indirect command executions, and the label hash of each state it bound (the first 8 bytes of a SHA-256 of the state's label and its functions' names; no name, no shader text). A host step adds the states its indirect commands named, as the GPU and the CPU left the records. - Once no work of the device advanced for 2 s with some pending, completion.rs's stall path logs one Info line (id name metal2vulkan-encoder-trail) for each VkQueue whose oldest batch is pending: that batch's encoders and the last batch the queue completed, with how long before; once a stall. - A submission a host step makes and waits for itself (a rasterization-rate map's fan-out probe, a predicated loop's check run again) signals no timeline; once it ran 2 s, one line names it, the encoder whose step made it and the states its commands named. Off, a device reads the switch once and notes nothing. Verified on msi (lavapipe, --cfg m2v_cpu_icd), at the branch tip this commit's tree equals: - tests::stall::the_encoder_trail_names_the_stuck_encoder_and_the_last_one_completed: a cb stuck on an event wait before two blit fills; the line names the stuck cb's encoder 0 (not its encoder 1) and the earlier completed cb's encoder 0: "VkQueue 0's oldest pending batch: Blit encoder 0 of command buffer 3, states []; the last batch it completed: Blit encoder 0 of command buffer 2, states [] (2.106823047s before)". - tests::rate_mapped_fan_out::the_encoder_trail_fans_out_the_same_pixels: with the trail on, probes/flagged/fanned [1, 1, 6] as without, no texel differs from the encoder's own draws. - The host-step families (rate_mapped_fan_out, rate_mapped_pieces, indirect_command_buffer_device, host_step_neutrals, ycbcr_in_place_loop) with METAL2VULKAN_ENCODER_TRAIL=1: 11 passed. - encoder_trail's unit test (one state's hash pinned: a reader of the pipeline creation log computes it again); the runtime suite 1504 passed; api_ tests 16 passed; clippy all features and the runtime under m2v_gpu and m2v_cpu_icd; rustdoc of the runtime and metal2vulkan. The runtime-sources pin moves (not re-pinned here). |
||
|
|
685ff90c1c |
Spread a fan-out probe's copy count over 32 words a draw by PrimitiveId
The host step's probe added each triangle's copies into one word per draw, so every triangle of a draw was an atomic add on the same address. On an RTX 3090 (NVIDIA 620.70.06) that made the probe 15.4 ms (cold) to 20.7 ms (warm) of GPU time for the pieces lane's 64 draws of 306,036 triangles, 20.7 of the warm frame's 26.8 ms, the fanned-out pass itself 3.0 ms. A scratch build whose probe added nothing ran it in 0.5 ms. Iris Xe and Radeon 780M ran the same probe in 1.1 and 0.5 ms. Each probed draw now takes bind::fan_out::PROBE_DRAW_WORDS words: its flag, then PROBE_COUNT_WORDS (32) counts, a triangle adding into the one its PrimitiveId picks (PrimitiveId & 31). The probe's geometry stage reads PrimitiveId whether or not the fragment function does. The host sums a draw's counts as it reads the flags back, so the routes see the same flag and copies pair as before. Verified, the pieces lane at 64 commands, each frame cold then warm, once per GPU (m3-max-23899, 23900, 23901): - RTX 3090: probe 1.45 ms; warm FanOut command buffer 6.0 ms (was 26.8) against Exact's 63.0. - Iris Xe (Mesa 26.2.6): probe 1.13 ms; warm FanOut 40.3 ms against 499.1. - Radeon 780M (Mesa 26.2.6): probe 0.40 to 0.49 ms; warm 34.7 ms against 231.7. The runtime's fan-out device tests passed on all three: pixels equal to the encoder's region-by-region draws, counts [1, 1, 6]. Test: link::tests::fan_out:: a_probe_adds_a_triangle_s_copies_into_the_count_its_primitive_picks checks the probe's triangle module adds once, reads PrimitiveId (and passes it on where the fragment function reads it) and masks it by 31. It passes, and fails against the one-word probe stage (negative control, m3-max-23925); clippy with m2v_gpu and m2v_gpu_hazards over the translator, the runtime and validation, 0 messages. |
||
|
|
257b77bc21 |
Fan a host step's rate-mapped draws out to the regions in one draw
A rate-mapped pass drew every draw once per region of the map's plan: an executed command's
triangles ran their vertex function 2074 times on a 3648 by 1734 screen's plan, and the command
buffer of a guest frame's shape took 514 ms of an Iris Xe's GPU and 462 ms of a Radeon 780M's.
At a host step, where the default `RateMapRegionPolicy::FanOut` holds and the device enables
`geometryShader`, `shaderClipDistance` and `vertexPipelineStoresAndAtomics`, the pass is now
probed first: each execution's commands, read once, are replayed in probe mode into a segment of
their own (one middle render pass per instance, the fan-out variant's geometry stage writing a
flag and a copy count per command and emitting nothing), submitted and waited for. A command
whose flag is clear (no triangle crosses w = 0 or touches more regions than the copies) is drawn
once through the fan-out variant over the whole target, its geometry stage emitting a copy per
region it touches; a flagged command, and every command after a barrier, after a draw that writes
memory or at a mesh or patch draw, is drawn region by region as before. A fan-out variant the
compile refuses falls back to region by region at the settle.
`RateMapRegionPolicy::Exact` (`DevicePolicy::exact_answers()`) keeps every draw region by
region. The FAST-PATHS row, the API.md bullet and a known gap (the encoder's own draws and the
draws commit records stay region by region) describe it; `WorkCounts` counts the probes, the
flagged and fanned-out draws and the probes' GPU time. `CommandBuffer::submit_waited` is the
loop check's waited submission, shared with the probe.
Verified (release, `--cfg m2v_gpu`, e55e6ebd01 before the rebase onto
|
||
|
|
2b8b56617d |
An object a recovery carries answers the caller's own device handle
What: the public device() of every object whose borrow reached a handle a recovery lets go of answers an owned Device, a clone of the generation handle it read: Buffer, Texture, Heap, IndirectCommandBuffer, Event, Fence, SamplerState, Library, Function, DepthStencilState, AddressPool, DynamicLibrary, BinaryArchive and SharedTextureHandle (whose device is its texture's). The runtime's own reads keep a borrow through a crate-private generation() on the types they read it of (Buffer, Texture, Heap, IndirectCommandBuffer, SamplerState, Function, BinaryArchive): 301 call sites, so no hot path pays a clone. Each changed item's doc says the handle is the caller's and keeps its generation, VkDevice included, while held, past a recovery that carries the object on; MadeOn's doc states that no borrow of it reaches the program. The validation lane's four callers that passed the borrow on take a reference of the handle. Signature table re-blessed (14 rows). Why: these accessors answered a borrow into device/carry.rs's MadeOn (a Buffer's or Event's parts, or a LineDevice's GenerationLink), whose let_go drops that Device at the lost generation's rest while the object lives. Safe code that held the borrow across a recovery and that rest read a dropped Device. Metal's device property answers a retained device. The other objects' device() (queues, command buffers, argument encoders, rate maps, pipeline states and their function tables) answer a borrow of a handle the object owns for its life, which no recovery lets go of. Verified: the lane that follows runs tests::device_recovery_handles before (it fails: one live VkDevice while the borrow is held) and after the fix; a workspace check of the accessor change was clean under the plain cfg and found the four validation callers under m2v_gpu and m2v_cpu_icd (job m3-max-23584 on a probe commit). |
||
|
|
f5d97f8e95 |
Cut a rate-mapped execution's big draws into ranges of their indices
A piece bound by command count, or by whole commands, still lets one command hold unbounded work: the sample's largest executed command draws 161,820 indices, times its 2,074 regions about 2.5 times the old piece work in one draw. Where an executed command's draw in a rate-mapped pass would alone hold more than the piece work, it is now drawn as consecutive ranges of its indices, each a draw of its own that a piece may begin before. That draws what Metal's one draw does only for an indexed list (points, lines, triangles: Metal never restarts a list) cut at primitive ends, of one instance, whose pipeline reads no [[primitive_id]] and writes no memory; every command of the sample is such a draw. Ranges are sized by the most region draws a draw of the execution made so far (the most a plan holds before any), an even count of primitives so 16-bit ranges keep 4-byte offsets. Any other draw rides whole: FAST-PATHS' known gaps now name them, with the encoder's own draws, as able to pass amdgpu's job timeout and NVIDIA's context-switch timeout. PIECE_WORK halves to 2^26, so a piece of cut draws holds under 2^27: about 56 ms of Iris Xe at a trivial vertex function, 35x under 2 s. WorkCounts::rate_map_index_ranges counts the ranges past the first; the signature table gains it and the four piece counters. A runtime device test draws eight commands of a twice-drawn blended triangle grid through 32-bit and offset 16-bit indices over a falling map, and checks the execution cut under a small piece work against the uncut execution and the encoder's own draws, byte for byte, with pieces and ranges counted. Unverified at this commit: the compile check and device runs are next. |
||
|
|
409c95ce23 |
Record a rate-mapped pass's executed commands in bounded pieces
A rate-mapped pass drawn region by region can hold more GPU work in one execution than amdgpu lets a kernel submission run (2 s by default); the sample's 8,162-command executions at 2,074 regions hang the 780M. Where an execution's commands record inline, each command's region draws now count their work (vertices or indices times instances per region draw, plus a per-draw term); once it reaches the piece bound the next command begins a new run, and that run begins a piece: the pass's recording ends its VkCommandBuffer there, and the batch's submission submits each piece but the last as a VkSubmitInfo of its own that signals the VkQueue's new timeline of pieces, so Mesa's queue does not merge it into the next kernel submission. Pieces are timed where the device writes timestamps, and counted (WorkCounts::rate_map_pieces, rate_map_piece_gpu_nanos*). Unverified at this commit: a compile check is next. |
||
|
|
a610b58b8a |
A replayed draw whose making outlasts the commit's bound leaves its pass to the host step
The last draw dropped for its making's time: a draw of an execution's replay at commit (render commands the CPU writes) whose pipeline the replay began itself and that was still being made at the command buffer's bound recorded nothing. Metal cannot encode a draw before its pipeline exists, so every encoded draw runs. Now the replay at commit stops there, keeps the making on the command buffer (CommandBuffer::leave_unmade), and the pass takes it into the makings its host step waits for (DeferredPass::left_for_makings): the commit leaves the pass to the host step with its pipelines pending, as it already did for a pass whose settled makings were still being made, and the step records it from the records as they stand then once the making lands. A replay inside a host step waits for its making until made, on the step's thread. record_on_gpu declines to the host step the same way. The commit still returns at its bound at most. Removed: DrawDroppedStillMaking, WorkCounts::draws_dropped_still_making, CommandBuffer::drop_late_draw, RenderLowering::drop_late_replayed_draw, the execution's encoder place that only named the dropped draw, and the open-gap text in FAST-PATHS row 43, API.md (the bullet and the catalogue entry), the runtime README and the PipelineWaitPolicy docs (api_signatures.tsv -2). The IndirectCommandCheck and executed-commands docs name the new case in which an execution read at commit is read and checked again in its host step. The gap's test flips: a_replayed_draw_whose_pipeline_is_still_being_made_at_its_bound_renders_once_made (commit returns after the bound and before the 10 s watchdog; the command buffer is not complete a second past its bound while another queue completes; once the hold goes it completes with the rectangle drawn and nothing dropped). Checked by the lint and lavapipe jobs reported with it. |
||
|
|
91dbc91bbc |
Hold a command buffer for its draws' and dispatches' makings instead of dropping them
A dispatch whose pipeline was still being made 4.5 s after its command buffer's commit recorded nothing, and so did such a draw. Metal makes a state's pipelines inside its creation, so every draw and dispatch it encodes runs: a dropped dispatch leaves wrong results (a guest's path tracer dropped 45 dispatches behind a 116 s compile on the RX 7900 XTX), and a dropped draw leaves content drawn once (a cached shadow map, a glyph atlas) without it. The owner's rule: no switch may break Metal's contract, so the dropping form is removed, not kept behind a switch. A batch's host step now waits for every making its segments record, past the bound too (Segment::steps_after_pipelines; the scheduler's StepWaits loses its `until`, and Segment::holds goes): the batch stays in its queue's line on the scheduler's thread, which no call waits for, and records the draws and dispatches once made. Held batches still give way to other queues' later commits that share no fence. `commit` waits for no making but a pass that executes render commands the CPU writes, until its bound, and leaves that pass to the host step past it. The pending dispatch, tile dispatch and pending draw recordings wait until made. DispatchDroppedStillMaking, its counter and catalogue entry, and CommandBuffer::drop_late_dispatch are removed. One drop remains, an open gap named in FAST-PATHS and the notice: a draw of an execution's replay whose pipeline the replay itself began making, of a key the commit's settle did not foresee, still being made at the bound (DrawDroppedStillMaking, now that case alone). That case is the next change. Tests (device, rewritten): a draw, a replayed draw and a dispatch whose makings are held past the bound each complete once the making lands, drawn or written, nothing dropped, while another queue's command buffer completes meanwhile and the held one is still not complete a second past its bound. |
||
|
|
644e670dd9 |
A texture turns no face after an execution of indirect commands in its command buffer
What: an encoder that leaves an execution of indirect commands to record later (compute and render, defer_execution) notes it on its command buffer's heap use (HeapUse::executes_later), and a pass's turn point takes that as bound heaps (HeapUse::may_bind): the turn is refused (Unturned::Busy) and the pass copies in, as where an earlier command bound a heap set. Docs: faces.rs (When, Unturned::Busy, TurnPoint). Why: a turn writes the texture's heap set elements again, so it is refused where a command of the command buffer bound a heap set: such a command runs before the turning pass and would read the new face through the texture's ID. An execution's commands are recorded by the commit or a host step, after the pass opened, so they bound no heap set yet when the turn was decided, and read the face the pass turned to (stale texels) through an argument buffer naming the texture. An encoder encoded again after a rebind leaves its execution to record later as its first encoding did, so the turn its pass decided is refused alike. Verification: the previous commit's test, without and with this change, on lavapipe and one device; results go with the hand-off. |
||
|
|
f10321aad5 |
A pass left for its draws' pipelines takes its encoding again once they are made
A render pass whose draw's VkPipeline was still being made as it was encoded records as a segment
of its encoder once the pipeline is made (render/pending.rs). A rate map's reset after that
making finished, before the command buffer's commit or after it while the command buffer waited,
encoded the pass again from its log, and the splice refused it: the segment in its place was
neither one whose pipelines are still being made nor work recorded on the GPU alone. The pass
then drew by the map it took and the reset announced rate-map-reset-unencoded, where Metal's GPU
draws by the map as reset. The rate-mapped multi-draw route made this common: its vertex variant
is made at a pass's first draw, so the reset lanes failed by timing
(a_reset_shows_in_a_pass_not_yet_submitted and a_reset_shows_in_every_pass_not_yet_submitted on
lavapipe, jobs m3-max-22179 and m3-max-22244).
The splice now also takes the place of a render pass left for its draws' or tile dispatches'
pipelines alone and executing no render commands (Deferred::left_for_pipelines,
DeferredPass::left_for_pipelines), made since or not: the encoding again recorded those draws
where it found their pipelines made, or left a segment of its own where they were still being
made, and what the first recording took stays retained, as for a segment still being made.
Verified, before the fix: a diagnostic on lavapipe (job m3-max-22327) waited a second after the
draw and refused the splice in both cases ("keeps false gpu_alone false ... making false"),
shading the identity's 64 by 64 pixels with the notice; without the wait the pipeline was still
being made and the splice took it. The new lane
a_reset_shows_in_a_pass_whose_pipeline_was_made_after_its_draw waits for the making
(WorkCounts::variant_pipelines_made) and checks the half map's 33 by 33 pixels and no notice.
|
||
|
|
7bb1358224 |
Runtime: record a rate-mapped pass's regions several at a time through VK_EXT_multi_draw
Where the device enables multiDraw, multiViewport, shaderOutputViewportIndex and shaderDrawParameters, a direct draw of one amplification in a rate-mapped pass whose map may plan several regions (not the identity), of a vertex+fragment pipeline whose vertex function chooses no slice or viewport and takes no compensation or band, asks for the region variant (BindState::region_viewports). The binder keeps the request only for a vertex pipeline drawn in one pass of no views, and the runtime follows the settled plan's VariantKey. Each batch of k regions (k = min(regions, maxViewports, maxMultiDrawCount - 1); the spec's "drawCount must be less than" maxMultiDrawCount) sets k viewports and scissors, the last batch padded with its first viewport through empty scissors, and records one vkCmdDrawMulti[Indexed]EXT of as many identical draws as regions; the VkPipeline takes k viewports (FixedState::viewports). DrawIndex selects each region's viewport and scissor. - recorder: vkCmdDrawMultiEXT / vkCmdDrawMultiIndexedEXT routed and counted (MultiDraws). - device: MultiDraws loaded with the batch from VkPhysicalDeviceMultiDrawPropertiesEXT. - render: DrawState::draws, region_states, Recording::multi; execution settles ask alike. - lane rate_mapped_passes: a direct draw (batched) and the same draw from an indirect buffer (region by region) shade the same bytes over 36 regions, plain and indexed; the counts show each route ran. rate_map_costs counts multi-draws. - binder: a mesh, tessellated or amplified draw keeps the plain variant. Verified: not yet built; the next commits fix forward what the build reports. |
||
|
|
7284147b43 |
A draw that reads its own color at its own pixels and writes none of it reads in place
A draw whose fragment function reads, at its own pixels alone, a texture its own render pass instance renders as a color, and whose pipeline writes no channel of that color, now reads the attachment in place, with a memory barrier before it or without: no copy, snapshot or split. The color is in the feedback loop layout for its instance, the pipeline is made with VK_PIPELINE_CREATE_COLOR_ATTACHMENT_FEEDBACK_LOOP_BIT_EXT, and the slot binds the texture in that layout. A by-region barrier before the draw (color writes to fragment shader reads) orders the earlier draws' and the load's writes before its reads (Vulkan 8.10.5), and a by-region execution barrier after it (fragment shader to color output) orders its reads before later draws' writes. Its own writes go to other colors, so no fragment of the draw races another over the texels it reads. It reuses the snapshot route's checks (pass shape, view format, pins, one image) and its binding (render/snapshot.rs, in place), on a device that enabled attachmentFeedbackLoopLayout. Why: the real Macs disagree on such a read without a barrier (probe ownread.m: the M3 Max answers the texels from before the pass at every pixel; the 5300M answers the earlier draws' writes at 98.6% of pixels and at all after a barrier; the UHD 630 at all but 0.01%). Under the owner's rule for such disagreements we take the cheapest form, the x86 Macs' answer, recorded as an accepted difference in docs/API.md. A compositor's backdrop reads paid a copy of the whole target per draw before. texture/attached_reads.rs now gives a color's image feedback loop usage wherever the device enabled attachmentFeedbackLoopLayout, not only where it has the snapshot route's write-mask command. New WorkCounts::reading_draws_in_place (api_signatures.tsv row). The draw-key and graphics-key carry a feedback_loop bit for the pipeline flag. render.rs (the draw's snapshot plumbing) is touched at: the draw's snapshot request, the phase hole, the counts, the snapshot views, the pair base and phases, Recording::record (the barrier after), and settle_draw's snapshot checks. Lane test runtime_lane::in_place_reads with an owned fixture ipr_reads.metal (regenerated with scripts/regen-air-fixtures). The golden tables and the compile census are re-blessed on development. Verified: not yet compiled; potluck build, lint and lavapipe lane jobs follow. |
||
|
|
e17223aed8 |
A render execution's range read from a buffer runs on the GPU in the merged form
executeCommandsInBuffer:indirectBuffer:indirectBufferOffset: sent every render execution to the host step, even when the GPU wrote the commands and they merge into one draw. That costs a GPU-to-CPU round trip each time. Now an execution whose commands merge takes the GPU form whatever its range: - The draw replay gets DrawReplay::range_read. The preprocess runs over every command of the buffer. Each invocation reads the range (location, then length) from the parameters (DrawReplayLayout::range_offset). A command outside the range draws nothing. - The range is taken as the host step takes it (ExecutionRange::commands): clamped at the size. A location past the size, or an end past 2^32 - 1, draws nothing and reports RANGE once. - The binder refuses range_read unless the replay is merged and covers the whole buffer (ReplayRefusal::RangeRead). - The runtime copies the range's 8 bytes, where the encoder read them (indirect_execute::range_from), into the scratch's parameters between barriers, before the preprocess. - These still take the host step, and the notice names the rule: commands that do not merge (a strip type, or a rule of the merged form), and an execution whose records the CPU alone writes. The degrade notice's text (degradation.rs, docs/API.md), the render executions' docs and the upload arena's docs now describe this. The API signatures are re-blessed. Tests: - bind::replay::draws::tests::a_replay_that_reads_its_range_draws_the_commands_inside_it, on the CPU interpreter: seven ranges, including clamped, empty, at the size, past the size and past 2^32 - 1. Each command's arguments and the merged corners are checked, plus both refusals. - runtime_lane::render_merged_executions::a_range_read_from_a_buffer_draws_on_the_gpu_what_the_host_step_draws: four ranges, one written by a blit before the pass. The GPU form draws 8 merged commands and reads no record. Its pixels and execution report equal the host step's. |
||
|
|
2724757bbf |
A host step waits for the batches that wrote what it reads, not every queue's work
A batch whose host step records indirect commands the GPU may write waited, once otherwise ready, until every VkQueue completed what was submitted to it by then. A frame of a GPU-culling renderer (a kernel encodes the draws and their execution range, then several render passes execute them through the range) paid one GPU round trip per pass: each pass's step waited for the passes before it in its command buffer, and for other queues' unrelated work, though it reads only the records and the range the culling wrote. The range read made it worse: it was read from a copy recorded right before the execution, in the batch of the previous pass. Now the gate is taken from the hazard state where it can be (scheduler gate_of): - CommandBufferShared::step_reads names what a batch's host step reads on the host of what the GPU may write, where each segment whose step waits for the GPU is an execution (outside a block of command predication) or a render pass of executions whose uses commit bounded: their records and ranges (Deferred::host_reads, ExecutionRange::host_reads), with their host aliases. Anything else (an indirect dispatch, a loop's check, a staged gather, an indirect sparse update) answers None. - Tracker::last_writes answers, per VkQueue, the value of the last batch that wrote those bytes of the writes the state holds; None for an untracked resource. The state forgets only what completed, and a write that let an older entry go waited for it, so once each queue reached its value every GPU write to those bytes completed and reached the host (every batch ends with the barrier to the host). Every such writer is submitted by the time the gate is taken: earlier batches of the line went first, an earlier commit's conflicting batch on another line holds the head behind it (its footprint holds the step's reads), a later one waits behind it. - Where either answers None the gate is every queue's last submission, as before. - The range of executeCommandsInBuffer:indirectBuffer: is read in place where the host maps the bytes the GPU writes (Buffer::maps_gpu_bytes: not Private, not a Managed host copy on a discrete device, not a copied host buffer), through Buffer::read_mapped, which holds a no-copy buffer's pages while it reads 8 bytes so a detach and rebind meanwhile free none of them; a detached buffer runs nothing. The read is noted at the call as a command that reads the bytes (no GPU work), so the encoder's order, a detach and the hazard state see it as they saw the copy's. Other buffers keep the copy. - WorkCounts::host_step_gates_narrowed counts gates that left out work submitted before them; the conformance cost tables report it and never gate it (QUEUE_DEPTH: whether a gate falls below a queue's last submission depends on whether the host had seen the writer complete). - The HostReplayedIndirectCommands notice's cost, its catalogue entry in docs/API.md, the scheduler's and indirect_execute's module docs and the execution calls' docs say so. Tests: tracker a_host_read_waits_for_the_last_writes_of_its_bytes_alone (the writer per queue, no writer, a covering write on another queue, untracked, a queue past the count, retired). Lane depth_executions a_frame_s_executions_wait_for_the_culling_alone: a culling command buffer on one queue, a fill on another queue submitted before the frame, then a frame of two passes that execute the commands through the range: two host steps, both gates narrowed, both targets hold each kept chunk's depth. The existing depth_executions test now shares its workload. No Metal-visible behaviour changes: what the steps read and record is the same; they start earlier. |
||
|
|
6d9bc9f096 |
RuntimeGap::IndirectRenderCommands names the rule that refused it (IndirectRule)
One gap stood for a dozen rules: an execution of the other encoder kind's commands, a range a draw of the encoder may write, a command's memoryless texture slot, a color in another format, the shader-side depth test, a shadowed texture the call did not gather, residency past the call meeting a shadow's truth, an emulated mesh command's ordering, a memoryless attachment read past the pass, and on an Apple10 device the render states the commands set themselves. A consumer's log said "IndirectRenderCommands" for all of them, so a report could not say which one a program met (a public GPU-culling sample's host step on an RX 550 did not). The variant now carries IndirectRule (public, non-exhaustive, Copy), one value per site, and the error's text prints it: "not implemented in the runtime yet: IndirectRenderCommands(UngatheredShadow)". A family row of indirect render commands names FamilyRow, the summary of the others. No behavior changes: every site refuses where it did, typed as before. Tests that expected the gap now expect its rule: the other encoder kind (render_executions, indirect_command_buffers), a range a draw wrote (render_executions), residency past the call (buffer_texture_renders), mesh ordering (mesh_commands) and the Apple10 states (state_ids, command_render_states, families). docs/REFUSALS.md and api_signatures.tsv regenerated. A consumer that names RuntimeGap::IndirectRenderCommands names a rule now, or matches IndirectRenderCommands(_). |
||
|
|
d971205216 |
RUNTIME_VERSION 2101: a slot that reads only levels past the attached ones reads them in place
A draw that samples a texture its own pass renders at one level read the texture's copy unless every read reached only levels before the lowest attached one. A slot every read of which reaches only levels past the highest attached one (a pyramid pass that renders level m from level m + 1, or through a sampler whose minLod lies past m) now binds the texture's own image through a view of its levels from the first up to the highest it reads (all of them where the sampler's maxLod reaches past the last), and names in its uses only those from the lowest it may read (LevelReads::lowest_level, SampledLevels::lowest, through each bound sampler's levels, its lodBias as the bind takes it included). The levels read hold the copy's texels: nothing the instance does writes them, checked as the levels-before case checks (reads_levels_in_place, shares_attachment, the unordered writes, the draw's own writes). The view holds the attached levels too, unread. Vulkan's rules against reading an attachment are of accesses (VUID-vkCmdDraw-None-10795; the Render Pass chapter's subresource "simultaneously being used as an attachment"), and the descriptor's layout must match the subresources the view holds (VUID-vkCmdDraw-imageLayout-00344): GENERAL, where every attachment rests. So such a slot keeps its copy in an instance that holds one of the texture's attached colors in the feedback loop layout, and the instance's general_colors (renamed from storage_colors, which now also holds the colors such a view spans) sends a later snapshot read of one into another instance. Counted as WorkCounts::attached_read_slots_past. The reasons a slot keeps its copy now test any level before the first-level case, which covers only a read that may reach an attached level. Tests: tests::attached_levels (runtime, the device cfgs) gains reads past the attached level; runtime_lane::attached_levels (validation, under the layer) reads levels past the attached one in a pass recorded inline, where the layer sees the attachment. Verified: built and run in the next job, with a negative control. |
||
|
|
834b663634 |
Runtime: pull a far vertex layout on a driver whose fixed-function fetch wraps at 4 GiB
lavapipe's fixed-function vertex input takes an element's displacement modulo 2^32: the conformance case vertex-fetch-past-4gib-small-buffer reads the wrapped words in 24 elements where Metal reads zero. Vulkan places the attribute at the whole displacement (28.4 Vertex Input Address Calculation) and robustBufferAccess2 makes a read past the bound range zero, so the wrap is the driver's defect: a new RuntimeDriverDefect::VertexFetchWrapsPast4GiB, listed for MESA_LLVMPIPE alone. On a listed driver the render lowering names the fixed-function layouts a draw may fetch past 2^32 bytes of their bind offset in a new BindState/BindShape field, far_vertex_buffers, and the binder pulls them (the existing pulled-vertex-buffer variant, whose fetch reads past 2^32 as zero). The reach is the existing furthest_element: a draw's last vertex, 65535 plus the base vertex for ushort indices, the base instance plus the last instance over the rate. Those are pulled by default. A per-vertex layout of a uint-indexed draw, and an indirect draw's, has its reach stated by GPU memory; pulling it costs a variant for every such draw, so it is behind a new runtime-only DevicePolicy switch, vertex_reach (VertexReachPolicy::Bounded by default, Exact in exact_answers()). Under Bounded such a draw keeps fixed function and is announced vertex-fetch-may-wrap (Precision). The draw-again paths (rebound, restated) compare the pulled set; the host-step precompile names none; the GPU replay derives it from its indirect draw. WorkCounts::far_vertex_fetch_pulled_draws counts the pulled draws. The conformance case's known-gaps row is removed: replay runs under Exact. FAST-PATHS gets the switch's row (its lavapipe cost is measured next, in a later commit). New tests: the binder pulls a named layout; far_layouts under both policies; runtime_lane::far_vertex_fetches measures the defect on every device under both values, and far_reach_costs (ignored) measures the exact form's cost. SEMANTICS_VERSION is unchanged: an empty far_vertex_buffers, every existing shape's, plans as before, so no output changes under an unchanged key. Verified so far: api_signatures blessed (signatures.py), refusal_surface --check, the conformance and Metal coverage checks; builds and tests follow as potluck jobs. |
||
|
|
984e49e455 |
Pass log: an execution's replay encoder notes nothing
The replay encoder of a render-command execution (render/executions.rs) is a RenderLowering of its own and took no pass_notes, so the runtime did not build. It is no pass of the program's: the executing encoder's line names the pass. Verified: cargo fmt; the build runs on potluck after this commit. |
||
|
|
75e5e5def1 |
Render draws reach their bind state with no Arc clone and no lock
Every render draw cloned the encoder's Arc<Mutex<LiveBind>> and locked it: two atomic counts and a lock and unlock per draw, there only so that a draw could hold the bind state while it called the lowering's other methods. On draws.10k the clone, lock, unlock and drop were about 28% of draw_rebound's own samples (a line-level profile on gem10), and a probe that reached the state with neither cut about 104 instructions a draw on the M3 (-2.0%). The bind state now lies beside the lowering instead of inside it: Lowering holds the boxed RenderLowering and the boxed LiveBind, derefs to the lowering for every other call, and hands a draw both as two borrows (Lowering::parts, RenderCommandEncoder::draw_at_call). The draw path takes the state as a parameter: the lowering's draw entry points, draw, draw_again, draw_rebound, draw_resident, the extended shadows' re-recording, the execution replays and their settles. Ending the encoder gives the state back to the device (Lowering::ending); SpareLiveBinds keeps the boxes, so an encoder's open and end still move and allocate none. An execution's encoders, and its chunks recorded apart, carry their bind state beside the encoder as before. Verified: pending (build, clippy, A/B on the M3 and lavapipe, suites). (cherry picked from commit 7692b71ca46440c42ead3f3b1061428559ba85d5) |
||
|
|
853e4cb37b |
Fix the coverage build: one Texture::root, the replay's readers, read only the measured queries
The view shadow's Texture::root already walks a view to the texture it was made from; the copy in texture.rs duplicated it. The replay lowering (render/executions.rs) builds a RenderLowering of its own and now starts with no readers. Readback reads the results of the queries its readers took, the pool's first ones, not all 64. (cherry picked from commit 599984b2e727c986e50ec59bd0f83dea63a3cc61) |
||
|
|
e5c37ecc62 |
Read a self-read through a snapshot of a color's own image where its image lacks STORAGE, pinning the instances through it
On the Iris Xe (m3-max-5702, the self_reads lane) a surface in place over host pages split every reading draw: 30 splits a frame, 224M texels copied in, 19.5 to 26 ms of GPU a frame, where its shadow took the snapshot (4.2 to 4.8 ms). Its image lacks STORAGE (the device's check failed storage writes over its pages), so snapshot_wanted fell back: a later framebuffer fetch of the color would render it through a stand-in for the whole pass, copied in before the pass, which a snapshot draw reading the texture's own image would not see. A draw now reads such a color through a snapshot of its own image all the same, pinning it (RenderLowering::pins_own_attachment), where nothing the pass's end decides from the whole pass changes what the instances through the draw render: the pass's first instance recorded inline, no stand-in, memoryless color or depth/stencil attachment in the pass, every color stored Store, no tile dispatch, execution, color groups or extended-range shadows, a draw that fetches nothing and needs no hidden depth. A stand-in arriving after a pin freezes the pins (no later draw pins), and the pass's end then renders the instances through the last pinned one with the colors' own images, takes each stand-in's copy of its attachment after the last of them (and a merged color's keep after that copy), keeps the reloads after them alone and joins no run of passes: as after an instance recorded inline (render/inline_first.rs). Counted: WorkCounts::reading_draws_pinned, WorkCounts::stand_ins_after_pins. Tests: tests::self_read_storage: a private target without STORAGE pins its first pass's reader and then takes its storage form; a pass whose pinned reader is followed by a fetch of the target keeps the reader's pixels and halves the fetched ones (a stand-in for the whole pass would leave the reader the red before the pass). The self-read cost lane (runtime_lane::attachment_read_costs::self_reads) prints the readers pinned per frame. Verified: - Iris Xe (ANV, Mesa 26.2.6), m3-max-6011: tests::self_read_storage passed both. A private BGRA8Unorm target without STORAGE gave (splits, snapshotted, pinned, stand-ins after pins, storage forms) = [0, 1, 1, 0, 1] in its first pass and [0, 1, 0, 0, 0] in later passes. A fetch after a pinned reader gave [0, 1, 1, 1, 1] in pass 0, with the reader's pixels the pass's red and the fetched ones halved. - lavapipe takes no snapshot path. There, both tests check the split branch ([1, 0, 0, 0, 0]); 193 filtered lavapipe tests passed in m3-max-5964. - Clippy plain, --cfg m2v_cpu_icd and --cfg m2v_gpu, and rustdoc -D warnings, for runtime and validation: clean (m3-max-5964). - The Iris lane frame: the device's render-target check now fails over host pages (the next commits), so the surface is a shadow and its readers take the snapshot unpinned: 3.94-3.97 ms/frame on development and on this commit alike (m3-max-6068, three rounds each, each process checking on a fresh cache). Pins apply there to a private target without STORAGE and to a render target over pages whose check passed. (cherry picked from commit e0799938e01c14d6b087ce7442bf9acfe3171b1c) |
||
|
|
ec9706e6e3 |
Survive the loss of the VkDevice: the device is a line of generations
Metal's MTLDevice survives a GPU recovery; the runtime's device refused every call with DeviceLost from the first loss on, and the consumer ends its VM at the first refusal. Now a device the runtime made is a line of generations (device/line.rs), each a DeviceShared over its own VkDevice, and the first call that needs the device after a loss makes a new VkDevice of the same physical device, options, queue families and extensions. - Two kinds of handle. The program's device (and its clones) is a root handle: it holds the line, pins no generation, and every public Device call goes to the generation that serves (each public method forwards to its *_now body). Objects hold generation handles, so their Vulkan calls, drops included, reach their own VkDevice alone. A generation handle's check is one relaxed load of the line's generation (Device::generation_serves). - A draw pays nothing for it. A command buffer takes its generation once, as it is made (CommandBuffer::generation); its encoders' per-draw reaches (work counts, fresh-unwritten and alias records, sampler-slot changes, attachment read notices) read it there, not through a device handle's kind. A bind's device check is one compare of the cells the two handles hold, inlined, its refusal (Device::foreign) out of line. - The state machine (Live, Lost, Failed): the claiming call recovers, every other call waits (a notice past 10 s, waiting on); threads command buffers' completion depends on never wait. Recovery: the lost generation's command buffers in flight fail through its completion path, its queues drain under their locks, create_on makes the next VkDevice, the queues are retired. - Command-buffer answers, as a real loss is one more hang: the oldest incomplete batch's command buffer fails GpuHang (exact on one VkQueue; on two or more the queue whose oldest incomplete batch was submitted first, said so in the notice), counted against its queue so the second revokes it (AccessRevoked); the others GpuRecoveryVictim; one committed on the hang's queue before the recovery runs nothing and completes with no error; one made before and committed after fails GpuRecoveryVictim. One loss names one hang: a batch that went to the driver just before the loss and reached the lost device's completion after the loss took the pending batches fails with it, as a victim (its own wait need not fail: the test hook's VkDevice runs it), and no later failure of the lost device names a second hang. - Command queues survive: a queue is a root handle and a cell of its place on one generation (VkQueue, slots, pools, hangs), which a recovery retires and the next command buffer re-makes; label and GPU-error count go on. - Objects made before a recovery are refused where they meet the new VkDevice or need their lost one: RuntimeGap::MadeBeforeRecovery, at the 38 lost-device checks (Device::lost_refusal) and at every foreign-object check of one line (Device::foreign). DeviceLost stays for a device the consumer made. - Carried across generations: the address space, resource IDs and the passing holds a making waits out before it takes one, unique identifiers, counters and the announced notice kinds. - A device handle is an enum of the two kinds (24 bytes, was 16): the shadow merge's copy-back dispatch, which holds handles, is boxed (clippy's large_enum_variant). - Device::recover_for_test (public, documented) runs the whole path with no GPU fault; RuntimeGap::AdoptedDeviceRecovery on an adopted device. - Degradation::DeviceRecovered (device-recovered), announced at each recovery with the culprit and its time. WorkCounts::vk_devices_live, vk_devices_made, device_recoveries: two VkDevices while objects of the lost one live, one after. Docs: docs/API.md catalogue entry, the runtime README's device-loss section, FAST-PATHS known gap (a make whose own submission first meets the loss is refused DeviceLost), docs/REFUSALS.md regenerated (refusal_surface.py names a forwarded body's sites by its public method), api_signatures blessed. Tests: runtime_lane::device_recovery (hang and victims, command buffers on their way to the driver at a recovery, MadeBeforeRecovery and the VkDevice bound, revocation at the second hang, a command buffer made before fails as victim, all under the validation layer; a recovery that finds nothing of the queue scheduled names no hang, its command buffers victims), tests::device_recovery (the hold of the hang's queue between a loss and the recovery), detach_lost and the MoltenVK lost-device lanes updated to the recovery's answers. Verified: - lavapipe: runtime suite and touched validation tests 1850/1850, surface 19/19 (m3-max-5695, gem10, before the rebase onto |
||
|
|
fcde58393c |
Announce the interlocked split with its own cause, and expect it in the fetch lanes
The split before a draw that reaches interlocked storage an earlier draw
of its instance wrote (Split::InterlockedWrites, where
DriverFact::InterlockedDrawsRaceUnderLoad holds) is announced as
render-pass-split. Its instances share one shape, so the notice gave the
generic reason ("its draws keep different attachments out of their
subpass"), which is wrong for it. SplitCauses gains interlocked_writes,
counted where the split is taken (an execution's runs through its
Found), and the notice names the cause. The RenderPassSplit doc and the
docs/API.md catalogue entry name the fact.
Three framebuffer_fetch lanes failed on the M3 Max (m3-max-5404). The
split is announced with the backing it gives a memoryless attachment,
and it adds instances. fetches_degrade_once_per_kind and
a_plain_draw_before_a_fetch_takes_the_devices_faster_form now expect
the announcement where the device splits so (splits_interlocked_writes).
a_memoryless_attachment_fetched_after_a_plain_inline_draw_starts_from_zero
counts the splits: 3 a pass there, none elsewhere.
Verified: cargo fmt. The M3 lane run follows.
(cherry picked from commit 844d58ba93764fd2b34d668114ac05b565c76a0d)
|
||
|
|
e5f1200536 |
Give an execution's render lowering its attachment memo too
The attachment memo commit (1a6da446ee) added RenderLowering::attached, which the lowering an execution of render commands makes (render/executions.rs) did not set (E0063, M3 job m3-max-4390). (cherry picked from commit 8d237c7bf38f4996469c74b58789133ea9864fcf) |
||
|
|
14c4b1ae67 |
An executed command's unstrided buffer takes the record's stride only where a dynamic layout reads it
28dc11d1b2 gave every buffer an indirect command set without a stride the
stride 2^32 - 1 on a buffer of dynamic attribute strides, whatever read it.
A buffer no layout of MTLBufferLayoutStrideDynamic reads (a kernel's output
buffer beside its stage-in buffer, say) then carried a stride the encoder's
own dispatch never gives it, and the command ran another compiled variant
than the dispatch: the lane's census of executed kernel cases failed at
stage-in-of-a-dynamic-stride-layout-of-an-executed-command-template ("another
execution", shard 15, MoltenVK on the M3 Max, jobs m3-max-4066, 4135, 4150).
Now the kernel path keeps the unstrided indices and inserts the stride at
dispatch only where pipeline.reads_stage_in_stride(index) holds, and the
render path inserts it after the command's state is known only where
reads_vertex_stride (restored) holds: a dynamic layout whose step reads an
element. What a dynamic layout reads is unchanged: 2^32 - 1.
Verified: none yet; the shard and the two unstrided lane tests follow.
(cherry picked from commit f7a9747f90a53aa7687ee95e087cf9d2a5b2a25a)
|
||
|
|
1fcaa5aa58 |
Read an executed indirect command's unstrided buffer at stride 2^32-1, as Metal does
An executed indirect command's kernel or vertex buffer set without an
attribute stride (the plain setter, or the stride form at
MTLAttributeStrideStatic), on an indirect command buffer that supports
dynamic attribute strides, under a layout of
MTLBufferLayoutStrideDynamic, was refused
NotImplemented(RuntimeGap::IndirectCommandUnstridedBuffer): plain Metal
reads it at the record's 32-bit stride word, 2^32-1 (measured on an M3
Max under macOS 27.0.1 with markers at bytes 2^32-1 and 2^32 of a buffer
past 4 GiB, compute and render alike; the stride form at 0xFFFFFFFF read
the same), which the 32-bit fetch could not place. The pulled fetch now
places a displacement past 32 bits (its reach check,
|
||
|
|
86d4b1cc0d |
Keep a render encoder's core box for the device's next render encoder
|
||
|
|
091354812a |
Key a draw's render pipeline by its pass without the resolves
A render state's creation predicts its first draw's key with a pass that resolves nothing, since nothing it sees says whether its draws' passes resolve. The draws keyed the pass's whole shape, color and depth/stencil resolves included, so a draw in a pass that resolves never took the creation's pipeline and made its own: on the M3 (MoltenVK) every `a2c-*`, `resolve-*`, `layered-resolve-places`, `pass-two-attachments-resolves` and `sample-positions-default-*` row wasted its predicted pipeline that way, and `resolve-depth-filters-2` made one pipeline per depth resolve mode (SampleZero, Min, Max) on top. Render pass compatibility ignores the resolve references and the depth/stencil resolve modes of passes of one subpass (Vulkan 1.4, "Render Pass Compatibility": "if two render passes have a single subpass, the resolve attachment reference and depth/stencil resolve mode compatibility requirements are ignored"), and every instance's pass has one subpass, which `render_target.rs` and `render/late_resolve.rs` already rely on. So a pipeline key holds the pass without its resolves (`PassShape::keyed`); a draw compares its instance's shape to a key with `PassShape::keys_as`, and an execution's replayed draw keys its run's shape the same way. A pipeline made against a pass that resolves is the one a draw in a pass of the same shape that resolves nothing takes, and the other way round. Test: `tests::creation_prediction_reach::a_draw_in_a_pass_that_resolves_takes_the_creation_s_pipeline` (a four-sample draw in a pass that resolves its color takes the one pipeline its state's creation made). Verified: it fails at the base on the M3 (MoltenVK, potluck m3-max-3100: 0 of 1 taken) and on lavapipe (m3-max-3103), and passes with the change on both (m3-max-3105, m3-max-3077). The conformance census and records follow in a later commit. (cherry picked from commit 1ff02eca42f0e14e463ba8999acb6f2caafdc0b3) |
||
|
|
6647aa1e91 |
Hand a render encoder's core and log on in boxes through its end
A render encoder's end passed its 1280-byte core by value at every step: out of the lowering, into `color_groups::Ended`, out of the `Result`, through `later_groups` and into `end_with_replay`. Its log (328 bytes, `Option<RenderLog>`) went the same way, and was boxed only at the end for `Replay::Render`. The lowering now holds the core in a box made as the encoder opens, and the log in the box `SpareLogs::render` makes, which the end hands to `Replay::Render` as it is. An ended pass is 264 bytes instead of 1856, and the lowering 8688 instead of 10280. An execution's replaying encoder boxes the core it is handed and gives it back unboxed, so the execution paths keep their by-value core. Check: a compile-time bound on `color_groups::Ended`'s size (320 bytes; 1856 before). Verified: release builds of the validation lib (x86_64, --cfg m2v_gpu) at 335c0ef7f7 and with this change, every memcpy/memmove call in the open and end functions listed by objdump: the end_encoding's copies of 1280, 1160, 328 and 320 bytes, later_groups' two of 1280, assemble's of 1280 and open_render's two of 328 are gone; assemble's whole-lowering copy shrinks from 10280 to 8688 bytes. (cherry picked from commit 4c885033bb5ee41f768fedaca34d4ba29efbcff1) (cherry picked from commit cee784906833a3a7e6713e15971b39dc03404062) |
||
|
|
df5d660090 |
Hold a render encoder's quiet bound-value memos in place
What (render.rs): QuietKept holds the up to QUIET_KEPT memos in a fixed array, written round in turn, in place of a Vec. Why: a Vec allocates at an encoder's first quiet memo and again as it grows. The memo it replaced (an Option) allocated nothing. An encoder's other kept state is held so that a draw allocates no more than it did (runtime_lane::frame_costs). The memos now work the same way. Measured, the draw_costs lane on the M3 Max, release, instructions a draw, median of 9 runs: - default codegen units: ws 19657 -> 19692 (+35), many 16318 -> 16317, 10k 8419 -> 8410 - one codegen unit (CARGO_PROFILE_RELEASE_CODEGEN_UNITS=1): ws 18884 -> 18875 (-9), many 15671 -> 15667, 10k 8076 -> 8077 The series, from its base to here, takes the ws shape's draws from 19945 to 19692 instructions (-253), many from 16377 to 16317 (-60) and 10k from 8399 to 8410 (default codegen units), and at one codegen unit ws from 19140 to 18875 (-265), many from 15707 to 15667 and 10k from 8074 to 8077. The lane's --counts show the same work counts, field for field, at the series' base and with every change but this one. Only timings, and the scheduling and completion counts that follow them, differ. Verified: the lane numbers above. The touched suites run at the tip of this series. (cherry picked from commit 7f0b338328bdf56a02618ce29afe5b117e9108a8) (cherry picked from commit 96d40b62db096b3db89640eeab82028a0c6ae180) |