ca5fecf79c8a5d3cec9e48125c8b6c52e66ef1ff
1456
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
ca5fecf79c |
State the extended-range conversions' bounds in device-pack-conversion's runtime doc
The runtime's Degradation::DevicePackConversion doc stated only the normalized pack and unpack bounds, though the kind is also announced for every conversion of an extended-range, padded 10-bit or bfloat texel. It now states those bounds too, as the translator's PrecisionNote doc and docs/API.md's catalogue already did: a linear value within one f32 ulp of Metal's, an encoded code within one (R10Unorm_X6_sRGB's and RGB10A2Unorm_sRGB's colour within two below 0.0031308), and a half result within one half ulp. device-rounded-resolve's text already states its bound (one code, an sRGB channel two), and the M3 measures within one, so it is unchanged. Doc-comment only. (cherry picked from commit 192b37ed75b28c0a12e07987ca98768bb264f31d) |
||
|
|
ef2a4e9da8 |
Check in-place YCbCr gathers against Metal's rows and the lane's model
Evidence for the in-place gather: a fixture, four conformance cases and a
device lane test.
- fixtures/public/engine/ycg_sample_gather.metal (ours, compiled by
scripts/regen-air-fixtures): `ycg_float` and `ycg_half` sample, gather
red or gather blue as lane `i % 3` asks, through one runtime sampler, the
shape whose gather used to keep the slot off the in-place form.
- conformance ycbcr_gathers: `ycbcr-gathers-{edge,zero,white,repeat}`, one
linear sampler state each, over a 420v and an x420 surface of 12 x 6
noise texels, float and half, at positions a third of a texel apart from
a texel before the texture to one past it (texel centres included, where
a gather's footprint turns). Recorded on Metal and replayed on the
runtime in a following commit.
- runtime_lane::ycbcr_in_place: on a device whose memory is the host's, a
dispatch of `ycg_float` binds the planes and converts nothing, its
samples are Metal's filter and its gathers Metal's texels at the four
taps (the lane's model), and no filter notice is announced.
The golden tables and the compile census gain the fixture's rows when
they are re-blessed on development.
(cherry picked from commit a561a4b56456c0d1d4dc4ca419dc9cb6cfe1f3f7)
|
||
|
|
6eb2a66d6e |
Gather a two-plane YCbCr texture's planes in place
A function that samples a YCBCR8_420_2P or YCBCR10_420_2P texture and also gathers it (a probe asking each lane for a sample or a gather of red or blue) lost the in-place form for the whole slot: `in_place_sample` built no gather, so the gather set `in_place.blocked`, the slot bound the converted image, and on MoltenVK its linear samples went through Metal's sampler of RGBA16F-like texels: `ycbcr-filter-not-exact` (Half/FloatSampleFilter), and through a pixel sampler `pixel-sampler-scaling`. Those notes killed three of a consumer's strict Mac tests. What: the in-place form now builds a 2D gather of a component without comparison, constant offset or none, through a constexpr sampler (either filter: a gather follows none) or a runtime one. The gather is the extended-range emulation's `gathered` over `Decode::InPlace` taps: the four taps of the linear footprint, each the texel Metal reads there (the border texel past a border axis), in Vulkan's order, a runtime sampler's word mapped as a 4:2:0 texture addresses. A gathered slot stays off the device's own Y'CbCr conversion (`device: false`): VUID-RuntimeSpirv-OpTypeSampledImage-12206 admits only samples through it. No Quad routine for a gather. SEMANTICS_VERSION 1962 (facts and modules of gathered slots change). Tests (engine_ycbcr_in_place): every gather of each component of random 8- and 10-bit planes under three conversions, constexpr and runtime samplers, float and half, on the lavapipe and moltenvk-m3 profiles, equals Metal's model taps on the interpreter; a gather states the in-place fact with `device: false`; a function that samples and gathers through one runtime sampler notes FloatSampleFilter/HalfSampleFilter on its image compile and states the fact, and its in-place compile builds both forms and notes neither those nor PixelSamplerScaling. Device evidence against Metal's rows follows with the fixture and conformance cases. Docs: API.md and FAST-PATHS (in-place reads and the planes-image row), RuntimeFact::YCbCrInPlace, InPlaceReads, the runtime README. (cherry picked from commit b95b95a355f9a8ff4c1bfacbf329a728c4896db9) |
||
|
|
2e2c1ec056 |
Leave fneg, fabs, floor and ceil unnoted where the M3's Metal keeps their denormals
MoltenVK on the Apple M3 Max runs a SPIR-V `OpFNegate`, `FAbs`, `Floor` and `Ceil` through Metal's own compiler, which keeps a denormal operand of negation and absolute value and reads it as the zero of its sign in floor and ceil, as plain Metal does. The translator noted `DeviceDenormals` on every such operation, so a strict consumer died on a kernel that negates a float though the answer is Metal's. What: a new APPLE9-only `DriverDeviation::MetalUnaryDenormals` (and its `VkProperty`) on the moltenvk-m3 profile. A function whose float negation, fabs, floor or ceil the deviation covers records no `DeviceDenormals` for them and requires the property instead; fabs keeps its Metal-own exemption on every other profile, and trunc, round, rint, fract, sign and the rest stay noted (the lane does not check them). `ARTIFACT_FORMAT_VERSION` 486 (the property's tag), `SEMANTICS_VERSION` 1961 (notes and requirements change). Evidence: the committed MoltenVK M3 observations of the four denormal cases (nan_denormals, nan_denormals_fast, dfl, dfl_fast) hash equal to Metal's on the same M3. The float_denormals gate lane now checks probe rows -a, 0-a, -(a*b), fabs(a), floor and ceil where the deviation is taken, and asserts the module requires the property exactly then; the arith unit test covers each op under each fast and unary setting. Device runs follow on the GPU job for this stack. Docs: FAST-PATHS row on device denormals, API.md degrade catalogue, driver_facts' measurement paragraph, api_signatures.tsv; refusal surface and signatures checks pass. (cherry picked from commit f3f65903a395b46b3a8001c4259bb1e4bb7bc203) |
||
|
|
a139f39c89 |
Note a texel centre's denormal only under an address mode that parts texel -1 from texel 0
What: a nearest pixel-coordinate sample at its texel's centre, floor(x) + 0.5, records
DeviceDenormals for that floor: Metal's sampler reads a negative subnormal x as texel -1, where a
floor that flushes it (MoltenVK's) makes texel 0. Clamp to edge, mirror clamp to edge and mirrored
repeat read texel -1 as texel 0, so the note now holds only where the s or t mode is repeat, clamp
to zero or clamp to the border:
- a constexpr sampler decides it from its (mapped) s and t modes at compile (centre_parts);
- a runtime sampler slot's clauses add, per axis, a test of the bound sampler's word that the
axis's mode is none of the three. The word is read through a new note-only key,
SpecKey::BoundSamplerWord(slot): no constant declares it and no pipeline's key carries it, so
the mode adds no VkPipeline variant (the alternative, the ADDRESS bits in SamplerState's fields,
would split every runtime pixel sampler slot's pipelines by mode on every device). The plan
records its value beside the pushed specialized values (slots::record_noted, given by
BindingPlan::specialized_value), SpecClause::tests_bound_values counts it, and the runtime's
degrade_bound_values announces such a clause at each draw or dispatch, as it does for a pushed
format class. The runtime's notice reads "under the formats and samplers it binds".
- NoteOn::BoundSampler is the lowering's name for the key.
Why: reims-vgpu's strict Mac tests died on device-denormals from a nearest clamp-to-edge pixel
sampler, under which the device's texel is Metal's.
Tests: tests::engine_sample_coordinates::a_texel_centre_notes_denormals_only_where_its_mode_
parts_texel_minus_one (constexpr array samples per mode on every committed profile; the runtime
slot's clauses evaluated over every s/t mode pair, and never under a normalized state);
cache::tests::the_version_485_member_round_trips;
runtime_lane::pixel_samplers::a_texel_centre_s_denormals_wait_for_a_mode_that_parts_texel_minus_one
(device: nothing at making, nor under clamp to edge and mirror clamp to edge, once under clamp to
zero). Conformance: four cases pixel-samplers-subnormal-{edge,zero,border,mirror}, the RGBA8Unorm
texture through a nearest filter at sixteen coordinates of subnormals, zeros and -2^-126 on each
axis, recorded on Metal in a following commit.
Versions: ARTIFACT_FORMAT_VERSION 485 (the SpecKey variant), SEMANTICS_VERSION 1960 (the clauses).
api_signatures gains the variant. Docs: API.md and FAST-PATHS.md (device-denormals), the
DeviceDenormals, SpecKey, SpecClause and plan rustdoc.
(cherry picked from commit 624008697abfab1dbb3039a926902373b84e1268)
|
||
|
|
308e0728b8 |
Record the M3's heap half reads in the MetalHalfConversion measurement
What: the MetalHalfConversion paragraph of the driver-facts record now states the gate lane's result on the M3 Max: a heap's `half` read of every code of the five forms it holds by raw texels (BGRA10_XR, BGR10_XR, R16Bfloat, RG16Bfloat, RGBA16Bfloat) is the nearest even half of the same read as float, and the slot's half read, in all 262,144 channels of each. Why: the previous commit counts a decoded texel's half rounding as the measured conversion; this is the run that measures it. Verified (potluck m3-max-438, --gpu m3max, MoltenVK 1.4.2, at 020e8fd919): runtime_lane::(heap_extended_reads|half_conversions|alpha_in_red)::, 17 tests, 17 passed; HEAP-HALF-ROUNDING lines: 0 of 262144 channels for each form, note false. CPU job m3-max-352 (same commit): clippy --all-targets --all-features -D warnings plain and --cfg m2v_gpu, the touched core tests (99 passed) and the gpucfg validation build. (cherry picked from commit f8e0383243bdfbc80d4dae0c98a53d123ff6c95a) |
||
|
|
5e87ad8325 |
Bump SEMANTICS_VERSION to 1959: a texel's half rounding counts as measured on MetalHalfConversion profiles
A cached artifact of an unchanged module and profile now carries other precision notes and requirements on moltenvk-m3's identity (NativeHalfConversion dropped, VkProperty::MetalHalfConversion required) though its SPIR-V is the same, so the key moves. Verified: the bump alone. (cherry picked from commit 020e8fd919063865be6537f5b09e74968f25f8c6) |
||
|
|
6e63f015b5 |
Count a texel's half rounding as the measured conversion on MetalHalfConversion profiles
What: narrow::round_texel rounds through round_measured, so in QuantizeForm::Converted the conversion pair's narrowing is recorded as measured. On a profile that takes DriverDeviation::MetalHalfConversion (MoltenVK on the Apple M3 Max's macOS 27 identity) a texel's half rounding no longer records PrecisionNote::NativeHalfConversion. That covers a texel the module decodes itself (extended_range::decode) and a merge of texels (a heap read's phi of its fetched texel and its decode routine's), as well as an image instruction's. The module requires VkProperty::MetalHalfConversion instead. The note stays for roundings by narrow::round: half operations and functions computed in float, filter sums, packs and the rest. Other profiles never read the measured set, so they are unchanged by construction. The SPIR-V is unchanged too: round_measured emits the same pair. Why: reims-vgpu's strict Mac tests die on native-half-conversion at a kernel that reads an argument buffer's texture as half (their ycbcr_probe.metal read_held). Every heap half read carries the decode routine of the seven extended-range/padded/bfloat forms, and its merge, so it recorded the note even for a BGRA8Unorm texture. The note states that the device's conversion may differ from Metal's half(float), and MetalHalfConversion measured that conversion as Metal's half(float) for loaded and computed floats. Where Metal's half texel is not the nearest even half of the texel's value, the access's own note states it: HalfTexelConversion (outright for a heap element, by the bound class at a slot) or DevicePackConversion (a decoded texel). Verified: - New core tests heap_half_texels_round_by_the_measured_conversion (heap half read, nearest sample and gather on moltenvk-m3: no note and the property with the deviation, the note without it, HalfTexelConversion kept; a linear sample's filter sum keeps the note on both) and decoded_half_texels_round_by_the_measured_conversion (a slot's half read of each extended-range form: the same, DevicePackConversion kept). Both fail with round_texel's old rounding and pass with the change; half_conversions_are_metals_where_measured still passes. - Notes of every public fixture subject on moltenvk-m3, lavapipe and nvidia-rtx5080-laptop before and after (a temporary dump over the golden-hash subjects, 2,915 per profile): 7 change, all on moltenvk-m3, each losing NativeHalfConversion alone and keeping HalfTexelConversion (a8r_buffer_read_half, hlf_half_buffer, selected_member_texture and kernel_texture_variant_leftovers, the .ll and .air.ll forms). - reims's ycbcr_probe read_held on moltenvk-m3 through the CLI: [DeviceNanEncoding, HalfTexelConversion, NativeHalfConversion] before. - Pending: the M3 lane heap_half_reads_of_every_code_round_their_float (new) and the lanes that read the note (alpha_in_red now requires a8r_buffer_read_half to be Metal's there). Docs: the PrecisionNote, DriverDeviation and VkProperty rustdoc, API.md's native-half-conversion exemption, the driver-facts record, narrow's docs. (cherry picked from commit 384734851de7b2f1a3106355a6c941080f097be4) |
||
|
|
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)
|
||
|
|
6be8045e7c |
Add a draw's resident geometry writes once per identity
GeometryWrites::add holds what an instance's draws wrote before their fragments, which a later draw's fragments touching it wait for. It walked every use of every draw, the uses of what the encoder made resident included. As with UnorderedWrites (de4b3e9984) and IndirectReads, those come first and are the same for every draw of one identity (binding::ResidentPrefix). - The new GeometryWrites::add_draw((uses, prefix)) adds the uses after them at every draw. - It adds theirs only where the last add_draw of the instance began with another identity. Otherwise they are held already, merged or not, and adding them again changes nothing barrier_before() reads. - The writes, and the identity with them, begin anew with each instance (GeometryWrites::new). - Builds with debug assertions check that every skipped write is held, by range and by its access in the stages before the fragments. The count, WorkCounts::resident_uses_geometry_writes, moves onto the walk's branch. Verified (CPU job, debug): - tests::tracker::draws_add_the_geometry_writes_of_what_their_encoder_ made_resident_once_by_identity: walked once past ENTRIES_PER_KEY draws; a later fragment read waits for the writes; another identity walks its own, and the first walks again after it; a new instance holds none. - Clippy, with and without --cfg m2v_gpu: clean. - Negative control, the identity compare dropped: that test fails. - tests::resident_uses checks the count with the others. It runs in the device suite at this stack's tip. Numbers (M3 Max, release, measured on 8de5619780 + this change, the same diff as here; base M2 = 8de5619780): - resident_draws N5000, marginal instructions a draw (30 frames less 10): entry own encoder 171,618 -> 141,699; entry own write 212,559 -> 182,658. Frame median 58.6 -> 47.1 ms and 76.8 -> 66.9 ms. - The walk's count over 2 frames: resident_uses_geometry_writes 50,020,000 -> 10,004 (encoder) and 50,030,000 -> 10,006 (write); the other walks' counts unchanged. - draws.10k runtime leg: 8355.1 / 8355.3 -> 8348.5 / 8354.1 instructions a draw. (cherry picked from commit 6f52bc5a6d8798a85cdbde94c0844783f9569390) |
||
|
|
5a86608e82 |
Add a draw's resident indirect reads once per identity
IndirectReads::add, the reads an instance's draws made as indirect arguments (which a later draw of the instance writing them waits for), walked every use of every draw, the uses of what the encoder made resident included. As with UnorderedWrites (de4b3e9984), those come first and are the same for every draw of one identity (binding::ResidentPrefix). - The new IndirectReads::add_draw((uses, prefix)) adds the uses after them at every draw. - It adds theirs only where the last add_draw of the instance began with another identity. Otherwise they are held already, merged or not, and adding them again changes nothing written_in() reads. - An instance's reads begin anew with it (IndirectReads::new at each instance), the identity with them. - Builds with debug assertions check that every skipped read is held, by range and access (KeptUses::holds). The count, WorkCounts::resident_uses_indirect_reads, moves onto the walk's branch. Verified (CPU job, debug): - tests::tracker::draws_add_the_indirect_reads_of_what_their_encoder_ made_resident_once_by_identity: walked once past ENTRIES_PER_KEY draws; a later write meets the reads; another identity walks its own, and the first walks again after it; a new instance holds none. - Clippy, with and without --cfg m2v_gpu: clean. - Negative control, the identity compare dropped (any identity taken as held): that test fails. - tests::resident_uses checks the count with the others. It runs in the device suite at this stack's tip. Measured, M3 Max, release, resident_draws lane at N 5000 (job m3-max-518; the parent de4b3e9984 in job m3-max-348), marginal over 100,000 draws: | | parent | this commit | |---|---|---| | own encoder, instructions a draw | 196,489 | 171,618 (-12.7%) | | own encoder, cycles a draw | 51,823 | 40,937 | | own write, instructions a draw | 237,561 | 212,559 (-10.5%) | | resident_uses_indirect_reads, 2 frames | 50,020,000 | 10,004 | The count is now one walk of the 5,002 uses a frame, where they are made. draws.10k runtime leg: 8355.1 / 8355.3 instructions a draw, against 8375.7 / 8375.7 at the parent. (cherry picked from commit 8de5619780059340abb26da82d670e84581521d5) (cherry picked from commit ac61b6de79f929614f143c166d411df7606138aa) |
||
|
|
1181ebe77f |
Add a draw's resident writes to the unordered writes once per identity
UnorderedWrites::add walked every use of every draw, the uses of what
the encoder made resident included. Those come first and are the same
for every draw of one identity (binding::ResidentPrefix): one key,
range, stages and access types each, a function of the plan and the
residency's generation alone (command_uses_into). The new
UnorderedWrites::add_draw((uses, prefix)) adds the uses after the
prefix at every draw. It adds the prefix's writes only where the last
add_draw since the last clear began with another identity. Otherwise
they are held already, merged or not, and adding them again changes
nothing written() reads.
- clear() (a memory barrier) forgets the identity, so the next draw
adds them again.
- A draw of another identity adds its own, and becomes the identity
held.
- Builds with debug assertions check that every skipped write is held,
covered by range and access.
render.rs and render/draw_again/rebound.rs call add_draw where the draw
has a prefix and count the resident uses only where it walked them
(WorkCounts::resident_uses_unordered_writes). Tile dispatches keep
add.
Verified:
- tests::tracker::draws_add_the_writes_of_what_their_encoder_made_
resident_once_until_a_barrier: walked once past ENTRIES_PER_KEY
draws; the writes are read; after a clear they are walked again and
read again; another identity walks its own, and the first walks
again after it. 65/65 tracker tests pass, CPU, debug.
- Negative control, the reset in clear() removed: that test fails at
the debug check ("an encoder added a draw's writes by their identity
less than its uses").
- tests::resident_uses checks the new count with the others: 0 for a
draw that keeps its uses, more where they were made again. It runs
in the device suite at this stack's tip.
Measured, M3 Max, release, resident_draws lane at N 5000 (job
m3-max-348; the parent 8e4e904fb6 in job m3-max-273), marginal over
100,000 draws:
| | parent | this commit |
|---|---|---|
| own encoder, instructions a draw | 236,696 | 196,489 (-17.0%) |
| own encoder, cycles a draw | 65,573 | 51,823 |
| own write, instructions a draw | 277,582 | 237,561 (-14.4%) |
| resident_uses_unordered_writes, 2 frames | 50,020,000 | 10,004 |
The count is now one walk of the 5,002 uses a frame, where they are
made.
draws.10k runtime leg: 8375.7 / 8375.7 instructions a draw, against
8387.6 / 8395.8 at the parent.
(cherry picked from commit de4b3e99842757dbfd023b2e55b7b11d6158f6b5)
(cherry picked from commit cd699661642fbb21444d09e48dc3d5be6218f5ba)
|
||
|
|
23f8b141a1 |
Count the resident uses each per-draw tracker walk walks
A render draw walks every one of its uses in four trackers: - UnorderedWrites::add (the writes no memory barrier orders yet); - IndirectReads::add (what the instance's draws read as indirect arguments); - GeometryWrites::add (what they wrote before their fragments); - GeometryWrites::barrier_before (the check against those). That includes the uses of what the encoder made resident, which come first and are the same for every draw of one identity (binding::ResidentPrefix). At N resident resources each walk is N uses a draw. Four WorkCounts fields count the resident uses each walk walked, so the memos that follow can show what they remove: - resident_uses_unordered_writes; - resident_uses_indirect_reads; - resident_uses_geometry_writes; - resident_uses_geometry_checked (a rebound draw's check whether it may rebind included). They are counted at the call sites in render.rs and render/draw_again/rebound.rs, and nothing is counted where a draw has no such uses. The public surface grows by the four fields (api_signatures.tsv blessed); nothing breaks for a consumer. Measured, M3 Max, release, resident_draws lane, N 5000, 2 frames with the counter dump (job m3-max-273): - entry own encoder: 50,020,000 a walk, 5,000 a draw for each of the four (resident_uses_made 10,004); - entry own write: 50,030,000 a walk. Marginal cost (30 frames less 10, over 100,000 draws), unchanged by this commit's count: - own encoder: 236,696 instructions a draw; - own write: 277,582 instructions a draw. A Time Profiler run of the same lane (x3's tip with UnorderedWrites::add kept out of line, job m3-max-215) put the four walks at about 56% of the encoding thread at N 5000 own encoder: UnorderedWrites::add 17.2%, IndirectReads::add 15.9%, GeometryWrites::add 14.4%, barrier_before 8.9%. On draws.10k they are 0.5%, 0.4%, 0.6% and 0.3%. draws.10k runtime leg: 8387.6 / 8395.8 instructions a draw, against 8334 to 8337 at the parent. The 4 counts, the guard and the prefix look-ups cost about 55 instructions a draw on that path. The memos that follow move each count onto its walk's own branch. (cherry picked from commit 8e4e904fb6143f6a71ac6a5cda8422ae8adcb889) (cherry picked from commit 84e6d9d6a40c6fe3ddee07c3171df52e95b4aad5) |
||
|
|
c52d0e8d48 |
End the auto-trait walk of an object's fields at the device's resource IDs
A program's crate proves Send and Sync of the runtime's objects at rustc's default recursion limit of 128 (tests/consumer_auto_traits.rs). Checked one object a crate at each limit (-Zcrate-attr=recursion_limit, M3 m3-max-827 at cd7b2a7e74), a Mutex<Option<ComputeCommandEncoder>> needed 124, four levels from failing; VisibleFunctionTable 115, a blit encoder 114, the pipeline states 113 and 111, Library and Function 109, Device 92, most other handles 95. The reported walks run through ResourceIds: a function's holds, a pipeline state's numbered samplers and every ID's hold reach the device's ID table, and from it, through its holders' weak references to textures, samplers, pipeline states, libraries and functions, nearly every other object. ResourceIds's Send and Sync are now written out. A constant proves each field Send and Sync in this crate (at its limit of 256), its pattern naming every field, so a field added fails it until it is proved too, and the impls claim nothing it does not check. A consumer's walk ends at the table. Verified: nothing yet; the M3 clippy and the per-object limits follow. (cherry picked from commit 12ef2e3078114a240233c0375df7f7e3173f1a76) |
||
|
|
8fcff2117f |
Put a host step's copy of a chunk's records off where they changed at two steps in a row
On the 5080, a page whose GPU-written records change at every frame (replayed_frames at K=0, 5000 records, CHANGE_EACH) paid about 0.9 ms more a host step than the baseline: base 19.15 ms, the tip 20.05, means of 3 interleaved runs of 22 warm frames each (b5080 entry icb-p-010218). The same tip with the host step's keeping cut off (no comparison, no copy) ran 19.31. perf of the steps thread put the difference in memmove: each step copied every chunk's records, 11 MB, into the copy the next step compares with, 575 KB a chunk, past the caches (h 501 Mcycles of memmove against 416 with no keeping). The comparison itself is a few hundred microseconds less than that and the single read (ff4610cd46) already left one read a record. A host step that records inline now copies a chunk's records only where it needs them (kept_commands::StepCopy, held in each chunk's state beside the bytes it last read): - where the records hold the bytes the last step read, it records from those bytes and copies nothing (ReadFrom::Held); - where they changed since, it copies them again, as before; - where they changed at the step before too, it reads them in place, record by record, as an execution that keeps nothing does (ReadFrom::InPlace, RecordSource::Storage), and copies them at one step in eight only (COPY_EVERY), each chunk at a step of its own among the eight, until a comparison finds them as the step before read them. A CPU write to the chunk, or a recording of it kept or forgotten, starts it over. So records that change at each step are copied for an eighth of their chunks a step, and a chunk whose records stop changing is copied again within eight steps and compared at the next. What a step keeps is unchanged: a chunk is kept only where its records compared equal, byte for byte. WorkCounts::host_step_chunk_copies_put_off counts the chunks read in place. Tests: kept_commands::tests::records_that_change_at_each_step_are_copied_at_one_step_in_eight_a_chunk (the schedule: chunk 0 copied at steps 0, 1, 10, 18, 26, chunk 7 at 0, 1, 3, 11, 19, 27, one chunk in eight a step from step 3, a held comparison and a write start it over). The kept-steps lane's changing case asserts each chunk's copy put off from the records' second change on, each record still read once (indirect_record_bytes_copied), the pixels a fresh page's, and that once the records hold again a step within ten records apart and keeps every chunk, the next running them kept. replayed_frames' split prints host_step_chunk_copies_put_off and indirect_record_bytes_copied. Verified: nothing yet; the M3 clippy, units and lanes, the negative control (always copy) and the 5080 timings follow. (cherry picked from commit cd7b2a7e74f2a6aeef4e8080689bb4bab50c0a2f) |
||
|
|
2e04276d2b |
End the auto-trait walk of a segment's work at Deferred, in place of the command buffer's state
The command buffer's StateLock (65d9d241fe) did not bring tests/consumer_auto_traits.rs back under rustc's default recursion limit (M3 job m3-max-712: clippy plain and --cfg m2v_gpu still fail, recursion_depth_exceeding_limit on Send of a Mutex<Option<ComputeCommandEncoder>>). The walk it reports runs from the compute encoder's core through its segments into their work and round it: EncoderCore, Vec<Segment>, Segment, Deferred, Arc<LoopCheck>, LoopCheck, Vec<Piece>, Piece, Deferred, and on. The state is one way into that work among several, so StateLock goes. Deferred's Send and Sync are now written out: each variant holds one Arc of its work, which is Send and Sync for every work that is both, and a constant proves that of each variant's work in this crate (at its limit of 256), its match naming every variant, so a variant added fails it until its work is proved too. A consumer's walk of any segment's work, from an encoder, a command buffer's recordings or a loop check's pieces, ends there. Verified: nothing yet; the M3 clippy (workspace, plain and --cfg m2v_gpu), rustdoc and the test crate's margin at lower recursion limits follow. (cherry picked from commit 56620f6a71edac26850357a386e4cec98bb0173d) |
||
|
|
7e9e6a1485 |
End the auto-trait walk of a command buffer at its state, at the default recursion limit
A program's crate proves Send and Sync of the runtime's objects at rustc's default recursion limit of 128 (tests/consumer_auto_traits.rs). Since the batch footprints kept apart from the state (the recordings and batches behind a Revised revision), the walk from a compute encoder held in a Mutex<Option<_>> runs past it, through its command buffer's state and down the recordings: consumer_auto_traits fails to build (recursion_depth_exceeding_limit, denied by -D warnings) under clippy plain and under --cfg m2v_gpu. CommandBufferShared::state is now a StateLock, a Mutex<State> whose Send and Sync are written out: a Mutex<State> is both for every State: Send, and a constant makes the compiler prove State: Send from its fields inside this crate (at its own limit of 256), so the impls claim nothing it does not check, and a field added to State is checked by the same proof. A consumer's walk ends there. StateLock derefs to the Mutex, so every lock site is unchanged. Verified: nothing yet; the M3 clippy (plain, workspace, all targets; and --cfg m2v_gpu), rustdoc and unit job follows. (cherry picked from commit 65d9d241fe731a39767fc3cbde95cfc189735a42) |
||
|
|
2d5e958cd0 |
Hold a footprint's segment probes behind a trait object
Clippy at ae5b372e7a (m3-max-622): consumers' proofs that the runtime's types are Send overflowed the recursion limit (examples/queue_share.rs's spawn, tests/consumer_auto_traits.rs's Mutex<Option<ComputeCommandEncoder>>): c1557efe2b made each command buffer's kept footprints hold their segments' work (Deferred) and step inputs, a second path to those types from every command buffer. A probe now holds a boxed Fn + Send + Sync that asks them, which ends the auto-trait proof there. (cherry picked from commit bcf80bd496254457f154aed8e587bf2d84176e36) |
||
|
|
40e884bd85 |
Box the kept arm of Keeps and read a step's copies as fixed-size records
Clippy (m3-max-586 at ff4610cd46): Keeps::Kept was 784 bytes against 24 for Inline (large_enum_variant), and chunks_exact of a constant length is as_chunks. Behaviour is unchanged. (cherry picked from commit ae5b372e7a66aac5ea762ae4c020abd915e0ee24) |
||
|
|
3ab5303945 |
Have a host step that records inline read its records once, into the copy it keeps
A step whose records change at each frame copied every chunk's records for the next step's comparison (written_bytes_into) and then read each record again to decode it (record_now): 11 MB copied twice a frame on a page of 5000 commands. On the 5080, three interleaved runs at K=0 with records changing every frame stepped 19.6 ms on average against 19.0 ms at 04115e977f, with libc's copy at 13.4% of the steps thread's cycles against 11.2%. steady now hands such a step StepReads, what it reads its records into, chunk by chunk: the bytes the last step read where it has them, else a fresh copy, and a chunk whose kept recording's records hold reads those. The inline recording decodes its records from those copies (IndirectCommandBuffer::written_records_in), and keeps them for the next comparison once it recorded. keeping answers Keeps: kept, or inline with or without reads. WorkCounts::indirect_record_bytes_copied counts the bytes copied out of a buffer's record storage. The kept_steps lane's changing frames now expect each record copied once (DRAWS x COMMAND_BYTES); copying them again besides fails it. Not built or run yet. (cherry picked from commit ff4610cd4660b94835af7841e24114d6ee89fae2) |
||
|
|
cda1d778de |
Read a batch's kept footprint without its command buffer's state lock
On the textured page (5001 GPU-written commands, 5001 resident textures) the M3 sample shows the scheduler thread waiting in CommandBufferShared::footprint for a command buffer's state lock in 1761 of its 6836 samples (26%): each pass's ask of a kept footprint took the lock to check what it was built from, while a host step's draws and commits' work take it. The recordings and the batches, which every footprint is built from, are now Revised parts of the state: every mutable access moves one revision they share, an atomic the command buffer's Footprints hold apart from the state with the kept footprints. A kept footprint stands where the revision is the one it was built at and each of its segments' probes gives the answers it gave then (the work's gpu_written, rewritten, outgrown and holds, and whether a rerecord is due): those, with the segment's fields that the revision covers, are everything the share a segment takes turns on, so the check is exact. A build still gathers under the lock and keeps its result only where the revision did not move meanwhile; an ask that finds the lock taken counts WorkCounts::footprint_lock_waits. The device test footprint_locks asks for a kept footprint while the state is locked and expects the same footprint back at once, with no build and no wait, then a build after another encoder ends into the batch. The lane split prints footprint_lock_waits. Not built or run yet: a CPU job (clippy, api_signatures) and a GPU job (the test, its negative control, the textured page's samples) follow. (cherry picked from commit c1557efe2b25a739a4947ddf2d42c57da2cc79b2) |
||
|
|
251bede077 |
Print the bind and residency counters in each replayed frame's split
root_table_ranges_noted, resident_uses_made and _gathered, resident_address_indexes_made, stage_tables_read, draws_rebound, draws_as_before, heap_tables_worked_out, host_range_lookups and argument_samplers_taken, beside the step's own: the textured page's step is to be split by what each command's binding does. (cherry picked from commit e3fc1bccb4834ff7ad7a30fb82454f21fa74d1e3) |
||
|
|
bce2855116 |
Say which draws indirect_draws_recorded counts and which it does not
It counts vkCmdDrawIndirect and vkCmdDrawIndexedIndirect only; a command a host step or a commit replays from an indirect command buffer's record is a direct draw. A consumer read its 0 beside 5001 records read as records resolving to nothing. (cherry picked from commit 517d2d270dd9a167b9aaf916cb4ea7bd8af085a6) |
||
|
|
2ddd9a8c7a |
Bring the textured page's library trait into scope and pass its instances as u32
The first build of replayed_textured.rs (m3-max-530) failed: new_library_with_air is AirLibrary's, and draw_primitives takes a u32 base instance. (cherry picked from commit 742498ebd6a30c8f87f6feb2921ad5ed9e2d4c60) |
||
|
|
3550112c29 |
Time a replayed page whose commands each bind their own argument buffer and texture
The host-replayed step a consumer measured costs about 14 s a frame on a page of 5001 GPU-written commands, each drawing with a texture of its own, under a residency of 15018 buffers and 5001 textures; replayed_frames' page binds no buffer per command and keeps one kind of resident. The owned fixture icb_vertex_encode_textured has each command set its fragment buffer to an argument buffer of its own (through a slot table of addresses), whose entry names its texture, and replayed_textured_frames times that page's frames as replayed_frames does, with REPLAYED_TEXTURED_DRAWS and REPLAYED_TEXTURED_BUFFERS setting the counts. replayed_frames' timing loop is now time_frames, which both use. Ignored measurement; not run yet (built and run on the M3 next). (cherry picked from commit 71890e856e34894733ef68fe61526a2ea2ffd177) |
||
|
|
44ae958d95 |
Name the summary a segment's footprint share takes SegmentShare
Taken, the name d862eadd34 gave it, is already imported into command_buffer/mod.rs (rebind::Taken), which failed the build (E0255). Verified: the M3 CPU job's build failed on the clash; the job that follows rebuilds. (cherry picked from commit 5d8a92a68c40604e3d32becc41a11d5d5be989ec) |
||
|
|
44c2bf6614 |
Print the scheduler's passes and the footprints built in each replayed frame
The replayed-frames lane's line gains scheduler_passes and footprints_built, so a frame shows how many passes looked at the held frame and how many footprints they built (CommandBufferShared::footprint keeps each batch's). Verified: cargo fmt; built by the M3 CPU job that follows. (cherry picked from commit 93a920c8cb3321b176566ff6d1d88d78cadbed4f) |
||
|
|
90edf6fd2f |
Keep each batch's footprint for the scheduler's order, built once from what it is built from
The scheduler's order across queues compares a held batch with each later queue's head by their footprints (scheduler/order.rs), and its memo lasts one pass: every pass, one at each commit and completion on any queue, built the held batch's footprint again, copying and sorting every use of its summaries under its command buffer's lock. On the replayed-frames page at 5000 resident pairs on the M3 (macOS sample, 4 s), that was 193 of the scheduler thread's 571 busy samples, and the host step's draws, which take the same lock, waited 137 samples for it. CommandBufferShared::footprint now keeps each batch's footprint (State::footprints) with what it was built from (FootprintSources), and a later ask takes the kept one while that holds: - The recordings' revision. State::recorded is a Parts, whose every mutable access moves the revision (DerefMut), so no change to an encoder's summary, a segment's recording or its bound (a host step's recording, a rebind's encoding again, a submission's scrubs and joins) leaves a kept footprint standing. - The batch's encoders (its range among the recordings). - Which summary each segment takes (Taken: a loop's laying, its recording, or the bound commit gave its host step): what may change while the recordings stand, as a route met since makes the GPU write what a segment's work reads or outgrows what commit recorded for good, or a recording falls due again. A footprint a segment's known uses join (Segment::known_summary, made from the device's aliases as they stand) is built at each ask, as before. A kept footprint is built from uses copied out under the lock (Footprint::gathered) and sorted without it (Footprint::sorted), and is kept only where the revision did not move meanwhile. WorkCounts::footprints_built counts the builds; the scheduler shares the footprint (Arc). Lane: replayed_frames::a_batch_s_footprint_is_built_once_however_many_passes_look holds the page's frame for its host step while a bystander commits on another queue until the frame completes, and asserts at most one build a bystander command buffer and two for each of the frame's batches. Verified: nothing yet; the M3 jobs (clippy, the lanes, the negative control, the page's sample before and after) follow. (cherry picked from commit d862eadd34ac9f218de5c1a0952c2d22a1e5b0b8) |
||
|
|
347b9870c4 |
Keep a host step's chunks only where two steps read the records alike, and copy the residency once an execution
A host step that compared a kept chunk's records and found them changed recorded every chunk apart again, each into a secondary of its own, to keep: on the replayed-frames page at 5000 resident pairs on the M3 that cost 23.3 ms a step where the records changed at each frame, against 18.3 ms recorded inline (one binary, keeping switched off by a temporary patch). Phase timers put the difference in a copy of the residency per chunk and its drop (2.9 ms over 20 chunks), a fresh 11 MB copy of the records (about 1.1 ms more read), resolutions and contexts. Two changes: - RenderExecution::steady decides before recording. A step keeps chunks only where the records hold, chunk by chunk, the bytes a kept recording was made from or else those the last step read, compared whole. Else the execution records inline, as before keeping, and each chunk's records are copied into the bytes the last step read (IndirectCommandBuffer:: written_bytes_into, no new pages after the first), for the next step's comparison; a recording whose records changed is forgotten and counted recorded again. So records that change at each step cost the step one copy of them beside today's inline recording, and a step records apart and keeps only what two steps read alike. The chunk store keeps those bytes per chunk (KeptChunks::look_up_step, read); a chunk recorded apart keeps them as its recording's bytes, copying nothing again. - The chunks an execution records apart carry the encoder's residency from one to the next with the bind state (replay_encoder takes it owned), so an execution copies the command buffer's residency once, as one recorded inline does. The kept-steps lane now counts chunks recorded apart to keep (WorkCounts::kept_contexts_made): the first frame records inline, the second apart, the third runs kept; a records change records inline, then apart, then kept; another input's change records apart at once; and records that change at each step record inline each frame, keeping nothing, each frame drawing what a fresh page draws. Verified: clippy, plain and under --cfg m2v_gpu, on this Mac. The lanes and the page's timings on the M3 follow. (cherry picked from commit b9b1c0aab9728e57e517cb6f0abdfc1df44e9b03) |
||
|
|
bc36a0d0d1 |
Pin the kept-steps identity case's buffers at a granule, and let the replayed-frames lane change the records each frame
The identity case made the indices' buffer at an address the runtime picked (on a 16-KiB page) and pinned the buffer made again at it, which the address space refuses (OffGranule: a pin starts on a 32-KiB granule's first page). Both now pin at one granule address high in the space. REPLAYED_FRAMES_CHANGE_EACH, set with REPLAYED_FRAMES_CHANGE_AT, binds the indices' zero half and their first half in turn from that frame, so every frame's records differ from the frame before's: the case where a kept host step records every chunk again each frame. Verified: clippy of the validation crate under --cfg m2v_gpu on this Mac; the lanes run on the M3 next. (cherry picked from commit f453f57886dda7c0bf7a84f180bf6f061e35b975) |
||
|
|
9e4a72c1b4 |
Start each chunk a kept recording records apart from the bind state the chunk before it left
A chunk recorded apart ran through a replay encoder that started from an empty bind state (Arc::default) and bind memo, so its first draw listed the residency's used resources whole. The M3 run of the replayed-frames page at 5000 resident pairs (an instrumented release build, not committed) put 42.6 ms of the keeping frame's 53.4 ms host step in the chunks' replays, against 9.4 ms with no resident pairs: 20 chunks each paying the listing. A page whose records change every frame would pay that every frame. Now the chunks of one recording hand the bind state and memo on (Carried): the first chunk takes the device's spares, each chunk recorded apart starts from what the one before it left, its encoder ended first (LiveBind::end_encoder, what SpareLiveBinds::give did, now shared), and the last gives them back. The chunks share one residency, so only the first draw lists it. This serves commit's kept chunks of the CPU's records too. Verified: cargo check and clippy -D warnings, all features, plain and --cfg m2v_gpu, runtime and validation crates. Device timing not run yet. (cherry picked from commit e6eb7316454778ef0856eec59a144bffd256394c) |
||
|
|
4c1ee2c921 |
Change the records of the kept-steps lanes to the indices' zero half, which shows in the pixels
kept_steps' records case bound the indices two on, which the M3 run of 83a1365119 found draws the same pixels: the page's 5000 primitives cover the grid's hull either way, so the case's check that the change shows failed though the step recorded both chunks again and drew what a fresh page draws. The indices now hold a zero half after the scrambled one (ZEROS_AT): binding there moves every record's index address inside the same buffer, as before, and draws every primitive at vertex 0. The case of the buffer an index address names makes the second buffer all zeros for the same reason, and REPLAYED_FRAMES_CHANGE_AT binds the zero half too, so its pixel hash moves at the change. Verified: clippy -D warnings, all features, --cfg m2v_gpu, validation crate. Not run on a device yet. (cherry picked from commit 742eb863e2152b19297b07aebc34591b29203cd9) |
||
|
|
5b451a6508 |
Hold a commit's refused recording of a write-resident ICB's records for the host step
A commit that recorded an execution from the CPU's records and found a record it refuses failed there, though a route met after the commit may still write those records before the work runs: another queue's command buffer that the work waits for through a shared event, encoded and committed after this commit. Metal runs what that route wrote (the new probe crates/metal2vulkan-conformance/probes/icb_cross_queue_writes.m, M3 Max, macOS 27.0.1, validation off: `written` completes both command buffers with the kernel's green triangle; `unwritten` completes too, drawing the CPU's mismatched-format command as garbage). Dying there where Metal runs breaks the owner's rule 2. Now, where the commit's recording of a render pass's executions, or of a compute execution, is refused and the command buffer made one of the executed buffers resident for writing (Residency::writable_indirect_command_buffers), the segment is held for its host step (Prepared::held sets Segment::host), prepared as a step's: settled variants and made-ahead pipelines, its footprint bound. The step waits for the work before it, records from the records as they stand then, and fails the command buffer at that batch's submission only where they are still refused. A refusal of another buffer's records, and every valid recording, keep the commit-time path. Counted: WorkCounts::commit_refusals_held (api_signatures row). The lane test write_routes::a_refused_command_another_queue_writes_again_runs_what_it_wrote runs the probe's `written` shape: both command buffers complete, the centre is green, and the counter moved once. docs/API.md states the held refusal. Verified: clippy -D warnings, all features, plain and --cfg m2v_gpu, for the runtime and validation crates; api_signatures/api_surface 15/15. The lane test is not run on a device yet. (cherry picked from commit 83a1365119f1563ce45f97941a335ea119bc9efc) |
||
|
|
8a407884d0 |
Let the replayed-frames lane change the records the GPU writes from a given frame
REPLAYED_FRAMES_CHANGE_AT=n has the encoding pass bind the indices two on from frame n, so the GPU writes other records from then on: that frame's host step records its kept chunks again (WorkCounts::host_step_chunks_recorded_again) and the next keeps them. A measurement knob of the lane alone, as REPLAYED_FRAMES_RESIDENT is. Verified: clippy -D warnings, all features, --cfg m2v_gpu, for the validation crate. Not run on a device yet. (cherry picked from commit e32e3362ddf2cb8ae5c172d9e26f6da20242deb6) |
||
|
|
042ec0a481 |
Keep a host step's recordings of GPU-written render commands, compared with the records
A host step of a render execution whose records the GPU may write recorded every command at every step: about 12 to 17 ms for the replayed-frames page's 5000 indexed draws on the M3, every frame, though the page's records are the same bytes each frame. The step now keeps its chunks as commit keeps the CPU's (render/executions/kept.rs, kept_commands.rs): from a chunk's second step on it records the chunk apart into a context of its own and keeps it with a copy of the bytes of its records; a later step runs the kept recording where the records hold those bytes now, compared whole, and its key is equal, and records it again otherwise. No write forgets such a chunk: the comparison decides. The key is everything the recording reads beside the records: the RenderKey commit's chunks use (inherited pipeline state, pass shape and layout, encoder state, scissors, amplification, attachments among the resident resources, the resident set compared whole once a list), plus the inherited tables' buffers by key with offsets and attribute strides (new: commit's chunks need tables that bind nothing), plus KeptChunk::runs_again's checks (each address named resolves as it did, no no-copy buffer moved, nothing detached, everything held alive). The step keeps only where the commands inherit the pipeline state and the inherited tables bind buffers alone; a record barrier makes its chunk not plain instead of ruling the execution out. Its chunks draw in the large-buffer form, as the step's other draws do. The step's round trip stays: the records are known only once the work before them completed. Counters: WorkCounts::host_step_chunks_kept, host_step_chunks_recorded_again, host_step_records_compared and host_step_compare_nanos (api_signatures rows added). The replayed_frames lane prints them and a hash of the target's pixels per frame (a blit copies the target out); the new kept_steps lane changes one input at a time (the records the GPU wrote, the inherited buffer and its offset, the inherited state, the scissor, the resident set, the buffer an index address names at the same address, the inherited no-copy buffer's pages) and checks a re-record, the pixels of a page that kept nothing, and keeping again after. FAST-PATHS' entry on kept recordings states the host step's. Verified: cargo check and clippy -D warnings, all features, plain and --cfg m2v_gpu, for the runtime and validation crates; api_signatures/api_surface 15/15; fast_paths 19/19; the runtime's kept and indirect-command unit tests 32/32. The device tests (kept_steps, replayed_frames, the ICB lane modules) are not run yet. (cherry picked from commit 9b3d13a6d22fba484cce4923fd87ad503f7bc060) |
||
|
|
c7d79b43ef |
List the queue-switch check among the modules that keep the device's functions
The teardown fix (
|
||
|
|
0f66565039 |
Pin the runtime sources at RUNTIME_VERSION 1765
Verified: pin-compute.py over the tree. |
||
|
|
9d0a6d3dbd |
Bump RUNTIME_VERSION to 1765: guest RAM copies on the GPU, and the device's teardown on the program's thread
- BlitCommandEncoder::copy_from_host_ram and copy_to_host_ram gather and scatter 4 KiB runs of a HostRam straight from its chunk imports (one bind::pages_copy_module dispatch per chunk), taking each chunk as an object over it does, so the import window moves past it. New counters host_ram_copies, host_ram_copy_bytes and host_ram_copy_dispatches. - The queue-switch check holds no device handle, and a device's teardown stops it within one step, so the program's last drop tears the device down on its own thread (RTX 5080: the teardown lanes ran the destroy on m2v-queue-switch-check before). - The GPU hazard tests' opt-in cfg changes no runtime behaviour. Verified: see the cherry-picked commits (HostRam copy: M3 33/33 and RTX 5080 35/35 host_ram device tests; teardown: 8/8 teardown_threads three times on each of the RTX 5080 and the M3). |
||
|
|
de2554f1ac |
Hold no device handle in the queue-switch check, so the program's last drop tears the device down
On the RTX 5080 Laptop GPU the teardown lanes failed: a device that made a command queue and went at once could be torn down on the m2v-queue-switch-check thread after the program's last drop returned. The check upgraded a weak handle for its run (a few milliseconds), so a program that dropped its own handle in that window left the check holding the last one; a consumer that adopted the VkDevice destroys it after its last drop returns, and Vulkan requires every object made from it destroyed first and host access to it externally synchronized (VUID-vkDestroyDevice-device-05137). What: - The check's thread holds the parts of the device it works with (queue_switch_check::Parts: shares of its functions, VkQueues, parking, counts, fences, loader word, sharing state and the shader cache's content store, and the family, round robin, pair, clock and driver identity it reads at the start), never a device handle. QueueUses lets a queue's use reach those parts without a Device. - The teardown stops the check before it goes on (QueueSwitch::stop): the check reads the flag before its objects' making, before each round and before it reads the timestamps, so the teardown waits at most one step, then for the check to release its objects (verdict Unchecked, nothing recorded) and drop its shares. QueueSwitch::began/ended bracket the thread from before its spawn; stop_waited reports the wait. - A new device test, a_running_queue_switch_check_leaves_the_device_to_the_program_s_thread, holds the check between two rounds, drops the device, and asserts that the teardown ran on the program's thread before the drop returned and that its wait for the check stayed within the release bound. It runs only where the check runs (two VkQueues with timestamps). Verified (cargo nextest, --cfg m2v_gpu, the hazard filter, -E 'test(/teardown_threads/)'), three runs each: - RTX 5080 Laptop GPU, NVIDIA 615.71.09, at 344351d867: 8 tests run: 8 passed, 1637 skipped, in each run; the new test ran and printed "the last drop took 225.70356ms, of which the wait for the check 2.273443ms" (then 127.5 ms / 1.38 ms and 205.2 ms / 10.83 ms). - M3 Max, MoltenVK 1.4.2, macOS 27.0.1: 8 tests run: 8 passed, 1620 skipped, in each run; the new test is skipped there (no queue-switch check runs on that device). No negative control against the old code: the test's hold between rounds is a hook this change adds. (cherry picked from commit 0c27be02fd4014b2ff3e31fdf26ecdc183c72882) |
||
|
|
cc4c44bd7e |
Make the GPU hazard tests opt-in under --cfg m2v_gpu_hazards
Owner's rule (11-05): tests that fault a real GPU, hold one for long, or allocate toward its limits never run in sweeps, lanes, stress loops or gates; they run only when that feature is tested, on request. On the M3 Max a GPU fault's recovery fails other processes' command buffers in flight (.config/nextest.toml has the measurement). #[ignore] is not enough, since lanes run --run-ignored all, so the gate is a cfg: on a real GPU a hazard compiles only under --cfg m2v_gpu --cfg m2v_gpu_hazards. Under --cfg m2v_cpu_icd it compiles and runs as before, so lavapipe CI keeps them. Gated (each doc comment now says which hazard it is): - runtime_lane::host_memory::a_gpu_fault_fails_its_command_buffer_and_the_queue_runs_on and ::a_lost_device_s_command_buffers_let_go_of_their_pools_after_the_driver_s_completion: GPU writes into read-only host pages, real page faults (2 and 3). - host_memory::a_no_copy_buffer_s_pages_are_imported_when_it_is_made: no-copy buffers of 1 to 16 GiB. - vertex_strides::vertex_fetches_past_4_gib_of_a_buffer_are_refused and stage_in_strides::stage_in_fetches_past_4_gib_of_a_buffer_are_refused (and their `Large` helper): 4 GiB + 4 KiB buffers. - heaps::the_largest_heap_lies_in_one_allocation: a heap of the device's largest allocation, up to 4 GiB. - cross_queue_shadows: the three tests whose spin holds one command buffer for 1.5 s. - framebuffer_fetch::storage_forms::a_steady_stream_takes_the_storage_form_at_its_first_lone_commit: a single-dispatch spin of up to 1 s that only its cap ends on Apple GPUs. - detach::table_3_a_detach_waits_for_running_work_then_refuses: single dispatches calibrated to 500 ms (up to 2 s loaded), the cap alone ending them on the M3 Max, where Metal ended some 0.5 s dispatches as hung. - runtime tests::detach_lost: one dispatch of 2^25 loads (about 4.5 s on the M3 Max) whose word the GPU does not see raised. Made safe instead of gated: - mesh_draws::object_grids_run_as_metal_runs_them: on a GPU without the hazards cfg, grids past 2^20 object threadgroups are skipped (printed), as a CPU ICD already skips them; the 70k to 262k grids and the past-the-watchdog discards still run. The 4.6M grid took 12 s in one command buffer on the RTX 5080 Laptop GPU. - detach::a_resident_buffer_no_command_reaches_fails_its_submission_once_detached takes the spin kernel without calibrating a cap (`spin_kernel`): its word is raised, so the cap never mattered, and the calibration's unraised runs are bounded only at 16 x 50 ms. - cross_queue_shadows::an_encoder_after_a_signal_reads_what_another_queue_wrote_after_it no longer calibrates a spin it never ran. The cfg is declared for unexpected_cfgs in the runtime, validation and conformance manifests. docs/VALIDATION.md says what a hazard is and how to run one; CONTRIBUTING.md and .config/nextest.toml mention the cfg. The device lane is unaffected: its builds set RUSTFLAGS to --cfg m2v_gpu alone. No product code changed (no RUNTIME_VERSION bump; the runtime-sources pin skips test modules). Verified on this Mac (no test run on any GPU): cargo fmt --all; cargo clippy --workspace --all-targets --all-features -D warnings clean plain, under --cfg m2v_gpu, --cfg m2v_gpu --cfg m2v_gpu_hazards and --cfg m2v_cpu_icd. cargo nextest list -p metal2vulkan-runtime -p metal2vulkan-validation --all-features --run-ignored all: under --cfg m2v_gpu 5022 tests, under --cfg m2v_gpu --cfg m2v_gpu_hazards 5034, and the difference is exactly the 12 gated tests; all 12 are listed under --cfg m2v_cpu_icd (5000 tests). (cherry picked from commit 7b57d9a87a3dd8275a2ece547fc0bd9b9cb6808c) |
||
|
|
ca19864eb3 |
runtime: a device test that a copy takes its chunks as an object does, moving the window ahead
On a device whose thread imports a RAM's chunks ahead (no `hold_host_ram_imports`), a gather from the RAM's first chunk finds that chunk imported ahead and opens the full window past it, and a scatter into the chunk past the window imports that chunk itself while the thread imports nothing past the RAM's end: the copy goes through the objects' one import path (`RamOnDevice::chunk`, `By::Object`) and moves the window as an object's take does. A RAM of six chunks (`AHEAD_CHUNKS` + 2), anonymous memory; the test's helpers gain a sized RAM and an unheld device. Verified: see the commit's evidence in the port's report (potluck jobs on the M3 and the RTX 5080). (cherry picked from commit 2ad02572ea64482f821c48cd9985a001fd382a98) |
||
|
|
a0bebe78f1 |
runtime: copy runs of a guest RAM to and from a buffer on the GPU, from the chunk imports
`BlitCommandEncoder::copy_from_host_ram(ram, runs, destination, destination_offset)` gathers runs
of a `HostRam` the device uses into consecutive bytes of a buffer, and
`copy_to_host_ram(source, source_offset, ram, runs)` scatters them back (a runtime extension:
Metal has none). A surface that is a scatter of guest pages is copied straight from the RAM's
64 MiB chunk imports, with no view mapped per surface (one mmap per run) and no import made per
surface.
How: adjacent ascending runs merge, descending neighbours stay apart; runs are cut at chunk ends;
the 4 KiB pages become a table in the command buffer's upload arena, and each chunk the runs touch
takes one dispatch of the new `bind::pages_copy_module` (more only past the storage-buffer range
or the workgroup count). A chunk not imported yet is imported, or its pending import waited for,
as an object over it does.
Ordering: each chunk a copy uses gets a resource key placed over the chunk's host bytes in the
host-alias placements, the way no-copy buffers and heaps are placed, so the copy's chunk uses
(joined to at most 16 ranges per chunk) order against other copies and against every no-copy
object over the RAM's own addresses, in one encoder and across encoders; the buffer side is
tracked like any blit. A scatter's writes reach the RAM's dirty log as the GPU's in place, so a
copied backing over those pages takes them in at its next commit. Objects made over another
mapping of the pages (a view resolved through `with_runs`) are not ordered against the copies.
Refused with `Problem::HostRam`: an empty run, one off 4 KiB, one outside the RAM, a RAM the
device does not use, buffer bytes off a 4-byte word; no host import is `Unsupported`; bytes past
the buffer are `RangeOutOfBounds`. Replayed at rebinds (`BlitCall::HostRamCopy`). New counters
`host_ram_copies`, `host_ram_copy_bytes`, `host_ram_copy_dispatches`. README, HOWTO, the
API signature rows and docs/REFUSALS.md updated.
Verified:
- On this M3 Max (MoltenVK), --cfg m2v_gpu under nextest: the five new device tests
(`tests::host_ram_copy_device`: round trips byte for byte over ascending, descending, adjacent,
repeated and chunk-crossing runs into Shared and Private buffers; CPU writes before the commit
gathered and a scatter's bytes in the pages after completion; the two hazard cases in one
encoder and across encoders; a copied backing over the pages taking a scatter at the next
commit; the refusals) and the ten `tests::host_ram_device` tests: 15 passed.
- Negative controls, each a saved build: merging descending neighbours fails
`adjacent_ascending_runs_merge_and_descending_ones_stay_apart` and
`a_gather_and_a_scatter_move_every_runs_bytes_in_order` ("the gathered bytes"); not placing the
chunk keys over the host bytes fails
`copies_are_ordered_against_a_no_copy_buffer_over_the_same_pages` ("a later reader sees the
scatter"). The first control found the test pattern repeating every 1 KiB, so a page swap
went unseen; the pattern now differs per page.
- The `host_ram::copy` unit tests (merge, refusals, chunk cuts, the plan, the joined uses) and
`consumer_auto_traits`; clippy --workspace --all-targets --all-features -D warnings, plain and
--cfg m2v_gpu; rustdoc -D warnings; `signatures.py --check` after the bless; the refusal
surface `--check`.
- The ignored release bench `tests::host_ram_copy_bench` on the M3, a 3840x2054 BGRA8 surface
(31,549,440 bytes, 31,551,488 in whole pages) scattered over 1 GiB of shared RAM: 7703 4 KiB
runs (5490 descending neighbours, 7279 runs after the merge) take 16 dispatches, 0.35 ms of CPU in the call, 0.59 ms of GPU and 0.64 ms from commit to completion
for a gather (scatter 0.37 / 0.58 / 0.64). The view path at the host's 16 KiB page (1926 runs:
a view mapped run by run, a buffer `with_runs`, a buffer-to-buffer copy, the release) takes
1.58 ms to map, 2.36 ms to make the buffer, 0.99 ms commit to completion and 0.78 ms to
release; the gather of the same 1926 runs takes 0.14 ms CPU and 0.60 ms commit to completion.
Ported onto gate/stack27, where the device's thread imports a window of chunks ahead of the
objects (paced, with the memory lock released, short of maxMemoryAllocationCount and giving back
what no object took). The conflict was `RamOnDevice`'s fields alone: the copies' `ChunkKeys` sit
beside the window and its wake, and the old cursor is gone. The copy still takes each chunk
through `RamOnDevice::chunk(.., By::Object)`, the objects' own path, which now moves the window
past it, wakes the thread and clears the chunk's untaken mark; there is no second import path. The
copy module docs and HOWTO say so. The ignored release bench waited for every chunk imported
ahead, which the window never does; its warm-up copy now imports the chunks the runs touch.
The verification above was on the old base; this tree's is in the commit that follows.
(cherry picked from commit 923718777c198bef526dd07f701fc71a71e07b00)
(cherry picked from commit fa00224f7b29ab0359c8305a47da9c9273fc5d37)
|
||
|
|
014d1d4c0b |
bind: a gather and a scatter of 4 KiB pages by a table, for the runtime's copies
A new owned compute module, `pages_copy_module(device, PagesCopy)`, built with the typed SPIR-V builder like the other `bind` modules. It moves whole 4 KiB pages between a scattered buffer and a consecutive one by a table of page pairs: workgroup g takes entry `first_entry + g`, whose two words name the scattered page and the consecutive page (counted from `first_word`); its 128 invocations copy the page's 1024 words, eight each. `Gather` writes the consecutive side, `Scatter` the scattered side. Local size 128 is the Vulkan 1.2 floor of maxComputeWorkGroupSize[0]. The runtime uses it to copy runs of guest RAM to and from a buffer straight from the RAM's chunk imports (next commit), in one dispatch per chunk rather than one copy region per run. Verified: the module's interpreter tests (valid on every committed device profile; a gather from a non-zero first entry and first word over descending and repeated pages; a scatter), the `owned_divisions` listing, `api_surface` and the blessed `api_signatures` rows; clippy (--all-targets --all-features, plain and --cfg m2v_gpu) clean; rustdoc -D warnings clean. (cherry picked from commit 03e1d0046e908f46b21e33423e45d7e541927a91) (cherry picked from commit 7167c05e8ef2b012c023f50e2910bea4ec00e9dc) |
||
|
|
aae542957b |
Hold the draws class's wasted creation pipelines at 86: the pass-start family's 39
The re-recorded costs give the pass-start-barrier family's 13 cases their first cost records, and the per-class creation-prediction ceiling then failed (cost::the_creation_prediction::neither_prediction_wastes_more_than_it_does_today, potluck m3-max-613): draws and no dispatch read 86 predicted pipelines no command took against 47. Every one of the 39 more is those 13 rows: comparing each recording's creation_pipelines_made and creation_pipelines_drawn before and after the re-record, only those 13 rows changed (none had a record before), each 5 made and 1 to 3 drawn. They are cases that draw, so this is a misprediction, an open bug the ceiling's doc now names with its suspect; its fix lowers the ceiling back to 47. The table of what the recordings read is updated to 528 rows. Verified: the comparison over all 528 recordings (13 changed rows, all new); the suite is rerun on the M3. |
||
|
|
908ba3dbf2 |
Re-record the conformance costs for stack 27
Stack 27 adds the resident_textures_looked_at count and moves two gated bounds, so the cost check against stack 26's records failed (m3-max-528): resident_textures_looked_at newly gated in 14 cases (seen in 246), pipeline_layouts_made 2 -> 1 and shader_modules_made 4 -> 3 in render-state-render-barriers, pipeline_layouts_made no longer gated in render-state-heap-residency, resident_textures_looked_at 2 -> 4 in frame-length-chain, and the 13 pass-start-barrier cases held no record. This re-records every case: a whole-set `conformance cost --runs 8 --write`, then `cost --runs 8 --alone --write` over every changed case (693), so each record carries its contrast, and AFTER_THE_LAST_RUN is empty again. Verified: the re-bless on the M3 Max (potluck m3-max-574): 693 cases measured, 0 the venue could not measure. |
||
|
|
d19da8bfce |
Bless the golden tables for the ICB vertex-encode fixture
icb_vertex_encode_indexed (from the ICB steps) is new: its printout, its three inventory rows and 114
golden-hash cells. Reviewed: ive_encode, ive_vertex and ive_fragment translate on every profile with
BufferDeviceAddress and ShaderInt64, and ive_encode is an honest Unsupported{GpuEncodedIndirectCommands}
on lunarg-desktop-baseline-2023, roadmap-2022, swiftshader and vk12-floor.
Verified: on the M3 (potluck m3-max-431) bless_engine_inventory, the air_input printout and
bless_golden_hashes, then the five failing tests (inventory order, golden printout, golden hashes,
llvm_as part 7, metal_as part 2): 5 passed.
|
||
|
|
43a04fc8a1 |
Pin the runtime sources at RUNTIME_VERSION 1764 after the copy-beside-import comment
The cherry-picked docs commit changes a comment in copied.rs, a hashed runtime source. Verified: pin-compute.py over the tree. |
||
|
|
03d4e53238 |
Record the copy beside another storage mode's import as a GPU-to-GPU gap
What: copied.rs's GPU-to-GPU note and docs/FAST-PATHS.md's known gap now also name a copy beside a live import of the same bytes for the other storage mode (a Managed buffer's import, then a Shared buffer over the same bytes whose import the gate refused): two memories that agree only through the pages, as overlapping copies do. Why: a buffer lies in a live import of its own memory class, else in a live copy of either class; a copy made while only the other class's import lives is a second memory. Lying in the other class's import instead was left out: it would change which memory type the buffer's import takes. Verified: docs only (cargo fmt). (cherry picked from commit 9f473f8f10f82e59864fd5abb74615b65c3b2e14) |
||
|
|
6b8b6e7310 |
Pin the runtime sources at RUNTIME_VERSION 1764
No Degradation variant, WorkCounts field or method is removed by this stack (api_signatures.tsv
loses no line against development
|