4b37878cdaa103cb8b0fe882474cd5961baafafe
73
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
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. |
||
|
|
b31c23f7c0 |
RUNTIME 2257: render targets placed apart in one Private placement heap keep no shadows
A game's render targets placed apart in one tracked Private placement heap (reims gameload G2
rtheap: MSAA colour, MSAA depth and a shadow map) were held as shadows on the Iris and the AMD
GPUs, with attached reads through copies, clears in part and sample moves every frame (+34.9 ms a
frame over native on the Iris guest at pin 77). Four causes, each with a test that fails before:
- C (d1eaec0f47, 792ea614de): a heap's images shared memory wherever their keys met, so a
texture placed apart was taken as attached to another's pass; images now share memory only where
their bytes meet, and the heap's own shadow images use their whole key's memory.
- B1 (6f54af68e2, e56bb982d7): a multisample heap texture takes the device's own size and
alignment answer and lies in its image (the 780M asks at most 64 KiB).
- D (f760b95001): a whole clear of a 2D multisample attachment copies nothing in.
- B2 (317d905449): a heap texture's device answer takes the device's alignment up to the heap's
own (the XTX's MSAA colour answers 256 KiB: 2375680 @ 256K, depth 1179656 @ 128K, shadow map
393224 @ 128K), the host GPU's real value as the owner's rule for device-describing answers
states.
New owned fixture hpr_reads (our MSL; regen-air-fixtures): fragment functions reading a device
buffer; its golden and the compile census are re-blessed at the next pin.
Verified (steelbrain/rtheap at 23fc75a899): release lane heap_placed_targets (320x192, 7
heap-placed targets, Device policy, mean of 10 frames), placed vs device-made: XTX 1.619 vs 0.576
ms before, shadows MsaaColor/MsaaDepth/Shadow, to 0.530 vs 0.594 ms, every shadow count 0
(m3-max-27670); 780M 2.150 vs 0.579 to 0.548 vs 0.599 ms (27671). Metal policy
(exact_answers): XTX 2.033 to 0.683 ms, 780M 2.650 to 1.079 ms, shadows kept as the switch says.
Texels and kernel reads equal the device-made frame on every leg. lavapipe green (27676); XTX
(27687) and 780M (27688) every heap_placed*, attached_levels, tracker, heap and shadow test
passes, the other failures only under the carried archive's compile-time paths and the
shadow_standing layer test fixed separately (
|
||
|
|
e3ee3d7f5e |
RUNTIME 2240: a draw that reads its own color through snapshots is kept: drawn again, rebound and carried
On the consumer's XTX Launchpad walk ~59% of render encoders end keeping nothing though they would fit the next encoder (WorkCounts::encoders_none_kept_next_fits, RUNTIME 2229), and ~75 draws a present read their own color attachment through a snapshot (render/snapshot.rs), a draw that kept nothing and so took every step each time. A direct draw that reads through snapshots (not in place), pins nothing, and otherwise meets every plain-draw condition (records into its instance as it stood, a pipeline made ahead, one push, one Vulkan draw, whole draw state, its only push hole SnapshotPhase, no write but its snapshots' uses) now keeps a Kept with a reader part (slots, feedback colors, the phase hole, the pipeline's own write masks, its layout). A draw again records exactly what the first did, the snapshot draw (masks 0, phase 1) then the drawing draw (own masks, phase 0), with their barriers and query, re-deriving only what changes with no call (the reader's ordinal, its learned coverage and the area/coverage decision, peeked first; if it would no longer take the snapshot the draw takes every step). A rebind re-derives the reader decision through side-effect-free cores of the functions every step runs (in_place_wanted, snapshot_wanted, area/coverage, snapshot_holds, snapshot_apart), binding::rebind_into rewrites a changed slot's SnapshotTexels source, and record_rebound records the two recordings with their pairs. A carried reader's snapshot conditions are checked at its rebind beside carried_stale (WorkCounts::draws_carry_stopped_snapshot), begin_carried passes its feedback to inline_begin, and a carried draw retains its pipeline objects into its encoder. Set-aside kept readers are exempt from a reader's forget of its colors' readers: their reads go through their own pair, whose first barrier orders every earlier color write. In-place readers, pinning readers and readers recording into a new instance stay unkept. New WorkCounts: reading_draws_snapshotted_again, draws_rebind_stopped_snapshot, draws_carry_stopped_snapshot. A lane bench (runtime_lane reader_costs) measures the CPU per draw of encoders ending in a reader. Expected reach (keepdraws' read of the consumer's lp72-xtx counters): readers never sit in an unsplit inline pass, so this reaches the ~22 fitting encoders a present that are not inline. Verified (keepdraws): clippy plain / --cfg m2v_gpu / --cfg m2v_cpu_icd and rustdoc 0 at adaccf2367; lavapipe 43/43 (no snapshot path there: pixels only); XTX and 780M debug at e4961c98ee 91/92, the one miss (a carried draw's later draw again) fixed by 8e219f8bad. XTX/780M reruns at the tip, negative control and the release bench are queued and follow on development. RUNTIME_VERSION 2239 -> 2240. |
||
|
|
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
|
||
|
|
30ba489080 |
A recovery carries sampler states
What: a sampler state's device is a LineDevice the state's own carry links (LineDevice::unkept, link_unkept). The recovery takes the generation's live sampler states (Carry::sampler_state, Taken::samplers) and, first after the handles, carries each (SamplerState::carry) where both generations compile alike: its handle linked to the new generation's under its cache's lock, the VkSamplers it kept forgotten, the state kept in the new generation's map of live states (an equal request gets it) and placed in its heap sets and sampler tables, then kept there for a later recovery. Its placement on the lost generation is taken out at that generation's rest (LostPlacement). SamplerState::vk_sampler takes the generation the bind writes for and makes the sampler there, cached for the state's latest generation alone; for any other generation it answers None, and the heap set, slot and argument-buffer writes take the neutral sampler. The recovery's notice counts the states carried (and any left, where the generations compile otherwise). Docs: MadeBeforeRecovery, the device-recovered cost (degradation.rs and API.md), the runtime README, device/carry.rs and sampler.rs. As main asked, Device::recover_for_test's doc and line.rs's module doc now point at device/carry.rs for the kinds carried instead of a stale list. Why: a sampler state kept its lost generation, so every bind of it after a recovery was refused (MadeBeforeRecovery) where Metal's goes on; and the argument buffers' listing of live states is line-wide, so a draw or dispatch of the new VkDevice made the listed state's VkSampler on the lost VkDevice and wrote it into a descriptor set of the new one, a handle of another device, which Vulkan does not allow. Verified: the lane that follows runs the test before and after on lavapipe; REFUSALS.md regenerated (no change). |
||
|
|
2b66def21d |
A bind finds its kept sampler description by the state it binds, and hands the state's cache a hashed one
A render encoder's binds keep the sampler descriptions they worked out (`BindMemo`). Each bind of a sampler slot built the slot's descriptor (the state's, with the bind's LOD clamps and the textures' address-mode map), then walked the kept descriptions comparing every field of that descriptor, then asked the state for its `VkSampler`, whose cache hashed the whole Vulkan description (every field, through `SamplerDesc`'s key) at every bind. On lavapipe, in a scene of material changes, 57% of `image_descriptor`'s instructions were this path: the walk's 29%, and `vk_sampler`'s 27% of which the description's hash was 12% (perf, job m3-max-22200). - The memo keeps a description by what it is a function of: the state, by its address and held weakly as a kept view's texture is (its allocation, and so its address, stays its while the memo holds it), the clamps by their bits, the map and the facts. A state's descriptor and LOD bias are fixed as it is made, so this is the same answer the descriptor's comparison gave, by a pointer and a few words. In debug builds every memo hit works the description out again and asserts it is the one kept. - The state's cache is keyed by a description hashed once (`sampler::HashedDesc`): the memo keeps it hashed, so a bind that finds its description there hashes nothing. The other binds (an argument buffer's samplers, a heap set's sampler array) hash it as they ask, as before. The state still answers every bind, so what it keeps and forgets is unchanged. |
||
|
|
aa2256b6e7 |
Order host-alias uses across queues again: Metal orders textures over one IOSurface across queues
Reverts a5634d48db and 3926d2d8c9, which left the uses the host aliases add out of the scheduler's order across queues on the strength of host_aliases.rs's line that Metal orders two textures over one IOSurface across queues only as the program orders them. The conformance probe probes/cross_queue_surface_order.m measured that case (queue A's long compute write committed before queue B's blit read of the same bytes, no event between them, three runs each): - two tracked textures over one IOSurface: B ran after A and read its writes in every run on an M3 Max (macOS 27.0.1, m3-max-21812, m3-max-21830), a Radeon Pro 5300M and a UHD 630 (macOS 26.7.1, m3-max-21850, m3-max-21851); untracked, the same but one run on the 5300M; - a texture of another surface (control): ran alongside A on the M3 and the 5300M; - two no-copy buffers over one allocation: B ran alongside A, reading stale or mixed words, on all three (8 of 9 runs; the 630 ran it one after the other twice); - one tracked buffer (control): ordered on the M3; the 5300M and the 630 each took B first once. So the alias keys' order across queues is the surfaces' order, which Metal keeps; dropping it was wrong for the consumer's surfaces, whose textures lie over per-texture no-copy buffers. host_aliases.rs now states those measurements, the plain no-copy buffers' among them, in place of the M4 line. The freeze the revert reopens (a held batch's making holding other queues' heads over a shared surface) is answered by the next commit, which lets a batch held for its making give way across queues, as the x86 Macs' GPUs may take a later commit first. Until that commit, tests::hold_sites::a_head_over_the_same_host_bytes_through_another_buffer_goes_while_a_batch_is_held fails as before a5634d48db (m3-max-21752). |
||
|
|
1b802ea45a |
Cross-queue commit order counts a conflict only on a resource both batches name
What: a use the device's host aliases add (host_aliases.rs: a no-copy buffer over the bytes of another, the consumer's textures of one IOSurface over their plane buffers) is now marked (`Use::aliased`). The scheduler's order across queues (`Footprint::conflicts`, behind `Order::is_behind`) leaves marked uses out, so a batch the runtime holds for a reason of its own (its pipelines' making, a host step, its checks) holds back no later commit of another queue that meets it only over shared host bytes. A use joined with one its command named stays named (join and merge keep `aliased` only where both are; `covers` lets no aliased use hold a named one), so two batches that name one resource still run in commit order, as Metal's tracking orders them. The tracker's barriers, inside a queue and on the GPU once both are submitted, take aliased uses as before. Why: on an Intel Iris Xe, one guest process's compute pipeline took about 3 s to make cold. Its command buffer kept its place in commit order (held for its making), and five other queues' heads in each scheduling pass, the window server's frame among them, conflicted with its footprint only through the alias keys over IOSurface pages they shared (heads_held_for_earlier_commits +5 per pass, footprints_built +2, the scheduler otherwise idle). The frame's present waits for its writers' completion, the guest's display pipe allows two unanswered presents, and the guest froze for 3.1 s. Metal orders two textures over one IOSurface across queues only as the program orders them (host_aliases.rs's measurement: an M4, macOS 27.0.1, plain and under API validation), so a later commit of another queue through another resource over those pages does not wait for an earlier one there; holding it was ours alone. docs/HOWTO.md's paragraph on copied and same-surface buffers says the same; the order.rs, scheduler gate and host_aliases.rs docs name the exception. Tests: tests::hold_sites::a_head_over_the_same_host_bytes_through_another_buffer_goes_while_a_batch_is_held (the previous commit) failed before this change on lavapipe (m3-max-21752: TimedOut, the fill waited behind the held dispatch) and is expected to pass after; tests::tracker gains a_use_the_host_aliases_added_orders_no_batch_across_queues (aliased-only overlaps unordered both ways, a named key on both sides ordered, a named use joined with an added one of the same range named); tests::host_aliases expects the added uses marked. |
||
|
|
3041c881d3 |
A draw that binds a zero region of its own is not kept at all
The previous commit kept such a draw from being rebound, but it was still kept for drawing again as it was: the next identical draw re-recorded its Vulkan draw over the kept draw's set-0 writes, the kept draw's zero region among them, where every step pushes a new one. In debug builds the lane test then panicked with 'a draw again recorded a state command' (draw_again.rs:946), at a strip drawn twice in a row with its vertex buffer unbound. A draw whose plan binds a zero region of its own (binding::binds_own_zeros) is now not kept (plain_but_heap), counted as one that may write (WorkCounts::draws_unkept_writing): it neither draws again as it was nor rebinds. The rebinds condition the previous commit added is dropped as redundant. |
||
|
|
8b551b05f0 |
A draw that binds a zero region of its own is not rebound
A function that reads a writable buffer binding with nothing bound to it reads a fresh zero-filled region of the command buffer's upload arena at every draw (binding::write_info's neutral zero buffer for a non-uniform binding). A draw rebound keeps the kept draw's set-0 writes at every slot but the changed ones, so it bound the kept draw's region, which that draw may have written, where every step binds a new one. In debug builds the check of a rebound draw panicked with 'a draw rebound worked out other set-0 writes than its every step' (draw_again.rs:804). A consumer's tests hit it: draws after the private setters with no vertex buffer bound, whose vertex function reads its buffer 0 unbound, rebound across direct and indexed calls since RV 2112. binding::binds_own_zeros tells such a plan, and a draw of it keeps no rebinds (Kept::rebinds false): it takes every step, as before RV 2112's reargued rebounds. Verified: runtime_lane::provoking::draws_after_the_private_setters_rebind_what_every_step_binds, with the vertex buffer left unbound, panics at draw_again.rs:804 on lavapipe before this change (job m3-max-21076). |
||
|
|
d225ee6e2c |
WIP: attached reads turn a texture's two faces instead of copying (unbuilt)
A texture an attached read samples takes two faces, its own image and a second of the same plan (the shadow the copy took); a pass that renders it whole without loading it renders the face it did not present while its draws read the one it did. Counted: texture_faces_made, attached_read_swaps, attached_read_swap_reads/texels, attached_read_swap_fixes/texels, and the copies no turn took off by cause (attached_read_unswapped_*). Not built yet: this commit is for the first compile job; fixes follow. |
||
|
|
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. |
||
|
|
0709ba7ba5 |
A sampler state's lodBias moves the level on a device presenting an Intel or AMD Mac
What: vk_sampler set mipLodBias 0 whatever the descriptor's lodBias, read as Apple9 (an Apple M3 Max samples every level as with no bias). The consumer's oracle (an AMD Radeon Pro 5300M and an Intel UHD 630) shows a Mac with an Intel or AMD GPU adds the bias to every sample's level, explicit (level()), gradient and implicit alike, clamped into the texture's levels. So a guest presenting such a Mac read the wrong level. How: the translator's SamplerUse gains lod_bias (with_lod_bias), a fact the consumer states per bind from the Mac it presents; a plan's uses leave it unset. With it, vk_sampler's mipLodBias is device_lod_bias's (new, public): the bias within the device's maxSamplerLodBias, the limit of its sign past it (Capped), none for a NaN (NotANumber) and none where the portability subset withholds samplerMipLodBias (Withheld). Without it, 0 as before; a use of texel coordinates takes none either way. Vulkan adds mipLodBias to an explicit level too, so the device's sampler gives the measured answer within the limit. The runtime keeps the resolved MacClass in DeviceProperties (one place, presented_class; lossless_compression derives from it). A state's taken descriptor keeps its bias on IntelOrAmd (-0 as 0, NaN as none) and 0 on AppleSilicon, and SamplerState::bound_use adds the flag at every bind: a slot's, an argument sampler's, a heap set's array element, and the attached-levels reckoning of the levels a draw samples. A bias the device cannot take as it is is announced once as the state is made, the new precision kind CappedLodBias (capped-lod-bias), never fatal. Docs: vk_sampler, SamplerDescriptor::lod_bias, the runtime sampler module, MacClass and DeviceOptions::mac_class name the answer per class; API.md's catalogue lists capped-lod-bias and the Mac-class section the bias. The api_surface and api_signatures tables take DeviceLodBias, device_lod_bias, SamplerUse::lod_bias/with_lod_bias and the new kind. REFUSALS.md regenerated unchanged. Tests: metal::sampler's a_lod_bias_is_the_device_s_where_the_use_adds_it (every committed profile, both uses) and the_device_lod_bias_is_the_bias_within_what_the_device_takes (exact, capped finite and infinite, NaN, withheld on MoltenVK's profile); tests::sampler takes the bias per class; the lane's lod_bias tests a device presenting each class: AppleSilicon reads the unbiased level (kernel explicit, fragment implicit), IntelOrAmd the biased one, the capped ones announced once (CAPPED_LOD_BIAS, listed as a site). Evidence: potluck jobs in the report to main. |
||
|
|
e26d12b544 |
A shadow's move in place counts in the views epoch, so no bind names its views after they went
A texture over host pages made before its pages' in-place verdicts is a shadow; once they pass, a commit moves it in place (TextureShared::moved) and the shadow's VkImage, views and memory go when that command buffer completes (ShadowAfterMove). Render encoders' bind memo (binding::BindMemo) keeps each texture slot's VkImageView by the texture's address, current while the device's views epoch holds; the move changed the image the texture presents without moving the epoch. A later encoder's draw then took the shadow's view from the memo and pushed it after it was destroyed: on the RTX 3090 (NVIDIA 620.70.06) a consumer's per-draw run with surfaces over host pages died with SIGSEGV in vkCmdPushDescriptorSet (push_set <- Recording::record <- draw_resident; the pushed combined image sampler's view object was freed memory). Before the shadow went, the same draw read the shadow instead of the image in place. The move now counts as the shadow letting its views go, under the shadow's views lock, before the flag that lets ShadowAfterMove free it: every kept view is dropped at the next bind, which works out the view of the image in place. The pooled-memory moves take the same path. Docs of the epoch, the memo, the counter and the storage-form module say so. Verified: cargo fmt; the device runs are in the report. |
||
|
|
aba4034dca |
Runtime: a program's exit handler reaches no destroyed thread-local
exit destroys the exiting thread's thread-locals before it runs the exit handlers (macOS, the GNU C library), and LocalKey::with on a destroyed one panics, which in a handler aborts the process. The exits lane case an_exit_handler_s_common_calls_answer_as_on_any_thread aborted there on both: "cannot access a Thread Local Storage value during or after destruction" in calls_at_exit on the M3, and on lavapipe at warm::pass::warming from PipelineMemo::compute, in the handler's new_compute_pipeline_state. Every runtime thread-local whose type needs dropping that a program's call reaches is now read with try_with, with what the thread does once it can keep nothing: - the making budget's turn (pipeline/budget.rs): program_turn takes none there, holds_turn is false, and a turn's give-back and lend read the note with try_with; - the driver facts' expectation (driver_facts.rs): expecting runs the call alone, its messages relayed; - the creation log's split (pipeline/creation_log.rs): none noted; - the warm pass (warm/pass.rs): none; - a relayed compile's held sink messages (device/compiles.rs): the call alone, its messages delivered as raised; - a lowering's refusal (render/deferral.rs): lowering::refusing is false there, so a notice of a kind the device refuses while lowering is announced, as anywhere else; - the debug-build checks of kept resident uses (binding.rs) and of slot rebinds (the translator's bind/graphics.rs): skipped. dirty_pages, shards, resource_ids and contexts already read theirs with try_with; the rest hold Copy values with no destructor. docs/API.md's accepted differences under "Process exit" say what an exit handler's calls keep no state for. |
||
|
|
81abe49dad |
Attached reads of the levels before the attached one read the texture's own image
A draw's sampled slot of a texture its render pass instance renders at level k (counted from the texture's own first level) took the texture's usage shadow, a whole copy of every level, even where its reads reach only levels before k. Such a slot now binds the texture's own image through a view of its levels 0..k, the same first level, so an explicit level of detail selects the same level, and names those levels in its uses (`binding::NarrowedSlots`): no copy is taken for it. The copy would hold the same texels: nothing the instance does writes those levels where the texture is an image of its own the bind reads in place (not sparse, no decoded twin, the sampled usage), no attachment of the instance is at them, no earlier draw wrote them since the instance's last barrier (a draw after one records into a new instance), and no write of the draw's own meets them (else every narrowed slot of the draw takes its copy, its uses made again). Which levels a read reaches is the translator's fact (`StageModule::level_reads`) through the samplers the draw binds: level-count and level-of-detail queries, computed fetch levels and samples without a sampler-bounded level keep the copy. A draw rebound works its narrowed slots out again and is rebound only where they are its kept draw's; a draw again binds as its kept draw did. WorkCounts: attached_read_slots_below becomes attached_read_slots_apart (the own image cannot serve them), attached_read_slots_written (something writes those levels) and attached_read_slots_narrowed. Verified: cargo fmt only; the build, clippy, a device test of an explicit read of level k - 1 while level k is attached and the touched suites follow as potluck jobs. (cherry picked from commit 7ba814a2e2f419643c2f9e68b9768709658cbe94) |
||
|
|
57c21dc6bb |
Draws unlike their kept draw only in their own arguments are rebound with them
In reims' pin-26 glass walk, 69,981 of 70,882 draws unlike their kept draw differed only in their arguments (draws_unlike_kept_arguments_alone, all of them in the index offset), and each took every step. Such a draw, of something to draw, now goes to the rebound path (render/draw_again/rebound.rs), whatever its tables' stamps, and works out again each step that reads its arguments: - its route, which reads them only through whether the draw may make a primitive (line_width::draws_primitives): the draw goes on only where that is the kept draw's; - its commands' Vulkan draw, index overrun, BaseVertexInstance push fields and index buffer use, through a new BindingPlan::redraw_apart_into, which answers Ok(false) where the plan reads the arguments some other way (a stage's argument or root table, a mesh, patch or de-indexed draw) or a fixed-function vertex buffer's fetch window moves with them; - its pulled attributes' reach (check_vertex_reach, as before, now of the new draw); - its index buffer's use, patched in place as a moved slot's use is (binding::patch_command_uses), so a moved, narrowed draw checks, notes and gathers it with the moved slots' uses; - its index buffer's bind (IndexBind::of of the new source), recorded where the record holds another, with its new draw; the kept draw takes its arguments, index source and draw. A stop at one of those steps is counted (WorkCounts::draws_rebind_stopped_arguments) and the draw takes every step; a rebound one is counted in draws_rebound_arguments. A draw of other arguments that draws nothing still takes every step and is counted unlike, as before. The draw-again debug check covers the new form: the kept draw it compares is the kept draw with the new arguments, and the rebound check now compares the recording's Vulkan draw and index buffer bind as well as its draw state. New public items: BindingPlan::redraw_apart_into (docs/API.md), WorkCounts::draws_rebound_arguments and draws_rebind_stopped_arguments (api_signatures blessed). Tests: the translator's draws_of_other_arguments_redraw_what_every_step_writes holds redraw_apart_into to every step's commands (first index, count, base vertex, a robust overrun) and to Ok(false) where a window moves, for another kind, index type or buffer, and a de-indexed plan, and to every step's error past a multiview limit; the runtime's draws_of_another_first_index_alone_are_rebound_with_their_pixels draws each rectangle by its first index alone, then by its base vertex alone, rebound, with the commands, state commands and pixels of the same draws taking every step; the unlike-count test now holds one draw rebound with other counts, one stopped at its route and one of nothing. (cherry picked from commit ab3e5002bbd6bf8dde7c2761bf7d12ab4461b555) |
||
|
|
fd7fecced1 |
A draw moved along its buffer notes, reads and gathers nothing again
A rebound draw moved after calls that moved a buffer slot's offset alone already patches its moved slots' uses in place and notes, adds to the pass's reads and gathers those alone. Where the offset moves along the buffer, as a guest's upload chunk is read draw after draw, each patched use lies inside the bytes of the use it replaced (the last draw's at its place), which the encoder's part, the pass's reads and the instance's gathered uses hold already, or hold one covering it. Comparing and noting it again changed nothing, but cost every such draw that walk. Now binding::patch_buffer_uses answers, where it patched, whether each patched use equals or lies inside (Use::covers) the one it replaced. A draw narrowed whose patched uses all do is inside: EncoderCore::note_moved checks the noted state as before (NotedApart::moves), observes fresh reads and holds what was made resident as before, then compares and records none of the moved uses and keeps the covering ones (counted as the new WorkCounts::draws_moved_inside, and not in uses_noted_covered); record_rebound adds nothing to the pass's reads and gathers nothing. The attachments' and geometry writes' checks of the moved uses are unchanged. Builds with debug assertions check, for each draw inside, that the noted kept uses cover the moved ones (NotedApart::covers_at), and that adding them to the pass's reads or the instance's gathered uses changes neither. New test draws_moved_along_their_buffer_note_nothing_again: draws moved along the vertex buffer are each inside, with the same commands, state commands and pixels as every step, and every step's covered count equal to the rebound run's plus the draws inside. command_counts lists draws_moved_inside. api_signatures re-blessed. Verified: pending (A/B on the M3 and lavapipe, suites, cost --check). (cherry picked from commit 2e524e00b4a50f175a5df59ef1ac1b667e30b091) |
||
|
|
5b11e66c4c |
List a narrowed draw's moved uses as the patch patches them
A narrowed draw walked its list of slot uses twice: patch_buffer_uses patched the uses of the changed slots, then CommandUses::slot_uses_into walked the list again to copy the same positions and uses out. patch_buffer_uses now writes the positions and patched uses into the kept storage as it patches them (emptied first, in the list's order), and slot_uses_into, which nothing else called, is gone. A draw that is not narrowed leaves the lists unread, as before. (cherry picked from commit a3f862c4c7fe50779115a7e2f3d404a313f4a6ba) |
||
|
|
86c2f737e8 |
Make a rebound draw's binding tables only for a step that reads them
rebind built the full binding::Tables for every rebound draw: a builder chain of six by-value copies of a struct of about thirty fields, three of them setting what Tables::new already sets. A moved draw that keeps its set-0 writes and patches its uses reads none of it but the stage tables. patch_buffer_uses now takes the stage tables (stage_buffer, which slot_buffer uses too). The full tables are made once, and only where rebind_into (set-0 writes not the kept draw's) or command_uses_into (uses not patched) reads them. The steps run in the same order and stop where they stopped. (cherry picked from commit bd3768f17c4473384ae1620c49ccc26fe24cd584) |
||
|
|
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 |
||
|
|
80add4510e |
Draw a rebound draw that moved buffer offsets alone without its whole rebind
A render draw rebound after calls that moved only buffer slots' offsets (or attribute strides), each slot keeping the buffer it bound (argument_table::Changed::offset), is now a draw moved (WorkCounts::draws_moved, new). Its tables bind the kept draw's objects, so it skips what those objects decide, each skip asserted in builds with debug assertions: - no stage's visible-function tables checked again, no shadowed-texture or detached-buffer look (both functions of the objects bound); - set-0 writes and dynamic offsets kept, and the push writes not built again, where its commands' descriptor ranges are the kept draw's (rebind_into writes a buffer's descriptor of its buffer and range alone); the every-second-draw check compares them with every step; - narrowed, where its uses were patched in place and none is of what the encoder made resident: the uses differ from the kept draw's only at the moved slots' (CommandUses::slot_uses_into), so only those are checked against the attachments (degrade_moved_attachment_reads) and the geometry writes, compared and recorded for the encoder's noted uses (EncoderCore::note_moved, NotedApart::note_moved, no touch walk), added to the pass's reads and gathered (InstanceShadows::add_moved). Every rebound draw without a resident prefix also skips the unordered writes, indirect reads and geometry writes adds and the pass's reads' announce: its uses are the kept draw's access types, none written and none an indirect read (draw_again::unwritten), in a pass whose fragments wrote nothing, which makes each of those a no-op. Folded in from the brief: bring_in reads with its sampler maps instead of cloning them per draw (ReadFrom::reads_through, read_again), and PassStartReads::announce and found walk no use while no fragment stage of the pass wrote (and read) anything. Verified: see the tip message (release A/B on lavapipe, the 5080 and the M3; runtime suites; conformance cost --check). New test draws_after_offsets_alone_moved_bind_what_every_step_binds compares moved draws with every-step draws (commands, pixels, state records, noted counts); draws_moved joins command_counts' per-encoder counts. (cherry picked from commit 1a2e3258d40604607bc681e8a58202ed632f1594) |
||
|
|
442dcd08c9 |
Copied host memory: a copy that drops the GPU's writes takes its guest RAM's log, and a draw that only reads through loaded addresses leaves unnamed copies uncompared
A copy of memory of Metal's private option bit 24 (on a system that maps no read-only view of the pages) skipped the routing of its guest RAM runs, so it kept no log: every commit compared every byte of it, and every completion of a command buffer with a root table compared every copy. In consumer boots that is about 29.5 MiB per commit and per completion over 37-44 objects. - Commit (copy in): a no-copy buffer, heap or rebind whose GPU writes are dropped has its runs asked as a writable one's are (routes_runs), so its copy takes the RAM's log and copies in only the pages the log reports written. It is still never bound in the RAM's chunk: the in-chunk binding is filtered on drops_writes. macOS keeps its read-only view and asks no runs. - Completion (merge back): State::writes_unnamed narrows reaches_unnamed to commands whose functions may write memory. A draw's root table writes only where the vertex or fragment function may store or update memory (GraphicsState::vertex_writes_memory, fragment_writes_memory) or the pipeline has another stage; kernels, tile functions, replay tables and records resolved by host steps stay as they were (every copy compared). The compare itself stays: in a dropping copy it is what restores the dropped bytes, so later command buffers read the pages' bytes. Tests: host_ram_copy_device a_private_bit_copy_over_the_pages_copies_in_only_the_pages_the_log_reports (one page written: length - page bytes not compared, the GPU's fill dropped) and copied_device a_merge_back_skips_a_copy_when_a_draw_only_reads_through_loaded_addresses (root table noted, merge back compared 0). Docs: copied.rs, FAST-PATHS known gap, HOWTO section on copies. (cherry picked from commit 61a9a4f4603a4c080ba5a4f2e204668ae621cf41) |
||
|
|
6337d4bf47 |
Read where a bound buffer over host pages lies through the encoder's bind memo
Every draw rebound wrote its changed buffer slots' descriptors again (binding::rebind_into), each reading where its buffer lies (Buffer::space): for a buffer over host pages, the pages' lock and a clone and drop of the pages' Arc (and on Linux the held import's), and for one placed in a no-copy heap, the heap's own buffer's, which every encoder of the device reads. The consumer binds each draws.10k draw's bytes in a heap over the guest's RAM, so every draw of every encoding thread locked and wrote that one cell: HostCell::lying was 2.9% of the graphics threads' samples on the RTX 5080 host, Buffer::at_for 1.0%. The bind memo an encoder takes (binding::BindMemo) keeps where up to four buffers over host pages lay (buffer::KeptSpaces), by their cell's address held weakly, read under the process's count of no-copy buffers' moves: a buffer lies where it lay until one moves (HostCell::replace counts each move under the cell's lock), and its import, once read for a binding, stays imported. A slot descriptor of such a buffer, or of one placed in such a heap, is read from there with no lock and no write another thread reads. Verified: in builds with debug assertions every kept answer is compared with the cell's own; the runtime suites; no_copy_lies_read and cycles a draw in the perdraw report. (cherry picked from commit c98cda26a4c6669c77201a04c1bc3b63df845cb3) |
||
|
|
315deb56ff |
Count a listing's walked uses by its sources, so release builds use every binding
list_slot_uses destructured CommandUses::uses only for its debug-assertion counter (LISTED_SLOT_USES), so every release build warned "unused variable: `uses`", an error under CI's RUSTFLAGS=-Dwarnings. The loop walks `sources` from `used`, and there are as many sources as uses (the invariant patch_buffer_uses checks), so the counter now adds `sources.len() - used`, the entries the loop walked, and the destructure leaves `uses` out. The count is the same; draw_again's listing test reads it. Verified: cargo build --release with RUSTFLAGS=-Dwarnings (see the batch report for venue and counts). (cherry picked from commit 1fa0e0528dce4f33f091cf6e808cb1931f3d40e2) |
||
|
|
534a6ab322 |
List a draw's uses of buffer slots at its first patch, not as its uses are made
What (binding.rs): CommandUses::slots, the uses of buffer slots and their positions that patch_buffer_uses patches by, is listed by the first patch after command_uses_into made the uses (list_slot_uses), and read by the patches after it until the uses are made again (CommandUses::slots_listed). Before, it was listed in the loop that makes the uses, for every draw that keeps them. Why: |
||
|
|
a265698635 |
Compare another plan's uses only where uses of what the encoder made resident are kept
What (binding.rs): ResidentOf::holds compares a draw's plan with the plan its kept uses were
made for (BindingPlan::uses) only where those uses include some of what the encoder made
resident. Where they include none, a draw of another plan makes them again.
Why:
|
||
|
|
296723b362 |
Test a filter notice's bound format against the format the slot's binding presents
The consumer's own-format view test died on the M3 Max (MoltenVK) in strict mode at a sample of an 8-bit 4:2:0 texture's 2D array view in its own format: `ycbcr-filter-not-exact`, "texture 0 bound as YCBCR84202P". That view is the luma view (`Texture::luma_view`): an `R8G8B8A8_UNORM` image of the codes, read as the code-reading format `RGB8_420_2P` through a swizzle, which Metal's own sampler filters as Metal filters that format (the lane already holds the view's linear sample to that format's, and Metal's view to it bit for bit). The binding plan reads the bound record's format (`ViewRecord::bound`, `RGB8_420_2P`), but the notice's bound-format test read `Texture::pixel_format`, the view's own (`YCBCR8_420_2P`), whose class carries the 1/2048 field `FloatSampleFilter`'s clause tests. So the note was wrong: no float texels are filtered there. The 10-bit views (`RGB10_420_2P` codes, `A2B10G10R10_UNORM_PACK32`) and the `_sRGB` twins' views announced it alike. `Tables::bound_format` now reads the format the texture's bindings present (`Texture::bound_pixel_format`, `ViewRecord::bound`), the one its slot's code was specialized for. That changes what the bound-format notices test and name for every texture that reads its image in another format: the luma views; views in other channels of their image's bits, whose class is their image's; and converted textures over a P3 surface, whose image is the code-reading format's codes. A P3 texture's linear sample is no longer announced: Metal's filter of it is not measured, now a FAST-PATHS known gap. Notices only: no pipeline, binding or answer changes. Docs: ycbcr.rs (views; linear filtering, with the in-place form's 4:2:0-only reach), the YCbCrFilterNotExact declaration and its API.md entry, and the FAST-PATHS known gap. Verified: cargo fmt. The lane check of the previous commit fails without this on the M3 Max; device runs follow. (cherry picked from commit 37a50861dd4e105619690a520a290c30bd3208d5) |
||
|
|
630deb9385 |
Count each command into a tally its encoder owns while it is open
What: the 58 counts a draw, dispatch, tile dispatch or bind adds as its encoder records it (the 23 that were sharded by thread, draws_rebound, stage_tables_read, stage_tables_read_in_part, draw_states_recorded, set_zero_writes_pushed and resident_uses_* among them, and 35 that were one shared AtomicU64 each, set_zero_sets_reused/found, no_copy_lies_read, draw_shapes_*, graphics_pipelines_looked_up, draws_settled and the rest) move into one struct, CommandCounters, kept in shards (shards.rs): - by encoder: each EncoderCore takes one of 64 tallies as it opens (Tally::take; a process-wide bitmask, lowest free bit) and gives it back as it drops. Where the count is made with the core at hand (EncoderCore::counts, Counters::of), it adds into that tally by a plain load and store: no thread-local lookup and no atomic read-modify-write. An encoder is recorded by one thread at a time (EncoderCore is not Sync; under the Worker policy its lowering sits behind a mutex, render/deferral.rs), so the tally has one writer. Encoders past the 64 open at once share one more by an atomic add. - by thread: counts made with no core at hand (a no-copy buffer's lie read, a pipeline lookup, a bound offset moved, the ycbcr binds, ...) go into the calling thread's shard (Counters::thread), as the draws' sharded counts did. The lowering thread takes its own shard as it starts. The fold point is the read: Device::work_counts() sums every tally and every thread shard, open encoders' included, so a count is whole whenever it is read. Lanes and tests read the counts while encoders are open (dispatch_work, dynamic_multi_variable, neutral_zeros_shared, uniform_bind_offsets among others), so a fold at an encoder's end would leave those reads short. A tally given back keeps its counts; its next owner adds on top (release on give-back, acquire on take). Why: the consumer's profile of game_draws-like frames (about 12k draws a frame on several walk threads) spent 0.094 samples a frame in the work counts, 0.077 of them in draws_rebound: each count took two calls on macOS for the thread-local shard, and the shared ones were atomic adds every walk thread contended for. Nobody read the counts in that run. No public item changes: WorkCounts keeps its fields. Verified, release builds of the runtime_lane game_draws lane (two object passes of 6,001 draws each, 12,002 a frame; a measurement branch carries the lane), ns of the encoding thread's CPU a draw, median of 5 rounds, before ( |
||
|
|
8e65408e85 |
Resolve the runtime's broken private intra-doc links, and lower its ceiling to 0
CI's private intra-doc link step reported 148 for metal2vulkan-runtime on
macOS and 149 on Linux at
|
||
|
|
f7e7dc2f5f |
Move only the changed keys of a draw's resident reach, not the whole set
A draw reaches through the resident set alone the buffers its encoder made resident that no other use of it names (CommandUses::resident). That set was rebuilt from all of them (reaching) at every draw whose other uses named different resident keys than the last draw's: one BTreeSet clone of every resident key and one drop, per draw. A render pass that makes N buffers resident and binds a different one of them at each draw (an ICB of per-draw buffers, all made resident) paid O(N) per draw and O(N^2) per pass. In runtime_lane::host_step_frames (5001 kernel-written ICB draws, each its own vertex buffer, all made resident), a macOS sample of the steps thread put 80% of the host step in uses_into, cloning and dropping that set. Now settle_resident makes the set whole only where the resident uses were made again (reaching is new). Otherwise reaching is the last draw's, so the keys the last draw's other uses named, and those a use added since took (CommandUses::push, which now lists them), go back in, and this draw's named keys come out: the keys that changed, not the set. Builds with debug assertions still check each kept set against one made whole (command_uses_into). WorkCounts::resident_keys_settled counts the keys each draw's working out moved. The resident-uses device test asserts it is 2 at every draw that keeps its resident uses (it binds one table, the last bound the other) and more than the positions where they are made again. (cherry picked from commit c16048145c2b6945540d066a4718e5f7d371e375) |
||
|
|
399a94382b |
Make a kept draw's resident uses whole for their check in kept storage
runtime_lane::frame_costs' draw allocations, built with debug assertions, were 20.33 a draw on the M3 after the two commits before this one. The bound, DRAW_ALLOCATIONS_DEBUG, is 20. Where the last 0.5 came from: in builds with debug assertions, command_uses_into checks the resident uses a draw kept against uses made whole (command_uses). That made a new CommandUses at each check, 3 allocations: the uses, their sources, and the positions of the plan's other uses. 5ab66c0e6b keeps the uses at a switch to a plan that lists the same uses, so more draws keep them, and each such draw runs the check. A backtrace of every allocation of the counted frame's draws (a diagnostic, not committed) put these 3 at 201 of the frame's 402 draws, 3 draws in each pass of 6. The +0.5 is one more such draw in each pass. Now the check makes the uses whole over the last check's storage, a CommandUses this thread keeps (WHOLE_USES). They are made through uses_into for no kept plan, as command_uses makes them. A remake empties every compared field first or sets it whole: resident_uses_into empties the uses, sources, others and reaching, and settle_resident sets resident from reaching. So the compared fields (uses, sources, used, resident) are those a new CommandUses gets. The kept storage holds resource keys alone (ResourceKey is a u64), nothing alive. Measured, frame_costs on the M3: - debug, --cfg m2v_gpu: 18.71 allocations a draw, from 20.33 (19.83 at fdb282e3ae, before the heap part). The check's 3 allocations are gone at every checked draw: 1.5 a draw at those 201 draws, and 0.12 more, the same 3 sites at 16 other draws of the frame; - release, without m2v_system_alloc: 6.88 a draw, against DRAW_ALLOCATIONS, 9 (7.38 with the first of these three commits alone). The negative control is the two commits before this one: 20.33, over the bound. Verified on the M3 (potluck), on this tree: - clippy --cfg m2v_gpu of the runtime and the validation crate, all targets; - the runtime suite, debug, --cfg m2v_gpu, hazard filter: 1627 of 1628, the one failure exit_guard's known base failure; - the lanes, hazard filter: 247 of 247, frame_costs included. (cherry picked from commit 50c59a440c1b85c1b2d05218c126ff8824b14e91) |
||
|
|
fa99ed2c19 |
Keep the plans a draw's resident uses were compared with in place
A draw that switched to a plan whose uses differ pushed the plan into its ResidentOf's compared list (5ab66c0e6b), allocating the list. It then made its uses again under a new ResidentOf, dropping the list. In runtime_lane::frame_costs' window-shaped frame, whose draws switch pipeline state from draw to draw, that was an allocation at nearly every draw. ResidentOf::compared is now an array of COMPARED_PLANS slots. Measured, frame_costs on the M3, debug, --cfg m2v_gpu: 20.33 allocations a draw, from 20.83. Verified on the M3 (potluck), on this tree: - clippy --cfg m2v_gpu of the runtime and the validation crate, all targets; - the runtime suite, debug, --cfg m2v_gpu, hazard filter: 1627 of 1628, the one failure exit_guard's known base failure; - the lanes: 246 of 247, the one failure frame_costs' debug bound at 20.33. (cherry picked from commit 1c237630db1b4273faa14068c653e926952f62fe) |
||
|
|
2282779a74 |
Work a heap part out into a let-go part's storage, and keep its listing's
12f8301c62 and 5ab66c0e6b raised runtime_lane::frame_costs' draw allocations, built with debug assertions, from 19.83 a draw on the M3 (at fdb282e3ae) to 21.50. The bound, DRAW_ALLOCATIONS_DEBUG, is 20. The window-shaped frame's draws switch pipeline state from draw to draw, so an encoder works out a heap part for each of its plans. Two of the allocations were these: - Each part worked out allocated its tables' list, what it is made of (samplers, function tables, slots) and its listing anew. - A kept part's check allocated a list for the tables it worked out again. Now: - KeptHeap keeps the parts an ended encoder let go of, emptied (the module docs). Their plan is let go of, and what a part holds otherwise is plain data, so they hold nothing alive. - A part worked out goes into the storage of one of those, or of the part drawn through longest ago where it keeps as many as it may. - PastHeap keeps its list's storage (PastHeap::forget, which empties it in place). - The check works the tables out into a list the KeptHeap keeps. Measured, frame_costs on the M3: - debug, --cfg m2v_gpu: 20.83 allocations a draw, from 21.50; - release, without m2v_system_alloc: 7.38 a draw, against DRAW_ALLOCATIONS, 9. Verified on the M3 (potluck), on this tree: - clippy --cfg m2v_gpu of the runtime and the validation crate, all targets; - the runtime suite, debug, --cfg m2v_gpu, hazard filter: 1627 of 1628, the one failure exit_guard's known base failure (a547d0ce33); - the lanes: 246 of 247, the one failure frame_costs' debug bound at 20.83. The commits after this one address it. The same results, 1626 of 1627 in the suite, came on this change over 5ab66c0e6b without 60bb566cdc. (cherry picked from commit fcb0f1885b8fb69fedd9d138bc4a7f00a0dd276a) |
||
|
|
537667dfcf |
Share kept resident uses between plans that list the same uses
A pipeline state's draws of different primitive types may take plans of their own. The replayed textured page's point draws take another plan than its other four types, so 2 of every 5 replayed draws switch plan. The uses of what the encoder made resident were kept for one plan only, so each switch: - worked all of them out again (resident_uses_made 10,009,006 a frame for 5001 draws over 5002 resident textures, about 2001 draws' worth); - gave them a new identity, so every per-draw walk memo keyed on it (gathered, noted, unordered writes, indirect reads, geometry writes, attachments, pass reads) walked them again. Those uses are a function of the plan's uses (BindingPlan::uses) and the residency alone (binding::resident_uses_into). So the kept ones now serve any plan whose uses equal those of the plan they were made for. A plan is compared once, and the answer kept for the last five plans compared (ResidentOf::compared). Measured, release, the replayed textured page, interleaved with the commit before over two rounds (3 frames each): - Apple M3 Max, MoltenVK 1.4.2: - host_step_ms 1489-1621 a frame before, 407-468 after; - resident_uses_made 10,009,006 a frame before, 5006 after; - test time 5.1-5.3 s before, 1.8-2.1 s after; - pixels e3306dc52a1c9e86 in both. - RTX 5080 Laptop (b5080 entry resident-x-heap-part-004402, kind t): - host_step_ms 1309-1359 before, 481-525 after; - resident_uses_made 10,009,006 before, 5006 after; - pixels 8e977e2bb4582473 in both. - Against the commit before the heap part: the M3 goes from 10363-10491 to 407-468 ms, the 5080 from 8800-8931 to 481-525. The page's counters are this change's control: the commit before is this one without the sharing. Verified: the checks of the commit before, on this tree, with the same results. The new test passes. On the M3 it passes with the sharing taken out too: the fixture's vertex function writes no point size, so its points and triangles take one plan there. (cherry picked from commit 5ab66c0e6b185cbc2ee0dfb59048bf945bbdd217) |
||
|
|
493178c82e |
Keep a draw's heap part while what it is made of holds
A replayed page's host step costs about 400 ns per replayed draw per
resident texture (reims: 14 s a frame). Each draw works its heap part
out again for every texture its encoder made resident, though the
residency did not change and the command rebinds only a buffer:
- the handle tables, at every heap member (bind::heap::member_id,
table_bytes);
- where the heap writes go (heap_elements, member_id again);
- each heap entry's view check (bound_view, view_reading,
binding_view, Image::view);
- for every member, a neutral image descriptor in each heap image
array whose class it does not fit (neutral_view, border_texel,
BicubicTexels::with_border). heap_sets::bind then dropped every one
of those.
Now:
- The translator splits the heap part from the rest of a draw's
commands:
- BindingPlan::instantiate_draw_apart_into writes every command but
the heap tables;
- heap_tables_into writes the heap tables alone (handle tables,
sampler tables, function-table directories);
- heap_slots names the texture slots they read besides the used
resources.
instantiate_draw_into is unchanged. A consumer breaks nowhere: all
three are additions. docs/API.md says when the tables may be kept.
- The runtime keeps each draw's heap part in its encoder's LiveBind
(render/heap_part.rs): the heap tables, where the heap writes go
(Arc<HeapElements>), and the writes past the heap's entries
(binding::PastHeap). The first draw that checks every entry's view
lists those writes, and meets no notice the device announces at each
occurrence (EachWatch) while it does.
- What a part is made of:
- the plan, by address;
- the variant's heap capacity;
- the residency's generation;
- the argument samplers: the count of sampler-ID slot changes they
were listed at, else compared state by state;
- the function tables, compared;
- what the plan's heap slots bind, compared;
- the heap placement and the token order.
- Parts are kept for the last 8 plans, so pipeline states drawn in
turn and the plans a draw's primitive type picks each keep their
own. They go as the encoder ends.
- Builds with debug assertions check every kept part against one
worked out whole, and every listing of writes past the heap against
one listed again.
- bind_into writes no heap image element at all, whatever the plan
reads: the device's heap set holds each one. One predicate,
heap_sets::holds_element, now says this for bind_into and
heap_sets::bind.
- WorkCounts::draw_heap_parts_made counts the parts worked out. The
replayed-frames lanes print it, and the resident uses' walk counters.
Builds with debug assertions check a kept listing against the writes
listed again in place, allocating nothing.
Measured, release, the replayed textured page
(runtime_lane::replayed_textured, 3 frames, interleaved with the
commit before over two rounds):
- Apple M3 Max, MoltenVK 1.4.2:
- host_step_ms 10363-10491 a frame before, 1489-1621 after;
- test time 31.7-32.5 s before, 5.1-5.3 s after;
- pixels e3306dc52a1c9e86 in both;
- peak RSS 306-317 MiB in both.
- RTX 5080 Laptop (b5080 entry resident-x-heap-part-004402, kind t):
- host_step_ms 8800-8931 before, 1309-1359 after;
- pixels 8e977e2bb4582473 in both.
- After, in both: draw_heap_parts_made 2 a frame (the point draws'
plan and the other draws'). resident_uses_made stays 10,009,006 a
frame; the next commit addresses it.
The 5080 binaries came from build-only commits. Their release code
equals this tree's but for the Deferred Send and Sync below this
commit and the lane's extra counter print.
Verified:
- On the M3 (potluck), clippy, plain and --cfg m2v_gpu, all targets,
of the translator, the runtime and the validation crate; Rustdoc
-D warnings; scripts/api-docs.
- The translator's heap, binder, instantiate and api tests, 143 of
143. Among them, graphics tests check that instantiate_draw_apart_into
plus heap_tables_into equals instantiate_draw_into wherever the
latter succeeds.
- The runtime's suite, debug, --cfg m2v_gpu, hazard filter: 1626 of
1627. The one failure, exit_guard's
only_the_listed_modules_keep_the_device_s_functions, fails on the
base too: a547d0ce33's command_buffer Parts shares a name with the
device's Parts.
- The validation lanes over residency, draws and notices, debug,
--cfg m2v_gpu, hazard filter: 246 of 247. The one failure is
runtime_lane::frame_costs::a_frame_s_draws_and_pass_ends_allocate_
within_their_bounds: 21.50 allocations a draw on the M3 against
DRAW_ALLOCATIONS_DEBUG, 20. Whether that comes from this change or
from its base is not yet measured. The release bound
(DRAW_ALLOCATIONS) was not run.
- Negative control: with the kept part never kept, the new test fails
at draw 1 (heap_parts 1, expected 0).
(cherry picked from commit 12f8301c62ffbbc149c04792007895649b8fe9ed)
|
||
|
|
e4d238a31d |
Patch a rebound draw's buffer-slot uses through a list of them
patch_buffer_uses found the uses of the buffer slots a call changed by walking every use of the kept draw past its resident ones and looking up each one's resource use to learn its slot. CommandUses now keeps, in uses a caller keeps (command_uses_into), the slot and position of each use of a buffer slot (`slots`), filled in the loop that makes the uses; patch_buffer_uses walks that list alone. Uses that command_uses makes whole (dispatches, tile dispatches, GPU-executed commands and the debug check's) list nothing, since nothing patches them, so they make no allocation more: a first version that listed slots in every CommandUses failed frame_costs' debug draw allocation bound (20.04 a draw, over 20) through the debug check's whole uses. Builds with debug assertions check the list against the uses before each patch (slot_uses_listed) and count the patches and the uses they looked at (patched_slot_uses). Verified on the M3 Max, debug, --cfg m2v_gpu: - New test draw_again::draws_rebound_after_an_offset_moved_patch_that_ slot_s_use_alone: draws of tob_sample with the texture and sampler bound once and vertex buffer 0's offset moving; each patch looks at one use, the vertex buffer's. Negative controls, each failing that test: listing every slot class trips "a command's uses of buffer slots other than it lists"; counting every use past the resident ones (what the old walk looked at) gives 21 uses over 7 patches against 7. - Runtime suite 1620/1620 (potluck job m3-max-155); the validation lanes over residency, draws and notices 248/248 (m3-max-157). draws.10k (reims-vgpu's draw_cost harness, release, M3 Max, 3 rounds interleaved, job m3-max-168), runtime leg per draw: - instructions 8337.5 / 8334.8 / 8334.3 against 8375.3 / 8386.3 / 8380.2: -44 (-0.5%); - CPU ns 430.6 / 432.5 / 430.3 against 422.6 / 432.1 / 429.5: no change beyond the noise. The base binary is 43be622f72, whose tree differs from this commit's parent only in noted_apart.rs's d2.1 variant; the two variants measured equal at draws.10k (8386.5 / 8381.0 against 8382.4 / 8383.9). (cherry picked from commit dbf5576dc25c7ee2bcb3e709c2b786758763aa1e) |
||
|
|
669b2df593 |
Note a draw's uses of what its encoder made resident once while their identity holds
A draw noted its uses apart (EncoderCore::note_reaching) by comparing every one with the last
draw's (NotedApart::holds, NotedApart::fresh), recording those that differed, touching each
(EncoderCore::touch_reaching) and copying them all for the next draw (NotedApart::note): work of
the count of the resources its encoder made resident, at each draw, which draws keep from one to
the next with their identity (binding::ResidentPrefix). On the resident-draws lane at N 2000 that
was 46% of the samples after the uses were kept.
CommandUses gives, with that identity, one of the keys the uses reach through the resident set
alone, given where those are worked out again (settle_resident, where it made uses of what the
encoder made resident), and the stages of those uses, folded where they are made:
CommandUses::reaching_prefix (binding::ReachingPrefix), None while a use added since took one of
those keys. render.rs's draw path and a rebound draw choose by it: a draw without one is noted by
note_reaching as before; one with one by EncoderCore::note_draw, which
- answers whether it is noted already by the identities and its uses past them
(NotedApart::holds_draw), records the uses past them that differ from the last's at their place
where the last began with the same (NotedApart::fresh_draw; every use otherwise),
- touches only the uses past them where the last such draw of the encoder began with the same
while the device's buffers over host pages stand as they did (NotedApart::touched,
EncoderCore::touch_draw), as the keys a draw touched stay kept, and named, while the encoder is
open,
- and keeps the identities and its uses past them alone (NotedApart::note_draw).
A command noted whole after it finds it not noted already (NotedApart::holds checks that the last
was noted whole). NotedApart::uses, which a draw again notes its fresh reads by, is a kept draw's,
which begins with no use of what its encoder made resident (checked with debug assertions).
Counted: WorkCounts::resident_uses_noted, the kept uses a draw's noting walked: 0 at a draw that
begins with the uses the last noted, by identity. WorkCounts gains that field, so a struct literal
of it must name it; the signature table is blessed. Builds with debug assertions keep the whole
uses too and check holds_draw, fresh_draw and touch_draw against them.
Tests (--cfg m2v_gpu, with debug assertions):
- tests::noted_apart::a_draw_beginning_with_the_same_resident_uses_compares_only_its_others and
tests::noted_apart::a_draw_s_resident_uses_are_touched_once_by_their_identity;
- tests::resident_uses::draws_keep_the_uses_of_what_their_encoder_made_resident_until_it_or_their_plan_changes
now also counts the kept uses each draw's noting walked.
Verified on the M3 Max (macOS 27), through potluck, as b3ddf2c122, this same tree:
- the runtime's suite (--cfg m2v_gpu, debug): 1619 passed;
- the validation lanes over residency, draws and notices (resident_draws::each, used_resources,
argument_buffers, render_arguments, indirect_command_buffers, indirect_executions,
draw_changes, draw_work, draw_costs, frame_costs, heaps, heap_textures, handles,
attachment_reads, attachment_read_costs, pass_start_reads, degrade_notices, degradations,
executions, shadows, in_place_textures): 248 passed;
- negative controls, each run and failing:
- NotedApart::fresh_draw taking any identity of the same count for the last's:
tests::noted_apart::a_draw_beginning_with_the_same_resident_uses_compares_only_its_others
fails its assertion of the uses found fresh;
- NotedApart::touched taking any identity of the same count for the last's: the debug check
fails ("a draw touched by its uses' identity less than by its uses") in
tests::noted_apart::a_draw_s_resident_uses_are_touched_once_by_their_identity, and
tests::resident_uses::draws_keep_the_uses_of_what_their_encoder_made_resident_until_it_or_their_plan_changes
fails its count;
- NotedApart::holds_draw comparing the uses' identity alone, not the resident keys': the unit
test above fails ("!noted.holds_draw(stages, (&first, &resident, other), into)").
Measured on the M3 Max:
- Plain rebound draws (reims's draws.10k, no resident uses; the runtime leg's instructions a
draw, median of 9 runs, two interleaved rounds, potluck job m3-max-136): the stack-26 gate tip
|
||
|
|
ec85bf8938 |
Check a draw's uses of what its encoder made resident against the attachments once
While AttachmentReadInPlace would be announced (never yet on the device, or at each occurrence),
each draw's check for memory an attachment of its render pass renders
(Device::degrade_attachment_reads, render_target::shares_attachment) walked its uses for each
attachment: work of the count of the resources its encoder made resident, at each draw, which
draws keep from one to the next with their identity (binding::ResidentPrefix). On the
resident-draws lane at N 2000, with the earlier steps, that was 12% of the samples.
render.rs's draw path and a rebound draw choose by CommandUses::prefix: a draw whose uses have
no identity is checked by degrade_attachment_reads, as before (its notice now made by
attachment_read_notice, which both share). One whose uses have one goes through
Device::degrade_resident_attachment_reads. Where a check of its whole uses finds that they share
no memory with an attachment, CommandUses keeps their identity and count with the version of the
pass's layout (CommandUses::apart_from): the next draw that begins with the same, in a pass of
that layout, checks only its uses past them (CommandUses::apart). An attachment's memory is its
texture's image or bytes, which no call changes, and a layout of one version is the same layout
(Versioned). A layout of a draw's own (attachments stood in for, render.rs) has no version, and
its draws check their whole uses. Where they share memory with one, every draw checks them, as
before, so a device that announces each announces each.
Counted: WorkCounts::resident_uses_against_attachments, the kept uses a check walked: 0 at a draw
that begins with the uses found to share none. WorkCounts gains that field, so a struct literal of
it must name it; the signature table is blessed. Builds with debug assertions check every answer
against that of the whole uses.
Tests (--cfg m2v_gpu, with debug assertions):
- tests::resident_uses::draws_announce_each_read_of_an_attachment_their_encoder_made_resident:
draws whose encoder made their pass's attachment resident each announce AttachmentReadInPlace
at each draw (announce_each), the later ones keeping their uses. With the identity kept where
the uses share memory with an attachment, the debug check fails ("a draw's uses checked
against the attachments by their identity less than its uses").
- tests::resident_uses::draws_keep_the_uses_of_what_their_encoder_made_resident_until_it_or_their_plan_changes
now also counts the kept uses the check walked: 0 at each draw that kept them.
Verified on the M3 Max (macOS 27), this tree (committed when the work was parked):
- the runtime's suite (--cfg m2v_gpu, debug): 1592 passed;
- the validation lanes over residency, draws and notices (resident_draws::each, used_resources,
argument_buffers, render_arguments, indirect_command_buffers, indirect_executions,
draw_changes, draw_work, draw_costs, frame_costs, heaps, heap_textures, handles,
attachment_reads, attachment_read_costs, pass_start_reads, degrade_notices, degradations,
executions, shadows, in_place_textures): 245 passed;
- clippy (workspace, all targets and features, -D warnings) at --cfg m2v_gpu and plain, and the
runtime's release --tests check at --cfg m2v_gpu: clean; the signature table check: clean;
- the negative control above, run: fails as described.
Measured:
- Plain rebound draws (reims's draws.10k, no resident uses; the runtime leg's instructions a
draw, median of 9 runs, two interleaved rounds): d1 11389.8 and 11384.1, this 11390.2 and 11376.5.
- RTX 5080 laptop (host_ab encode, 10,000 draws; median over 6 runs of each run's median, us a
draw; two exclusive holds of 3 interleaved passes, the CPU package at 63 to 66 C): draw_offset
d1 0.459, the last commit 0.413, this 0.434 (draw_offset is bimodal by process: 0.409 to
0.454 over this one's runs); draw_compositor d1 0.978, the last commit 0.974, this 0.982.
- The resident-draws lane on the M3 Max, whole-process instructions over 5 frames (frame
median ms), the last commit then this, interleaved:
entry own encoder N 500 1.317e9 (6.5) 1.335e9 (6.5)
N 1000 2.511e9 (19.0) 2.539e9 (19.8)
N 2000 7.296e9 (66.0) 7.410e9 (69.6)
N 5000 39.12e9 (393.0) 39.82e9 (399.1)
entry own write N 5000 40.69e9 (456.7) 41.39e9 (481.8)
one round each. This step saved nothing on the lane: about 5.6 instructions more a resident
use a draw at N 5000. An earlier form of it (degrade_attachment_reads itself choosing by the
identity) saved about 19 a use on the same lane. The cause is not investigated: UNVERIFIED
whether the lane's draws check against the attachments at all once their kind is announced,
and whether the identity is kept across them.
(cherry picked from commit 5634c84266d2de065b92822ec1d50610b74e2c22)
|
||
|
|
8da041d648 |
Gather a draw's uses of what its encoder made resident once while their identity holds
A draw's gathering for its render pass instance (InstanceShadows::add, which the shadowed
textures it uses are copied around) compared each of its uses with the last draw's at its place
and gathered those that differed: work of the count of the resources its encoder made resident,
at each draw, which draws keep from one to the next since the last change
(binding::command_uses_into). On the resident-draws lane at N 2000 that was 17% of the samples
after the uses were kept.
The kept uses now have an identity (binding::ResidentPrefix): a number of the process's, given
where command_uses_into makes them (none where they are none), and their count. The numbers come
from one counter, taken at such a making alone; a draw that keeps them, or has none, takes none.
CommandUses::prefix gives it, None where there are none or command_uses made the uses whole.
A draw whose uses have an identity is gathered through InstanceShadows::add_draw, which keeps the
identity and count of the kept uses the instance's last such draw began with: a draw that begins
with the same gathers only its uses past them. What an instance gathered stays until it is
cleared, and uses of one identity are the same uses, so gathering them again changes nothing, as
each range only grows. A draw whose uses have none is gathered by InstanceShadows::add, as
before: render.rs's draw path and a rebound draw choose by CommandUses::prefix, so a plain draw
takes the code it took before but for that choice.
Counted: WorkCounts::resident_uses_gathered, the kept uses a draw's gathering walked: 0 at a
draw whose instance's last such draw began with the same. WorkCounts gains that field, so a
struct literal of it must name it; the signature table is blessed. Builds with debug assertions
check, at each such draw, that what the instance gathered holds each of the draw's whole uses'
reads and writes.
Tests (--cfg m2v_gpu, with debug assertions):
- tests::resident_uses::draws_keep_the_uses_of_what_their_encoder_made_resident_until_it_or_their_plan_changes
now also counts the kept uses each draw's gathering walked: 0 at each draw that kept them,
some at each that made them again. With add_draw taking any identity for the last's, the debug
check fails at the draw after the use_resource ("an instance gathered by its uses' identity
less than its uses").
Verified on the M3 Max (macOS 27), this tree:
- the runtime's suite (--cfg m2v_gpu, debug): 1588 passed;
- the validation lanes over residency, draws and notices (resident_draws::each, used_resources,
argument_buffers, render_arguments, indirect_command_buffers, indirect_executions,
draw_changes, draw_work, draw_costs, frame_costs, heaps, heap_textures, handles,
attachment_reads, attachment_read_costs, pass_start_reads, degrade_notices, degradations,
executions, shadows, in_place_textures): 245 passed;
- clippy (workspace, all targets and features, -D warnings) at --cfg m2v_gpu and plain, and the
runtime's release --tests check at --cfg m2v_gpu: clean; the signature table check: clean;
- the negative control above, run: fails as described.
Measured:
- Plain rebound draws (reims's draws.10k, no resident uses; the runtime leg's instructions a
draw, median of 9 runs, two interleaved rounds): d1 11386.9 and 11378.7, this 11384.8 and
11382.2.
- RTX 5080 laptop (host_ab encode, 10,000 draws; median over 6 runs of each run's median, us a
draw; two exclusive holds of 3 interleaved passes): draw_offset d1 0.471, this 0.441;
draw_compositor d1 1.038, this 1.020 (draw_offset is bimodal by process).
- The resident-draws lane on the M3 Max, whole-process instructions over 5 frames (frame
median ms), d1 then this:
entry own encoder N 500 1.389e9 (8.4) 1.273e9 (7.1)
N 1000 3.249e9 (27.0) 2.787e9 (22.5)
N 2000 10.23e9 (108.6) 8.384e9 (90.9)
N 5000 57.47e9 (642.4) 45.91e9 (517.7)
entry own write N 5000 60.72e9 (752.8) 49.10e9 (597.8)
about 92 instructions fewer a resident use a draw; entry one encoder N 5000, 3 frames:
2.224e9, 2.221e9.
(cherry picked from commit a46fe23585cf0a1d3183349d64d68d6e650e8758)
(cherry picked from commit 6de4e38fbb2daec5f1e61cf0aaffefd356e51a0d)
|
||
|
|
626bd347d2 |
Keep a draw's uses of what its encoder made resident while its plan and residency stay the same
A draw's uses (binding::command_uses_into) held a use for each resource the encoder made
resident that its binding plan lists (UseTarget::Used), made again at every draw with two sets
of the keys reached through the resident set and named otherwise: work of the count of the
resources made resident, at each draw. On the resident-draws lane (runtime_lane::resident_draws:
each draw binds a resource of its own among N made resident), that made a frame of N draws
quadratic in N.
A draw's CommandUses (kept in LiveBind::uses) now holds those uses first, with the keys of the
buffers among them that no texture use of them names, and what they were made for: the plan,
compared by address through a Weak (so no other plan has that address while it is kept), and
the residency's generation. A draw of the same plan under a residency of the same generation
keeps them, makes its other uses, and works the resident keys out again only where the keys
its other uses name changed, or a use added since took one out (CommandUses::settle_resident).
Those uses are a function of what is compared: each one's resource is the residency's under its
token, whose contents a generation names (residency.rs), its access and stages are the plan's,
and its key and range are the resource's identity and length, which no call changes. The key
leaves out buffer::host_cells_moved: a no-copy buffer's move (HostCell::replace, at a rebind or
a detach) changes where its bytes lie, its pages' base and device address, which a binding
reads; a use's key is the buffer's identity and its range its length from 0, shifted for a heap
buffer by its fixed offset in the heap (Buffer::tracked), and neither is under the cell.
The uses of what the encoder made resident now come first among a command's uses, where they
came at their place in its plan's list. The consumers that compare a command's uses by position
with the last command's (EncoderCore::touch_reaching, NotedApart::fresh, InstanceShadows::add)
compare like with like across draws of one plan. With that order every suite and lane below
passes, and the lane's cases draw the same pixels and move the same counters.
Counted: WorkCounts::resident_uses_made, the uses of resources made resident that draws worked
out (0 at a draw that kept them). WorkCounts gains that field, so a struct literal of it (the
lanes' counters, not part of the API) must name it; the signature table is blessed. Builds with
debug assertions check every draw that kept them against the uses command_uses makes whole, and
count the checks (binding::kept_resident_checks).
Tests (--cfg m2v_gpu, with debug assertions):
- tests::resident_uses::draws_keep_the_uses_of_what_their_encoder_made_resident_until_it_or_their_plan_changes:
two encoders over the resident-draws fixture's entry shape, the second over other resources
of the same residency's shape. Each draw after the first keeps the uses (0 made, its kept uses
checked against those made whole) but the draw after a use_resource between draws, the draw
after one of another plan (which lists none), and the second encoder's first draw, of the
first's last plan under another generation, which make them again. With ResidentOf::holds ignoring the
generation, the debug check fails at the second encoder's first draw ("a command kept uses of
what the encoder made resident not its own"); with it ignoring the plan, the draw after the
other plan's indexes another plan's uses and panics (index out of bounds).
Verified on the M3 Max (MoltenVK 1.4.2), --cfg m2v_gpu, with debug assertions: the runtime's
whole suite, 1588 of 1588; the validation crate's runtime lanes over residency, argument
buffers, indirect command buffers, executions, draws, frame costs, heaps, handles, attachment
reads and degrade notices (resident_draws::each_path_draws_what_the_encoder_draws among them,
300 draws a case under the debug check), 234 of 234; clippy over the workspace with all targets
and features, plain and at --cfg m2v_gpu; cargo check of the runtime's tests in release at
--cfg m2v_gpu, no warning; the signature table checked.
Measured, M3 Max, release (--cfg m2v_gpu --cfg m2v_system_alloc), resident_draws, a frame's
median of 5 (ms), at the parent and with this:
| case | N 500 | N 1000 | N 2000 | N 5000 |
|---|---|---|---|---|
| entry own encoder | 20.2 -> 7.7 | 81.1 -> 25.0 | 351 -> 91.8 | 2576 -> 525 |
| entry own read | 20.9 -> 8.6 | 80.0 -> 27.9 | 355 -> 96.2 | 2542 -> 550 |
| entry own write | 22.0 -> 9.5 | 83.2 -> 29.0 | 355 -> 98.9 | 2597 -> 549 |
The slot shape and the entry shape at offsets of one buffer move within their noise. Every
case drew the same pixels (its hash) and moved the same counters but those of timing (arena
recycling and eviction, scheduler sleeps) and resident_uses_made (its plan's uses at each
frame's first draw: 502 a frame at N 500, 0 at every later draw). Still quadratic: 15.4, 25.0,
45.9 and 105 us a draw; at N 2000 the draws' noting of the kept uses (EncoderCore::note_reaching,
46% of the samples), the instance's gathering (InstanceShadows::add, 17%) and the pass's reads
(PassStartReads, 12%) walk them at each draw, and uses_into is 0.3%.
reims-vgpu's draws.10k (its draw_cost harness, the runtime leg, through its run.sh on the M3
Max; median [range] of 9 runs, two interleaved runs each), instructions a draw: 11473.9
[11463.0, 11480.2] and 11478.8 [11471.2, 11481.6] at the parent, 11387.0 [11373.8, 11392.7] and
11387.1 [11378.9, 11404.4] with this: 87 fewer (0.8%), the two sets no longer made at each draw.
host_ab on the RTX 5080 Laptop (encode, us a draw, median and range of 6 runs over two exclusive
holds), at the parent and with this: static 0.059 and 0.059, offset 0.462 and 0.465, bind 0.753
and 0.740, compositor 1.012 and 1.002, host 0.518 and 0.515: within their ranges, as those
shapes make nothing resident.
(cherry picked from commit f6bc17a568bd6b1424089faf8e26584bd159fbb8)
(cherry picked from commit 02ef82edcb8c8042b313d8773a58575447e07795)
|
||
|
|
32b1920f21 |
Work a buffer use's access out at its callers, with bytes_use infallible and inline
Step 2 (patching a rebound draw's buffer uses in place) moved the making of one buffer use into binding::bytes_use, which command_uses_into calls for each buffer use of every draw that takes every step, and which returned a Result: it worked out the use's access flags from its class (fallibly) and checked its source index's width per use. On the 5080 the shapes that never take the patch read slower after step 2 in two A/Bs (bind 0.848 -> 0.884 and 0.960 -> 1.014 us a draw, compositor 1.089 -> 1.127 and 1.207 -> 1.266, medians of 6 samples each, wide ranges). bytes_use now takes the use's reads and writes as its callers work them out and returns the use: command_uses_into works the access out from the class as before every step did, and patch_buffer_uses keeps the accesses of the use it patches, which its class made. The source index's width is checked once a command, for its whole count of uses, where it was checked per use. The uses made are the same. Measured. M3 Max, whole-process instructions a draw (two runs of 3000 and 9000 draws a pass, 23 passes each), step 1 / step 2 / step 2 with this: bind 16601 / 16882 / 16338, compositor 19039 / 18466 / 18852, offset 12430 / 11940 / 11871: mixed signs within about 600, so no cost of step 2 on those shapes stands out of the noise there, nor any gain of this. 5080, interleaved A/B of 6 samples in 2 exclusive holds, us a draw, median (range): bind 0.960 (0.871-1.406) / 1.014 (0.908-2.585) / 0.988 (0.909-1.790), compositor 1.207 (1.133-3.339) / 1.266 (1.190-2.271) / 1.258 (1.168-2.254), offset 0.629 / 0.616 / 0.602. The 5080's main-thread perf counts spread too far to read (offset 11770 to 21885 instructions a draw across binaries whose encode times sit within 0.05 us). A neutral change, kept as correct and built. Verified on the M3 Max (MoltenVK 1.4.2), --cfg m2v_gpu, with debug assertions, on step 4's tree with this: the runtime's whole suite, 1551 of 1551; the validation crate's runtime lanes frame_costs, draw_* and render, all passing; clippy over the workspace at --cfg m2v_gpu. (cherry picked from commit f44082d4e309bbc18e5cdac3cb232b560c7134a6) (cherry picked from commit a087c926bcf9f250436db564d1645ff122f9c560) |
||
|
|
d6731732dd |
Rebind a draw's buffer slots without locking its command buffer's state
A draw rebound locked its command buffer's state (CommandBuffer::state) to rewrite set 0's buffer descriptors, as binding::descriptor takes the state for the sources that upload bytes. The command buffer's encoders on other threads share that lock, and the 5080 profile put about 2.6% of a rebound draw in it. The rebind rewrites only slots' descriptors: a buffer slot's buffer, or the call's copy of a slot's bytes, neither of which uploads. binding::slot_descriptor now makes those two descriptors from the command's planned range alone (planned_range and in_space, shared with binding::descriptor, which takes them first), and rebind_into takes no state: a draw rebound locks none. In builds with debug assertions, CommandBuffer::state counts its locks on the locking thread (command_buffer::state_locks), and tests::shared_draw_locks::draws_rebound_at_another_offset_lock_no_command_buffer_state draws a rectangle at another offset of its vertex buffer 8 times and asserts that every draw counted rebound (WorkCounts::draws_rebound) locked no command buffer's state. Verified so far: clippy over the runtime, plain and --cfg m2v_gpu. Its run on the M3 Max (the runtime's whole suite and the validation crate's runtime lanes) and its negative control (a state lock put back into the rebind, so the new test should fail) are pending. 5080: expected faster on the rebound shapes; the interleaved A/B is pending. (cherry picked from commit a77b2629c6e5c9a0cda65332f1cacca29c4255da) (cherry picked from commit 49dd6820c6de412a7b3c744569c63390a1fbbbd3) |
||
|
|
d21d960cb1 |
Point a push's raw descriptor writes at each write's own info
binding::push_set copied each pushed write's info into one of three 16-entry arrays (buffer infos, image infos, texel views), zeroed whole first with a 16-entry array of raw writes, and pointed each raw write at its copy: about 1.9 KB zeroed and filled at every push of set 0, of a draw or a dispatch. write_sets did the same for each 16 writes it hands vkUpdateDescriptorSets. A raw write now points at the info its write holds where it lies (Info::written, SetWrite::raw): the infos are copied nowhere. The raw writes sit on the stack uninitialised past those written (binding::fill_raw), and only those are handed over; past 16, push_set collects them on the heap as before. Vulkan reads the infos during the call, while the writes they lie in live. The same descriptors reach the same commands. tests::push_raw_writes asserts it: of a buffer, an image and a texel write, each raw write is at its binding, element and type with one descriptor, and points at its own write's info (by address), and as many raw writes as writes are handed over. Verified on the M3 Max (MoltenVK 1.4.2), --cfg m2v_gpu, with debug assertions: the runtime's whole suite, 1550 of 1550; the validation crate's runtime lanes (frame_costs, render, draw_*, compute, dispatch, tile, hazards, sync_coverage, shadows, attachments, executions, degrade_notices, push, descriptor, argument), 343 of 343. Clippy over the runtime, plain and --cfg m2v_gpu; signatures.py --check. 5080: expected faster at every push; the interleaved A/B is pending. Single lock holds read 0.483-0.502 us a draw on the offset shape with the steps before. (cherry picked from commit ecb9682fd1384d7d09dfc5d7634b052ddeb4a7e8) (cherry picked from commit 2d224ab1674e199de10900876e8257a79fa3602e) |
||
|
|
698988bdde |
Patch a rebound draw's buffer uses in place where only offsets moved
A draw rebound after buffer binds made its uses again whole (binding::command_uses_into): every use of every slot, texture and resource, and the attachment checks of the texture uses (render_target::shares_attachment). Where only buffer slots changed and each still binds the buffer it bound (its offset may have moved), only those slots' uses can differ. command_uses_into now records, for each use it makes, the index of the plan's or command's resource use it was made of (CommandUses::sources). binding::patch_buffer_uses rewrites in place the uses of the changed buffer slots, as bytes_use (factored out of the builder) makes them for the slot's buffer and offset now. It declines, and the draw makes its uses whole as before, where any changed slot is unbound or binds another buffer, where a use was added after the builder (its sources no longer match), or where a texture or sampler slot changed. Every other use is of a slot, buffer or texture no call changed, so the uses, and the keys the resident set reaches, are those command_uses_into makes, and the tracker sees the same uses and ranges: the same barriers. Verified on the M3 Max (MoltenVK 1.4.2), --cfg m2v_gpu, with debug assertions, where the first rebound draw of a kept draw and every second after it take every step and compare the uses by digest: the runtime's whole suite, 1549 of 1549; the validation crate's runtime lanes (frame_costs, render, draw_*, hazards, sync_coverage, shadows, attachments, executions, degrade_notices), 292 of 292. Negative control (the patch skipping its rewrite, so the debug check should report other uses): built, its run pending. Clippy over the workspace, plain and --cfg m2v_gpu. 5080: expected faster on the offset shape; the interleaved A/B is pending. Single lock holds read 0.548-0.567 us a draw on the offset shape with the step before. (cherry picked from commit 678ded926bd21c1b52ecb693b7a6f5664500e017) (cherry picked from commit e11f9719d9bb500bf346cd5d2077788059011cc3) |
||
|
|
df985fbacb |
Check a draw again against its every step by digests: the check allocates nothing
In builds with debug assertions every second draw again (and rebound draw) takes every step and checks it against what the draw again would have done. The check boxed itself (Again::Check's Box<Checked>) and cloned what it compared: the drawn areas and coverage, the pass's reads and the instance's gathered uses (HeldReads, HeldGathered: copied lists), the noted uses, the pass's input and extended sets, and of a rebound draw its commands, set-0 writes, offsets, push bytes, vertex buffers, uses and resident keys. Those allocations count in the frame lanes' draw allocations, which CI runs with debug assertions: runtime_lane::frame_costs' a_frame_s_draws_and_pass_ends_allocate_within_their_bounds measured 22.30 allocations a draw on the M3 (bound 20) once draws rebind. Each part is now compared by a digest of its Debug form, streamed into a hasher through a fmt::Write adapter (draw_again::digest), which copies nothing. The encoder's held state is taken only for a plain draw again (Expected::Plain; a rebound draw's check compares what it worked out, Expected::Rebound). Checked is no longer boxed: the draw path hands draw_again an Option<Checked> on its stack, which kept_again takes as before. pass_start_reads::held and shadows::gathered lend their lists rather than copy them; binding::Info and NotedApart print their Vulkan values raw (ash's types print nothing without its debug feature). Release builds are unchanged. No bound changed. Measured on the M3 Max (MoltenVK 1.4.2), with debug assertions: that lane's draws make 18.21 allocations a draw (was 22.30; bound 20); a pass end 15.67, a pass open 5.00. Negative control: with binding::rebind_into's image descriptors left as they were (the rebind's texture path broken), tests::draw_again::draws_after_texture_and_sampler_changes_rebind_what_every_step_binds fails with "a draw rebound worked out other set-0 writes than its every step". Verified there, --cfg m2v_gpu, on a tree that also held the next commit's change: the runtime's whole suite, 1545 of 1546 (the one failure, tests::scheduler_wakes:: commits_with_idle_gaps_lose_no_wake, passed 10 of 10 reruns); the validation crate's runtime lanes listed in the last commit, 288 of 288. Clippy over the workspace, plain and --cfg m2v_gpu; release builds check clean. (cherry picked from commit 1b8e52fe2f58f01df507d4f9b345dcb901c16ca2) (cherry picked from commit 838786566146858e00b579ebc78240353fa87061) |
||
|
|
50b41ecc54 |
Draw the kept draw again rebound after texture and sampler binds too: rewrite those slots alone
A vertex or fragment texture or sampler bind forgot the encoder's kept draw, so a draw after one
took every step: the compositor shape (a buffer and a texture bound before each draw) never
reached the bind tail.
Now:
- Texture and sampler binds keep the kept draw (log_keeping), as buffer binds do; the next draw
compares the tables' stamps.
- BindingPlan::rebind_draw_slots_into (was rebind_draw_buffers_into) takes buffer, texture and
sampler slots. A texture or sampler slot decides none of the commands. It answers Ok(false)
for a texture buffer's texel range and a YCbCr texture's planes.
- binding::rebind_into writes a changed texture's or sampler's image descriptor as bind_into
does (image_descriptor, through the encoder's memo, its samplers kept for retaining). It
answers Ok(false) for a changed texel buffer, YCbCr image or argument sampler.
- The draw rebound brings in texture and sampler slots and stops where every step would differ:
- a memoryless texture its functions use (the full path fails the command buffer there);
- runtime samplers' address modes other than the kept draw's;
- a changed shape (a sampler of other addressing, which the pipeline's specialization
reads, takes every step);
- a plan that samples or writes a color attachment's texture;
- an extended-range shadow.
It retains the new samplers and notes whether its uses read an image (Kept::reads_images).
- Docs: rebound.rs, WorkCounts::draws_rebound, docs/API.md, api_signatures.tsv.
Check: tests::draw_again::draws_after_texture_and_sampler_changes_rebind_what_every_step_binds
(tob_sample). It covers another texture each draw, another sampler of the same shape, both,
and samplers of other addressing. It checks rebound counts (0 for the last), commands, state
commands, noted uses and pixels against every step, with the debug cross-check on every second
hit. It fails without the change (0 rebounds). The buffer test's slot-of-another-class case is
now more slots than a draw rebound takes (samplers 0 to 8). Passes on the M3 (MoltenVK) with
the draw_again tests; clippy clean, plain and with --cfg m2v_gpu.
(cherry picked from commit ecf97956b214836a1309affe539aff8454239e97)
(cherry picked from commit 8472edf4c0ae174c3dab7bc667cecfa6874aa942)
|
||
|
|
e3f2c95dfe |
Draw the kept draw again rebound: after buffer, offset or bytes binds, rewrite those slots alone
A render encoder's kept draw (render/draw_again.rs) drawn again after calls that bound other
buffers, offsets or inline bytes at vertex or fragment buffer slots now rebinds only those slots
(render/draw_again/rebound.rs, WorkCounts::draws_rebound), where it took every step of a draw.
- Translator: BindingPlan::rebind_draw_buffers_into(state, slots, commands) writes again, over
the same draw's commands of a state of the same shape, only what the buffer slots decide: their
descriptor ranges at their places, the SlotBindOffset, SlotGuestBase and pulled-stride push
fields that read them, and their vertex buffers' offsets. Ok(false) for a device-address slot,
an argument or root table, a per-bind stride's vertex binding, a mesh, patch or de-indexed draw,
or a uniform view a written slot may alias. docs/API.md says so; api_signatures gains it and
WorkCounts::draws_rebound.
- Runtime: buffer and bytes binds keep the kept draw (log_keeping); the draw compares its tables'
stamps with the kept draw's. On a difference, the tables' changes since (argument_table::
changed_since: buffer slots alone, at most 8) are brought into the kept bind state
(refresh_changed), and the draw goes on only where its shape stays, its variant and plan then
the bind state's kept settle (LiveBind::settles_kept). It rewrites the commands
(rebind_draw_buffers_into), set 0's writes and dynamic offsets (binding::rebind_into), push
bytes and vertex buffers, and its uses whole (command_uses_into), and takes the checks a draw
takes of them: a pulled attribute's reach, the stages' function tables, the attachments' reads;
it stops at a pass whose fragments wrote memory, a shadowed texture among its uses, a barrier
its fragments need after earlier geometry writes, or a detached buffer. It records with set 0
as any draw finds or writes it (EncoderCore::set_zero_of), its uses noted as any draw notes
them, through the kept draw's recording parts against what its command buffer holds; a notice
met at each occurrence forgets it once recorded, as every step does. The kept parts (set-0
writes that hold no keeper, dynamic states, the rest of its recording) live in the bind state's
storage (LiveBind::kept), filled at the keep alone: a draw that takes every step pays one
KeptStorage::keep and nothing per recording.
- Checked in builds with debug assertions: the first rebound draw of a kept draw and every second
after it take every step instead, which must keep the draw, with the same commands, set-0
writes, dynamic offsets, push bytes, vertex buffers and uses.
Tests: tests::draw_again::draws_after_buffer_changes_rebind_what_every_step_binds (MoltenVK, M3):
draws after offset and bytes changes rebind (draws_rebound == the draws again but those the check
takes), with the same commands of every kind, state commands, noted uses and pixels as the same
draws each taking every step, every draw at its own offset and color; a sampler bind between them
takes every step. Negative control: the translator not rewriting a changed slot's range fails it
at the cross-check ("other commands"). metal2vulkan's tests::engine_graphics_binder rebind test:
1360 rebinds over stage-io plans equal a full instantiate, and its negative control fails.
host_ab encode, release, 10k draws per command buffer, us/draw, offset case (one
set_vertex_buffer_offset before each draw), measured on this change before its last revision
(which moved the kept parts' fill from every full draw's recording to the keep and dropped three
Arc clones a keep; its own numbers come with the next landing):
Apple M3 Max, MoltenVK 1.4.2, three interleaved rounds (median / mean of round p50s / max p90):
lock fix 1.561 / 1.550 / 1.591 -> 0.550 / 0.548 / 0.592
RTX 5080 Laptop GPU, thread CPU per draw, host_ab threads workload, one thread:
lock fix 2.006 (shared PSO), 2.001 (own) -> 0.541, 0.585; on 8 threads 10.3 Mdraws/s (was 2.9)
The unchanged draw (static) holds: 0.044 -> 0.046 on the M3.
(cherry picked from commit 2ee3520ff104094afde523e2eebf7bc8a9a9626d)
(cherry picked from commit d00975ea7da92da4886a29f1ebda6397f64202b1)
|
||
|
|
e1c53c37ed |
A compute variant works out its heap tables once, and its commands take the heaps lock once
Each compute command whose layout binds the device's texture or sampler table read the layout again for those bindings and the table kind (allocating their lists), and took the device-wide heaps lock three times: for the highest texture ID placed and the texture table, for the sampler table, and in heap_sets::bind. - heap_sets.rs: TextureTableAt and SamplerTableAt work out from a layout where it binds the tables, over how many entries and of which kind, and keep each table's descriptor once read (the device makes each table once and never replaces it). HeapTables holds both; texture_table and sampler_table (render's calls, unchanged) build them per call as before. - The highest texture ID placed, for UnnamedTexturesPastCapacity, is stored under the lock as textures are placed and unplaced (DeviceShared::heap_textures_end) and read without it, so the notice is made at the same commands. - pipeline/objects.rs: VariantObjects::heap_tables makes HeapTables at a variant's first command; compute's record takes it there. TextureTable and SamplerTable borrow the bindings. - WorkCounts::heap_tables_worked_out counts the layout reads. The same descriptors, sets and notices. heap_sets::bind keeps its one lock. Check that fails without it: runtime_lane::resource_ids::a_variant_reads_its_layout_for_the_device_tables_once (four dispatches of a kernel reading a texture handle: [1, 0, 0, 0] layout reads; with the per-call form beside it, [3, 2, 2, 2]). Release, M3 Max, MoltenVK 1.4.2, host_ab encode, before (d6779a26d9) and after interleaved three times, us per dispatch (medians of 3 rounds; one thread, so no lock contention is measured): | workload | before | after | |---|---:|---:| | dispatch_handles | 1.075-1.115 | 1.047-1.076 | | dispatch_handles (process CPU) | 8.95-9.72 | 8.20-9.07 | | dispatch_static | 0.674-1.009 | 0.664-0.685 | dispatch_handles_rt_heap_tables_worked_out: 0.000 a dispatch after the first runs. Verified on MoltenVK: the runtime GPU suite 1505/1505; the validation runtime lanes 534/536 (the two failing the same at the base); resource_ids, heaps and argument-buffer lanes 153/155, the two (extended_range_two_planes::two_plane_heap_textures_read_and_write_as_metal_does, argument_linear_samples::heap_linear_samples_answer_as_slot_samples) failing the same at the base. (cherry picked from commit b9f35448fd3e947bb02a440a79eec2f9caf705ca) (cherry picked from commit c327b2e68c82f88698e85637569461b102bc51be) (cherry picked from commit c6ad3ecd67471216711b5410fbf35201c423f091) (cherry picked from commit 78be3664f4474a26221b82842cbe5c8df76fead3) |
||
|
|
2f033d3002 |
Take the device's Y'CbCr conversion for 4:2:2 twins and for YCbCr planes read in place
4:2:2 twins hold the device's own conversion where it has Metal's reconstruction; planes read
in place are sampled through the device's Y'CbCr sampler where the driver lays them out as the
surface does; RADV's 10-bit conversion recorded as reading codes as words. With development's
golden re-bless after the native landings. SEMANTICS 1911, ARTIFACT 477, RUNTIME 1683.
One work packet, landed as 6 commit(s) (a1088b2c2e..67dc5650e1 on archive/development-linear-2026-10-28-evening), in order:
* Hold a 4:2:2 texture's twin as the device's own conversion where it converts the format
A GBGR422 or BGRG422 texture reads a decoded twin of 8-bit codes on every device: Vulkan views
G8B8G8R8_422_UNORM and B8G8R8G8_422_UNORM only through a sampler Y'CbCr conversion, which no
pipeline's layout bakes. Until now the twin always held Metal's decode, (3c + n + 2) >> 2, computed
by the runtime's own kernel or on the CPU, even where the device converts the format itself.
Now, where the device converts the pairs' format with Metal's reconstruction (its optimal tiling
reports SAMPLED_IMAGE, TRANSFER_DST, MIDPOINT_CHROMA_SAMPLES and a linear chroma filter, and the
width is even), the twin holds the device's conversion:
- each decode pass copies the written rows' pairs out of the carrier into the scratch, then into
a per-texture image of the 4:2:2 format, and samples it through the device's conversion (the
identity model at full range) into the band's texels, which go into the twin;
- the kernel is the new bind::chroma_sample_module (ChromaSampleModule), a sample at each luma
texel's centre at level 0, each channel stored as roundEven(clamp(c, 0, 1) * 255);
- such a carrier takes no host or staging copies, so every write's decode is a GPU pass and no
texel of the twin is the CPU's decode;
- counted in WorkCounts::chroma_device_twins and chroma_device_decodes, and announced
decoded-texel-precision (the catalogue's cost text says so).
Elsewhere the twin keeps Metal's decode, as capability. The FAST-PATHS device-gaps table has the
row.
Venues (from the formats' features): MoltenVK 1.4.2 converts both formats (its single-plane 4:2:2
reconstruction is Vulkan's); lavapipe filters their chroma nearest only; RADV (Mesa 26.2.4, 780M)
reports neither format.
Verified:
- clippy -D warnings, plain and --cfg m2v_gpu, for metal2vulkan and metal2vulkan-runtime;
- chroma_decode unit tests (the sample module is valid on every committed profile), fast_paths,
the degradation catalogue tests, api_surface and api_signatures (table blessed: the new module,
ChromaDecode::format and the two WorkCounts fields);
- M3 Max (MoltenVK 1.4.2): tests::ycbcr_device::a_four_two_two_twin_holds_the_devices_conversion...
took the device route for both formats (twins 1, passes >= 2, no CPU decode, announced once);
chroma within 0.5000 codes of Vulkan's (3c + n) / 4 on 40 x 24 random pairs (the test also
prints how many chroma codes differ from Metal's; that line is compiled and clippy-clean, not
yet run);
runtime_lane::chroma_pairs (5 tests) pass, the read lane checking green exactly and red and
blue within 1/255 of Metal's on the device route;
- lavapipe (arm64 linux-gate, m2v_cpu_icd): the same runtime test and the five chroma_pairs lane
tests pass; no 4:2:2 texture took the device route (twins hold Metal's decode, exactly);
- RADV 780M: not run (host away).
docs/REFUSALS.md regenerated: unchanged. runtime-sources.sha256 updated; the RUNTIME_VERSION
bump is in the versions commit.
* Record that RADV's 10-bit Y'CbCr conversion reads codes as words
RADV has the same defect lavapipe has (RuntimeDriverDefect::TenBitCodesReadAsWords): a sampler
Y'CbCr conversion of G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16 reads each code's 16-bit word as a
16-bit UNORM value, its six unused low bits included, where Vulkan converts the 10-bit code as
c / 1023.
Evidence: a bare Vulkan probe on the Radeon 780M (RADV, Mesa 26.2.4) read luma code 1023 (low bits
0) through the identity model of a LINEAR image of the format as 0.999039, which is 65472 / 65535
and not 1.0. The optimal tiling's conversion of the format was not measured; the row is per
driver, as the defect table's rows are.
What changes: the AFFECTED table gains a MESA_RADV row, with no clean GPU. Nothing is refused.
- A 10-bit two-plane texture on RADV now converts through Metal's arithmetic. Before, RADV's
optimal-tiling device conversion (ycbcr_device.rs) took it, and that path was never measured on
RADV.
- The planes image of the next commit is not taken for 10-bit codes there.
The driver_defects test expectations (every committed RADV profile, Hawk Point's 780M) and the
docs that name the defect's drivers (ycbcr.rs, ycbcr_device.rs, docs/API.md) say RADV too.
Verified: clippy -D warnings (plain and --cfg m2v_gpu) for metal2vulkan, metal2vulkan-runtime and
metal2vulkan-validation; tests::driver_defects on the host. The RADV device itself was not run: the
host is away.
* Sample YCbCr planes read in place through the device's own Y'CbCr sampler where it has Metal's reconstruction
On an integrated GPU or a CPU device, a function that only samples a YCBCR8_420_2P or
YCBCR10_420_2P texture reads the planes in place through a uniform texel buffer. It converts and
filters them with Metal's fixed-point arithmetic in the shader. Where the device converts the
planes' 4:2:0 format as a linear image with Metal's reconstruction (midpoint chroma through a
linear chroma filter), rule 1 makes the device's own conversion the only form. So such a slot now
samples the planes through the device's sampler Y'CbCr conversion. Elsewhere the texel buffer
read stays, as capability.
Translator (metal2vulkan):
- bind::YCbCrPlanesSampler (new, non-exhaustive) holds the conversion: the codes' bits and the
surface's range and matrix. It also gives the image's format: G8_B8R8_2PLANE_420_UNORM, or
G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16.
- YCbCrInPlace::with_planes_image, ::sampler and ::planes_sampler. TextureShape::Texture gains
ycbcr_planes_sampler.
- RuntimeFact::YCbCrInPlace gains `device`: the device's sampler takes every sample of the slot.
It does not where a constexpr sampler has a border address mode, or a texel offset is placed by a
parent's size.
- VariantKey and LoweringInputs gain ycbcr_planes_sampled. The binder fills it from slots with
`device`, bound to a texture that holds the image, whose runtime sampler words have no border
mode on s or t.
- Such a slot is declared as a combined image sampler: ResourceKind::YCbCrPlanes and
BindingSource::YCbCrPlanes, written from WriteSource::YCbCrPlanesImage. Its immutable sampler is
the new vk::SamplerDesc::ycbcr: linear, clamp to edge, lod 0, and a new `ycbcr` field.
- Each sample (lower/sampler/in_place.rs device_sample) is OpImageSampleExplicitLod at level 0:
- a linear sample takes Metal's coordinate, with its texel offset moved in texels;
- a nearest one takes the centre of the luma texel Metal reads, clamped to the edge;
- pixel coordinates and the filter are known when the module is made (constexpr) or read from
the runtime word;
- a half result is rounded to a half, as every sampled texel's is.
- The texel buffer stays the slot's resource otherwise. The planes read use is tracked as before.
Runtime (metal2vulkan-runtime):
- YCbCrFormats queries the two 4:2:0 formats' LINEAR tiling: SAMPLED_IMAGE,
MIDPOINT_CHROMA_SAMPLES, a linear chroma filter, and the limits and
combinedImageSamplerDescriptorCount.
- YCbCrSampler::planes gives the conversion. It is None under TwoPlaneChromaMisplaced, and for
10-bit codes under TenBitCodesReadAsWords. holds_planes checks for an even size within the
limits.
- texture/ycbcr_planes.rs (new) makes a PREINITIALIZED linear image of the format over the planes'
bytes, and only in memory the runtime allocated. It is made only where:
- the luma plane comes first;
- the driver's PLANE_0 and PLANE_1 subresource layouts are the surface's offsets and pitches;
- the alignment, the type and the room within the buffer fit.
Its view and every immutable sampler of it share one VkSamplerYcbcrConversion
(Device::made_ycbcr_conversion, kept in the owned kernels' map), so the two are identically
defined (VUID-VkWriteDescriptorSet-descriptorType-02738). Its first move rides the next
submission (Fresh, never rebindable), and it is announced ycbcr-filter-not-exact.
- Fresh pages, no-copy pages and the caller's VkBuffer keep the texel buffer. An image bound to
imported memory starts UNDEFINED, and the in-place check covers that first move for single-plane
images only.
- The texture's facts state the image (with_planes_image). binding.rs writes the view in GENERAL
under the layout's immutable sampler.
- sampler_set chains the conversion into each SamplerDesc::ycbcr sampler. A non-pushed set 0
reserves combinedImageSamplerDescriptorCount descriptors per such binding.
- WorkCounts gains ycbcr_planes_images, ycbcr_planes_images_kept_{conversion,memory,layout} and
ycbcr_planes_images_bound.
Venues (from the formats' linear features):
- Radeon 780M (RADV, Mesa 26.2.4): reports the 8-bit route for rows 256 bytes apart. Its 10-bit
codes carry TenBitCodesReadAsWords (previous commit).
- MoltenVK 1.4.2: TwoPlaneChromaMisplaced.
- lavapipe: its 4:2:0 conversion is cosited only.
Measured before building, through a bare Vulkan probe on the 780M with 8-bit codes:
- luma centres within 0.0003 codes of Vulkan's model, and points between texels within 0.66
codes;
- Metal's conversion-then-filter differs by up to 54/255 between texels of random planes;
- GPU time, 3840x2160 composited into 1680x1050: 248 us against the texel buffer's 340 (1 pass),
741 against 1027 (3 passes).
The runtime's path itself is not measured on a device that takes it: the 780M host is away.
Docs: a FAST-PATHS device-gaps row (the device's route, where the texel buffer stays, and why);
the in-place paragraph; docs/API.md (the pipeline interface paragraph, and the notice's catalogue
entry); module docs (ycbcr.rs, ycbcr_device.rs, ycbcr_image.rs); the api_surface table
(YCbCrPlanesSampler N); api_signatures blessed.
Tests:
- bind::ycbcr_in_place::the_planes_sampler_is_the_conversion_word.
- bind::plan::slots::the_planes_image_variant_takes_a_slot_the_device_s_sampler_reads.
- tests::engine_ycbcr_in_place::a_planes_image_slot_samples_through_the_device_s_conversion: the
lavapipe and M3 profiles; linear, nearest, pixel, offset and runtime samplers, each half and
float. Each case links and validates, with one OpImageSampleExplicitLod. Border and repeat-offset
slots state device false.
- Lane runtime_lane::ycbcr_in_place::a_ycbcr_texture_s_planes_image_samples_through_the_device_s_conversion
covers surfaces whose rows are 256 bytes apart. Each in-place texture is counted exactly once,
as an image or by why not. Through the image, nearest samples are Vulkan's conversion within the
device's bound, announced; without it, Metal's texels through the texel buffer, unannounced.
Verified:
- clippy -D warnings, plain and --cfg m2v_gpu, for metal2vulkan, metal2vulkan-runtime and
metal2vulkan-validation.
- Host, plain target, the touched selection (ycbcr, fast_paths, api_surface, api_signatures,
codec, slots, api_tests, the inputs encoding, sampler, ash_interop, driver_defects, degradation,
vk tests): 408 run, 407 passed. The engine test's half cases failed, because a half result was
an f16 where a sample holds it widened. They now take narrow::round_texel, and the in-place
engine tests pass, 4 of 4.
- M3 Max (MoltenVK 1.4.2), runtime and validation, ycbcr|chroma|driver_defects|runtime_sources:
66 run, 64 passed. The planes image test counted [0, 1, 0, 0] for both surfaces (kept for the
conversion: TwoPlaneChromaMisplaced), bound the texel buffer and read Metal's texels. The two
failures:
- the runtime-sources pin, re-pinned in the versions commit;
- runtime_lane::ycbcr_textures::a_ycbcr_sample_through_an_unmeasured_filter_is_announced
(anisotropic through a constexpr sampler), which fails the same way at the base, as
|