fc79fdd4e9906a138b6695ff404bfb305931e8fa
229
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
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)
|
||
|
|
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) |
||
|
|
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) |
||
|
|
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) |
||
|
|
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) |
||
|
|
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) |
||
|
|
6c4b409fb0 |
Lay a no-copy buffer over a live copied host buffer's bytes in its copy
What: a copied host buffer (the caller's gate refused the import, or an admitted import failed) now joins its memory and is placed as an import is (`HostAliases::join` with `Kind::Copy`, `HostAliases::place`). A later no-copy buffer over exactly the same first byte and length, of either storage mode, finds it (`HostAliases::import`: an import of its class, else the live copy), lies in it through `Device::buffer_in_import`, is named to it (`copied_as`) and joins its key, with the gate not asked. A rebind onto such bytes lies in the copy too where its textures were planned at the copy's offset (its first byte) and no image in place rides on it; an import keeps the old `!moved` rule. A heap's own copy is placed but joins nothing; a buffer whose writes are dropped keeps its read-only view. New counter `WorkCounts::copied_host_buffers_shared`. Why: two copies of one memory agreed only through the pages (merge back at the writer's completion, copy in at the reader's commit). reims-vgpu measured on the M3 (MoltenVK) two textures over one 64x64 BGRA8 surface, each over its own refused no-copy buffer: a blit write then a blit read in one command buffer, and a reader committed first on a second queue waiting on the writer's event, both read all 16384 bytes stale, where Metal and the runtime in place read the write. The consumer also made a full copy of the surface per texture per present. The remaining GPU-to-GPU gap, between a copy and another copy or import of overlapping but different bytes, is recorded in copied.rs, docs/API.md, docs/HOWTO.md and docs/FAST-PATHS.md's known gaps. Verified: cargo check of the runtime with tests; the lane in the next commit, run on the M3 (see its message). (cherry picked from commit 69feb791dc6ec3bc2405dbf5b6ae5d0b27d936aa) |
||
|
|
1a541744e1 |
Destroy an event's semaphore where its release goes again, and record NVIDIA's event costs
What: an event's release destroys its timeline semaphore on the releasing thread again, as at
4bbafa667d (event.rs is that commit's again); the device's free thread frees blocks alone. The
semaphore posting goes with its counter (WorkCounts::semaphore_destroys_posted; the API table
blessed: the field removed), its runtime test and its lane rows. docs/FAST-PATHS.md's known gaps
record what making and releasing an event costs on NVIDIA, and why the release is not posted.
Why: NVIDIA's driver runs a vkCreateSemaphore behind a vkDestroySemaphore another thread runs,
so a posted destroy moves its cost onto the program's next event and adds to it. Measured on the
RTX 5080 Laptop GPU with the bench's event modes (each row 1000 events unless said; before and
after interleaved within each hold; CPU package 83-103 C), p50 unless said:
burst, 1000 made then released inline: make 143-262 us, release 495-579 us
(0.47-0.57 s a 1000 released)
posted, bound 4096: release 0.2-0.5 us, but the makes
while the destroys drained 1048-1676 us (1.10-1.66 s
a 1000)
posted, bound 64: release 0.5-1.2 us, p99 1.5-2.2 ms,
0.51-0.66 s a 1000; makes unchanged
steady, make one and release the inline 203-238 us a pair; posted (64) 390-507 us
one before, back to back
steady, 2 ms apart (500) inline 488-490 us a pair (event), 663-677 us (shared);
posted 260-263 us and 417-421 us
the driver's own cost grows with the semaphores live: 98-119 us a make and a
release with one or two live, against the burst's
143-262 and 495-579 us with 1000 live
On the M3 Max (MoltenVK 1.4.2) a pair costs 2.6-2.8 us inline and 5.3-5.9 us posted back to
back, about 45 us either way 2 ms apart; Metal's own newEvent and newSharedEvent take 0.8-1.9
us there. The consumer's guests made no event in a boot of theirs, and their host makes a few a
second, so no shape of use has the posted destroy ahead, and the burst at a program's close,
which posting was for, gains nothing: the device's teardown drains what was posted.
Verified on the M3 Max (debug, --cfg m2v_gpu, under maclock and memcap): 90 runtime tests
(posted_frees, freed_memory, teardown_threads, memory, allocations, event, cpu_copy_layouts)
and 27 lane tests (posted_frees, shared_event, events, pool_churn, staging_batches) pass;
api_signatures and api_surface pass; clippy (plain and --cfg m2v_gpu, workspace, all targets,
all features) and the release check of the runtime's tests are clean. The inline rows above
are the RTX 5080's at 4bbafa667d's event path, which this restores.
(cherry picked from commit 1659544703425cd461106fba2cff7cfe73a02a8a)
|
||
|
|
289af45922 |
Give the shadow runs' RTX 5080 Laptop times again, measured with the in-place first pass
The previous commit removed the RTX 5080 Laptop numbers from docs/FAST-PATHS.md because they described the earlier form of the runs. They are measured again here, with the in-place first pass and the second keep. Verified on msi-laptop (RTX 5080 Laptop GPU, NVIDIA 615.71.09), under an exclusive GPU hold with no VM running. Release builds of the 700-pass probe were made at 36c3063e16 (tip) and at 2bc0f1eac6 (fix), and run interleaved, three processes each. The times are commit to completion of the second to fourth command buffers of each process: - passes back to back: fix 6.5-9.1 ms, tip 6.3-9.0 ms; - with an empty 1x1 encoder between every two passes: fix 9.3-12.2 ms, tip 9.1-12.7 ms. The fix took 5 shadow copies and kept 2,097,152 texels in every run; the tip took 3 and kept 1,048,576. The figures for the build without runs (40.6-43.0 ms and 44.5-47.1 ms) are the ones the row already gave. (cherry picked from commit fa2b1b354d818fd4a373fb5af7ba1c5dd44ce21c) (cherry picked from commit 8674db962402c9c425765fe0c8430f1383edd6ff) |
||
|
|
4bfeb66cd9 |
Merge a shadowed texture's pass in place until a second pass goes on from it
A shadowed texture's pass that opened a run left its merge to its batch's submission
(`Deferred::RunMerge`). That splits its encoder's commands into a continuation VkCommandBuffer and
records a segment of batch work at the submission. A pass that no later pass goes on from paid for
this and saved nothing. The conformance cases rotated-planes-load-0-64x16 and -32x32, one such pass
each, measured alone on the M3 Max: command_buffers_begun 3 -> 6, command_buffers_submitted 2 -> 5,
submit_infos 1 -> 2, end_command_buffer 3 -> 6, encoder_command_buffers_begun 2 -> 3, batch work
1 -> 2, and one batch barrier and one continuation that the recordings do not have. Reverting the
shadow runs alone restored the recorded counts; reverting the twin-shadow fix changed nothing.
Now the pass that would open a run merges in place as its encoder ends, as a pass alone does, and
only marks where a run may start (`PassRuns::placed`). The pass after it opens the run
(`Joined::Placed`): its image is carried, with no copy in, and it keeps the texture again.
The second keep is required. A run's merge compares its keep with the image its last pass left,
byte by byte, and a byte equal in both keeps the buffer's byte. A first attempt went on over the
in-place pass's keep instead. Bytes that the later passes changed and changed back then kept the
in-place merge's value, and the byte comparisons failed:
- tests::shadow_runs::runs_over_host_pages: 1,176 bytes;
- tests::merge_scratch's passes over host pages;
- the validation lane's many_passes_over_host_pages tests.
So a run of k >= 2 passes costs two keeps, two merges and k - 1 continuations, and a lone pass
costs nothing extra.
Verified on the M3 Max (MoltenVK 1.4.2, --cfg m2v_gpu):
- `conformance cost --runs 8 --alone --show` for both rotated-planes cases: every count that rose
equals the recording again. The four counts that differ alone from the whole-set measurement
(command_buffers_deferred, cmd_push_constants, device_memory_allocated,
queues_sharing_a_vk_queue) also differ with the shadow runs reverted.
- New test tests::shadow_runs::a_pass_alone_merges_in_place. A pass alone: 0 continuations,
3 shadow copies. Three passes: 2 continuations, 5 copies. The bytes equal a private texture's.
Negative controls:
- with the in-place path disabled, it fails at (1, 1, 3);
- with the pass after a marker opening the run without a keep (`Joined::Opens`), it fails at
(3, 0, 7).
- tests::shadow_runs and tests::merge_scratch, 10 of 10, with updated counts:
- runs_over_host_pages: 32 copies, 14,680,064 texels kept;
- the scissored passes keep at [0, 1, 2];
- the rebind encodes 4 passes again.
- The runtime's shadow, merge, linear, rebind, re-encode and replay tests: 155 of 155.
- The validation lane's shadow, padded, linear, rotated and surface tests: 145 of 145.
- The 700-pass probe now takes 5 shadow copies and keeps 2,097,152 texels (3 and 1,048,576
before). Release builds of this tree and of its parent, interleaved, three processes each, the
second to fourth command buffers: commit to completion was 32.7-35.6 ms against the parent's
31.6-36.1 ms, and with an empty encoder between every two passes, 61.5-67.2 ms against
60.4-67.0 ms.
docs/FAST-PATHS.md gives the new counts and the M3 times. The RTX 5080 Laptop numbers are removed:
they described the previous form, and that host was running VMs, so they were not measured again.
(cherry picked from commit 2bc0f1eac676dcc86dadfbd37a81313977515d45)
(cherry picked from commit 55c7f307a92c67125d31b08c33b3f91c7d14a67b)
|
||
|
|
241ee2c0d1 |
Keep and merge a run of passes over one shadowed texture once, not once a pass
What: a render pass whose color is a shadowed texture merged back (its truth a buffer's bytes
another writer may write, such as a no-copy buffer's host pages or a Shared buffer's), loaded and
stored, now joins a run of passes (pass_runs.rs) where it may. The run's first pass copies in (or
takes the carried image) and keeps, as before. Each later pass goes on over the image the pass
before it left (ShadowSync::go_on) and keeps nothing. Each pass leaves its merge to its batch's
submission (Deferred::RunMerge, RunWork::Shadow), and the run's next pass takes it over, so the
merge recorded is the last pass's, compared against the first keep. The run holds the keep's
scratch or kept image (RunHeld::Shadow, its MergeLease) until it ends or the command buffer
commits.
Why: consecutive render passes over one merged-back shadowed texture each copied in, kept and
merged the whole texture. 700 one-rectangle passes over a 1024x1024 BGRA8Unorm texture over host
pages took 1,401 shadow copies and 700 merges.
The rule, structural, with no names: a run ends wherever something other than its own passes
could observe or change the bytes, as in the linear runs' list:
- any encoder between its passes that is not a render encoder;
- a render encoder that names the bytes' buffer or its host range, reaches memory it does not
name, fences, resolves, writes visibility results, records later or renders over a rate map;
- a render encoder with an attachment over those bytes, or whose draws or attachments take a
shadowed texture over them (the run's own texture bound to a draw included);
- a signal, a wait or a host step (a new batch), and the command buffer's end;
- for a shadow, the encoder no longer carrying the image (the carry dropped).
A shadowed color joins only when it is loaded and stored, has no stand-in and no planes, belongs
to a pass of one render pass instance that is not inline and not inside a predicated laying, is
laid out as one image's texels at level 0 and slice 0, and merges back.
Encoded again: unlike a linear attachment's run, a shadowed texture's run may hold passes over
host pages, which a rebind before the first submission encodes again. Such a pass leaves its run
(RunMerge::leave). The merge it took over records after all (given back), and the pass copies in,
keeps and merges for itself. Where a later pass took its merge over, it keeps the run's scratch
again after its own merge (RunMerge::keep_after), so that later pass's run merges what the passes
after it change. Run segments now record again (Segment::records_again) and splice. An encoder
encoded again takes no pooled scratch or kept image (ShadowMerge::new's `lent`). A run's merge is
resolved at its calls (Deferred::resolved_at_its_calls), so it holds no host pages past commit;
before this, a rebind of such a run was refused with Rebind(EncodedUses).
Two more changes. A run's keep that a later pass writes outside merges and keeps every texel next,
and a run's pass that needs texels the copy-in did not hold copies every texel in. A merge in whole
blocks stays in blocks where the keep holds the pass's area (stores_blocks), under the same
read-to-store window that shadow.rs's Stored attachments already state.
Counted with the existing counters: shadow_copies, shadow_texels_kept and
shadow_merge_dispatches_planned fall from one per pass to one per run. docs/FAST-PATHS.md records
the run and its costs.
Verified on the M3 Max (MoltenVK 1.4.2), --cfg m2v_gpu, under maclock and memcap:
- tests::shadow_runs (new, all pass):
- runs_over_host_pages_keep_and_merge_once: 1024x1024 BGRA8Unorm over host pages, rows of 15360
bytes, with blits, foreign render encoders, reads, CPU byte writes, a signal and an aliasing
view between runs. Mid-sequence and final reads match a private texture byte for byte, and
the padding is untouched. Joined: 22 copies, 9 merges. Apart: 112 copies, 54 merges.
- rebound_passes_leave_their_runs: 3 encoders encoded again, 0 refused, bytes equal.
- scissored_runs_keep_again_once_and_merge_in_blocks: keeps at passes [0, 1], all in blocks.
- Runtime suites (shadow, merge_scratch, linear_runs): 69 of 69 passed.
- Validation runtime_lane (shadow, padded, linear): 91 of 91 passed.
- Negative controls, each a sabotaged build, source restored and touched after; each fails:
- go_on off: every pass keeps;
- follows across encoders: keeps [D0, D8, D9, D10, A11, D12];
- leave off: 961,469 bytes differ;
- stores_blocks reverted: every scissored pass keeps.
- Release probe, 700 passes in one command buffer, base a543f6428d against this commit: shadow
copies 3 against 1,401, texels kept 1,048,576 against 734,003,200, merges planned 1 against 700.
Commit to completion, runs 1-3: 31.6-35.3 ms against 69.3-99.9 ms. With a 1x1 render encoder
between every two: 61.6-65.0 ms against 107.4-118.6 ms.
On the RTX 5080 Laptop GPU (NVIDIA 615.71.09), the same probe, runs 1-3: 6.6-10.0 ms against
40.6-43.0 ms, and 9.7-12.3 ms against 44.5-47.1 ms. The same 11 shadow, merge and linear device
tests passed there.
clippy --all-targets --all-features -D warnings passed plain and with --cfg m2v_gpu, and cargo fmt
was run.
(cherry picked from commit bf783428131f46c7289518a50b8505e809ecc8e5)
(cherry picked from commit 99949a4cd08cd042e448484e0b1d2f5da1898db5)
|
||
|
|
385a2ed40f |
Record host steps on up to eight threads, so one queue's long step holds back no other queue's
What: scheduler/steps.rs had one thread per device record every host step of every queue, in hand-over order. It now hands each step to a free thread of a pool, or starts one for it below THREADS (8); past the cap a step waits for the first thread free, in hand-over order. The first thread stays until the scheduler stops, as the one thread did; each later one ends after 2 s with no step. All start at the user-interactive class, each step is still a section of the exit guard, and where the host cannot start the first thread the scheduler's thread records the step itself, as before. Why: the consumer (one device for every guest process) saw WindowServer's present wait 13.6 s in the host after the page's context had closed. A page's render-bundle ICB execution was recording a seconds-long host step, and any command buffer whose draw or dispatch has a pipeline still being made takes a host step too (deferred.rs: RenderPass with making(), Pending), which queued behind the page's on the one thread. A dead context's step keeps recording, as its command buffer holds what it uses. Order is still the scheduler's: only a line's head is handed over, marked stepping until its step ends, so a logical queue's steps are recorded one at a time in its order, and a head that waits for an event value, or is behind an earlier commit's conflicting batch (order.rs), is not gated or handed over (gate_heads takes `behind`). Audit of what assumed one step at a time device-wide: - kept chunks (kept_commands.rs): no host step uses them (render executions keep only when !step, compute executions only when states.is_none()); - upload and descriptor arenas: per command buffer (State::uploads, State::descriptors); their spares are the device's, under a lock; the command pool is per command buffer, recorded under its `reencoding` turn, which host_step takes; - pipeline making: the pool, the budget's turns and the making maps already serve concurrent encoders; the in_host_step()-gated branches (Urgency::HostStep, keep_room skipped, kept variants not taken back, takes_multi_variable_dynamic, make_at_creation skipped, sampler-set count) read a thread-local, so they hold per thread; kept.rs StepNumbers is thread-local and per command buffer, whose steps stay sequential, `made` handed on through end_step and the scheduler's locks; - residency: a command buffer's own value, its address index made per residency; - the scheduler's wake and hand-over: record() marks the inbox under its lock and wakes, as a committing thread does; begin_step/end_step are the command buffer's atomics; post pushes under the steps' lock; - the exit guard: sections are counted per thread and in atomics, HOST_STEPS is thread-local, called() is atomic; many sections at once were already normal; - interior mutability used by the steps thread alone: none besides the steps' own state (every shared object is Sync and shared with committing threads already); - notices: every-occurrence notices announced inside steps (each_in_order) of two queues may now interleave; Metal orders nothing between such queues. Docs: the scheduler's "Host steps" section, left.rs, WorkCounts' host-step counters, kept.rs, RecordsRead::HostStep and FAST-PATHS.md's pipeline-wait row say steps' threads. The host-replayed-indirect-commands notice already says only resources the execution may reach hold later batches back, so it is unchanged. Verified on the M3 Max (MoltenVK, --cfg m2v_gpu, maclock+memcap), with the next commit's lane test runtime_lane::steps_apart::another_queue_goes_on_while_a_host_step_records: before, queue B's own stepped command buffer did not complete within 10 s while queue A's step was held (A's objects kept, and released); after, 18.6 / 18.9 ms in debug. Its ordered checks (a step after an event A signals, and a pass into A's target) begin only after A's step ends, before and after. Negative control: THREADS = 1 fails the test again (Stepped, kept and released); restored and touched. Release, A a real 5000-draw step (2.7 to 5.0 s), B's stepped kind went from 3580 ms (released: 3359) to p50 1.49 / max 15.6 ms (released: 1.65 / 40.4); idle 1.32 ms p50. Runtime tests::(scheduler|inbox|host_step|waiter_submits|commit_and_submit|completion_order| unsubmitted|pipeline_wait_order|blit_order): 50 passed. Lane cases (indirect, kept, *executions, *host_steps, submi*, steps_apart, resident_draws, event_round_trips, command_queues): 272 passed. clippy --workspace --all-targets --all-features -D warnings, plain and with --cfg m2v_gpu: clean. (cherry picked from commit e15fd6752fe4f714b73dab0ee72d15fce686f3d7) (cherry picked from commit 229f407b2abe2de5b85bf3d98b2080d0a0667e9d) |
||
|
|
f6692d84e5 |
Keep an ICB execution's chunks where its check can see nothing among its commands
Before, any execution given a check (execute_commands_in_buffer_checked) recorded every command at every commit and kept no chunk, even when the check's needs ruled out everything the buffer's records may hold. In that case commit never calls the check: RenderExecution::check_sees and Execute::check_sees answer from the needs and IndirectCommandBuffer::command_writes. A consumer that hands every execution of own-state commands a check for draws of points, and draws triangles, never had its unchanged commands run from kept recordings. Now RenderExecution::keeping declines where `self.check_sees_now()` holds, and Execute::keeping where `self.check_sees()` holds. The decision is the structural one commit makes for the check, the check's needs against what the records may hold. When a later write makes the records hold something the check looks for, it forgets the chunks it reaches. At the next execution check_sees is true, so keeping declines and the execution records inline, calling the check with every command. Docs: the "Which executions" lists in render/executions/kept.rs and indirect_execute/kept.rs, and docs/FAST-PATHS.md's kept-recordings row. Tests (runtime_lane::kept_commands), counting records read, chunks and commands kept and contexts made (WorkCounts::indirect_chunks_kept and kept_contexts_made show the kept path ran), and the commands the check was called with: - a_checked_execution_keeps_where_its_check_sees_nothing (render). With needs for states that may encode indirect commands, which the inherited state can't, the check sees nothing: [N, 0, 0, 0], then [N, 0, 0, 3], then [0, 3, N, 0], and the check is called 0 times. With needs for draws of points, which the records hold, the check sees: [N, 0, 0, 0] three times, and the check is called with all 3N commands. - a_checked_compute_execution_keeps_where_its_check_sees_nothing: a compute execution checked for every kind. Its records hold no draw and no state that may encode, so it keeps as above, and the check is called 0 times. No fixture kernel encodes indirect commands, so compute has no "check sees" leg. Verified on the M3 Max, debug (--cfg m2v_gpu), on lane 7583fe5d99 with the first-execution ruling cherry-picked beneath it: - nextest -j 8 over every runtime_lane module that executes an indirect command buffer: 39 modules, 473 tests, all pass. - Negative control: keep only with no check at all (the condition before). Both new tests fail at "the second records three chunks to keep" ([600, 0, 0, 0] where [600, 0, 0, 3] is expected). - Negative control: keep whatever the check (render). The render test fails at "a check that sees keeps nothing" ([0, 3, 600, 0] where [600, 0, 0, 0] is expected). - fmt --check, clippy -D warnings (runtime and validation, all targets and features, m2v_gpu), metal2vulkan tests::fast_paths 19/19. Needs a RUNTIME_VERSION bump. No SEMANTICS_VERSION: no translated module changes. (cherry picked from commit d75cb04ac8ed9d4616b10aa13d26af869a32d405) (cherry picked from commit efafed587dd062f7d87bd9c9868ccb035e9ddc26) |
||
|
|
24dc3f20bb |
Keep an ICB range's chunks from their second execution, and forget a written chunk in one store
A range's first execution no longer pays for keeping. Before, every execution of CPU-encoded
commands recorded each 256-command chunk apart, in a KeptContext of its own (a command pool, a
descriptor arena and uploads), so it could run that recording again later, even when no later
execution came. Now a chunk is recorded to keep only from its second execution with no write
reaching it since. The first execution since a write records inline, as before 922caf3199, and
keeps nothing. A consumer that re-encodes every command each frame now pays nothing for keeping.
- kept_commands.rs: KeptChunks notes which chunks an execution that may keep its commands ran
since a write last reached them. look_up answers each chunk of a range as Kept::Recording (a
kept recording), Kept::Again (run before, nothing kept) or Kept::First, and notes each as run.
IndirectCommandBuffer::kept_chunks answers None, so the execution records inline, when every
chunk is First. When some chunks are kept and others are not, a First chunk records apart from
its command buffer's own pool and arenas, with no KeptContext, and is not kept. An Again chunk
records apart in a KeptContext and is kept.
- KeptChunks is dense: one ChunkState per chunk (kept recording, stepped, seen) up to the
furthest chunk looked up, plus a flag for whether any chunk holds a state. KeptChunks::wrote
costs one store per chunk the written range covers, whatever the number of kept chunks, and
returns at once while no chunk holds a state. Before, it ran BTreeMap/BTreeSet::retain over
every kept and stepped chunk on each setter call.
- WorkCounts::kept_contexts_made counts the KeptContexts made (api_signatures.tsv).
- Docs: kept_commands.rs, render/executions/kept.rs, indirect_execute/kept.rs and
docs/FAST-PATHS.md (the kept-recordings row).
- examples/icb_setters.rs --kept now executes three times before each repetition: the first
keeps nothing, the second records every chunk to keep, and the third runs all of them from
those recordings.
Tests:
- runtime_lane::kept_commands asserts kept_contexts_made beside the records read and the chunks
and commands kept.
- A once-executed range makes no context: [N, 0, 0, 0].
- Its second execution keeps every chunk: [N, 0, 0, 3].
- Its third runs them: [0, 3, N, 0].
- After a write, the written chunk records inline again and the next execution keeps it.
- kept_commands::tests::a_write_costs_the_chunks_it_covers asserts the count of chunk states
wrote() looks at.
Verified on the M3 Max:
- Debug device lanes (--cfg m2v_gpu, nextest), with the live compute flags fix from stack22
applied locally (not part of this commit): every runtime_lane module that executes an indirect
command buffer (39 modules, 471 tests) pass.
- Negative control for the ruling (each chunk keeps from its first execution), debug:
3 of the 5 kept_commands tests fail, a first execution making 3 contexts where 0 are expected
and a written chunk making 2.
- Negative control for wrote() (it walks every chunk state): a_write_costs_the_chunks_it_covers
fails, looking at 1000 states where 1 is expected.
- Unit tests: kept_commands::tests 2/2 and metal2vulkan tests::fast_paths 19/19.
- cargo fmt --check and clippy -D warnings (runtime and validation, all targets and features,
--cfg m2v_gpu) are clean.
- icb_setters compute --kept (release, instructions per command, median of 30, two runs each):
| | before (2c542021bf) | after |
|---|---|---|
| compute command, nothing kept | 2528.7 / 2529.1 | 2428.1 / 2427.7 |
| compute command, 64 chunks kept | 5947.8 / 5945.5 | 2586.5 / 2583.9 |
| set_kernel_buffer, 64 chunks kept | 1129.6 / 1129.6 | 456.9 / 456.3 |
With three executions, the third runs all 64 chunks from kept recordings (the
bench prints [64]), at 2583.9 and 456.3 instructions.
- conformance cost --alone indirect-render-commands-inherited-state reads arena_pools_made 1,
argument_objects_retained 2 and argument_tables_retained 1, the recorded bounds. With a first
execution's KeptContext these read 3, 6 and 3 (the cost run that held its record back).
- execution_costs (release) on a loaded host: wall times are dominated by host load. An earlier
pair of runs read the first execution as slower (render n=1024 all re-encoded commit 2.88 to
6.55 ms), but the parent then read 6.55 ms itself under the same load. Time Profiler, test
thread CPU, same case and count, this change on 2b55ab415e against its parent:
- render n=1024 one re-encoded, 300 executions: 611 to 610 ms;
- compute n=1024 all re-encoded, 80 executions: 336 to 333 ms;
- render n=1024 all re-encoded, 120 executions: 782 to 859 ms. This is the inline path's
whole-range read: RenderExecution::commands collects the range into a second
Vec<Option<Command>> (memmove 0 to 25 ms in RenderExecution::record), and render_records
reallocates as it grows. The same profile has IndirectCommandBuffer::edit, whose code is
the same in both builds, up 31 to 40 ms, so part of the difference is load.
A later run of this commit's tree read render n=1024 all re-encoded at 2.37 ms commit, one re-encoded
at 0.61 ms, and compute n=1024 all re-encoded at 3.49 ms.
Needs a RUNTIME_VERSION bump. No SEMANTICS_VERSION: no translated module changes.
(cherry picked from commit a54756c6a4f7fbe9ae82d732e8de46a19f4f86e5)
(cherry picked from commit 71e798c081648ea3818abbffc7538a3061456c75)
|
||
|
|
12f58a227f |
Keep no chunk of a buffer of mesh or patch draws alone: none of their draws is plain
922caf3199 records an execution of commands the CPU encoded chunk by chunk, each chunk apart from a KeptContext of its own (a command pool, descriptor arena and uploads), and keeps a chunk whose draws are all plain. A mesh draw and a patch draw are never plain (render/executions.rs clears RenderLowering::replay_plain for both), so on a buffer whose command types hold neither DRAW nor DRAW_INDEXED every chunk recorded apart was found not plain, noted, and its execution finished through the apart encoder. That cost a command pool and two more primaries, each with a barrier, on the first execution, and kept nothing. RenderExecution::keeping now admits only a buffer whose command types intersect DRAW | DRAW_INDEXED (the test settle already makes). A buffer of mesh or patch draws alone records as it did before 922caf3199. A buffer that mixes them with draws of primitives keeps today's path. docs/FAST-PATHS.md's known gap lists the buffers that still record at every commit. Runtime behaviour: such a buffer's executions record no chunk apart. An execution of a chunk of resets alone on one of them, which draws nothing, is no longer kept either. The cost gate showed the redundant work as three conformance rises, now withheld in the records, all from 922caf3199. Each case measured alone, debug, M3 Max, over 8 runs: - indirect-mesh-commands-object-threadgroup-lengths: command_buffers_begun 11 -> 9, continuations 3 -> 1, submitted 8 -> 6, cmd_pipeline_barrier 14 -> 12, end_command_buffer 11 -> 9, encoder_command_buffers_begun 9 -> 7. - mesh-commands-unordered-draws: 9 -> 7, 3 -> 1, 6 -> 4, 11 -> 9, 9 -> 7, 8 -> 6. - mesh-commands-own-state: 10 -> 8, 3 -> 1, 7 -> 5, 13 -> 11, 10 -> 8, 8 -> 6. command_pools_made fell 2 -> 1 in each. Every gated count equals its value at c00efdc7c0, 922caf3199's parent. The remaining differences are scheduler_sleeps, scheduler_wakes_host and submit_stalls_on_work, which the race rule names. Test: runtime_lane::mesh_commands::a_buffer_of_mesh_draws_alone_records_no_chunk_apart executes the CPU's own commands on a buffer of both mesh kinds twice, after another buffer's execution. It asserts the first execution begins as many command buffers as the second, and that both draw Metal's words. Verified on the M3 Max (--cfg m2v_gpu): it passes with the fix, and fails without it (left 9, right 7). own_commands_draw_metals_words, which now shares encode_own, passes. clippy -D warnings, all targets and features, with --cfg m2v_gpu, is clean for metal2vulkan-runtime and metal2vulkan-validation. RUNTIME_VERSION and the runtime-sources pin are left to the stack. (cherry picked from commit 132d0aeea055b9a3819c82619a12e3c4adf32646) (cherry picked from commit 2a23d1882ceb4cd21506af2a66f92f8258b5b2b2) |
||
|
|
61a9508e92 |
Build visibilityResultType: Accumulate takes a pass's results into the buffer's words
RenderPassDescriptor gains visibility_result_type (MTLVisibilityResultType: Reset, the default and today's behaviour, and Accumulate). Under Accumulate no query result is copied over its offset's word: every query of an offset, the first one too, is copied into the upload region the continuations already use, and the crate-owned combine takes them into the word as the buffer holds it. The combine already loaded the destination word as its accumulator, so Accumulate is the first query becoming one more source. A `Boolean` word ORs the device's results in; a `Counting` word is summed in through a new table mode of the combine, into the word's low 32 bits alone, wrapping there, its high 32 bits kept (ContinuedResult::low_half / in_low_half). That last part is what the M3 Max answered when recorded: 0xffff_fff8 plus 16 samples writes 8, and 0xffff_ffff_ffff_fff8 plus 16 writes 0xffff_ffff_0000_0008. A plain 64-bit sum was divergent there. An offset set with no draw after it keeps its word, because a query with no draw adds 0. Where a no-copy buffer's bytes start off a multiple of 8, so the results land in an upload region, the words are now copied into that region before the combine (Landing::inward). Reset records exactly what it did before. Conformance: RenderPass gains visibility_type (typed()), and words() appends it only where it is not Reset, so existing fingerprints read as before. Both sides set it. There are four new visibility cases, recorded on the M3 Max (macOS 27.0.1): visibility-counting-accumulate (two command buffers; words 100/5/7/0xffff_fff8/u64::MAX-7), visibility-counting-accumulate-one-command-buffer (two passes in one command buffer, read once), visibility-counting-accumulate-revisit, and visibility-boolean-accumulate (words 0/2/3 under covering and non-covering draws, an offset set with no draw, then a second command buffer). The family's acts key states the type, and a joined shape adds a command-buffer input. Cost and timing records for the new cases are not written here. Lane tests (runtime_lane): accumulated_counts_add_to_the_words, accumulated_booleans_or_into_the_words, and host_bytes::accumulated_visibility_results_land_where_their_bytes_lie. Unit tests: the combine's accumulated_counts_are_summed_into_the_low_half, its plan's table mode, and the type's raw values. Coverage: coverage.tsv marks MTLRenderPassDescriptor.visibilityResultType implemented (its unused "visibility" group is removed), and METAL-COVERAGE.md is regenerated. MTLVisibilityResultType joins the enum table, so metal_enumerators.tsv and CONFORMANCE-COVERAGE.md are regenerated. The API signatures are re-blessed. REFUSALS.md is regenerated: VisibilityResultType::from_raw is one more UndefinedValue site. The regeneration also picks up two bind/graphics.rs sites the committed file was missing. The degrade docs (landed results, Boolean) state Accumulate. Verified on the M3 Max under MoltenVK 1.4.2: - The 52 visibility-touching lane tests pass: visibility, host_bytes, depth_never, amplified_draws, degrade_notices and the framebuffer_fetch split pass. - The visibility family's replay is all announced (no divergence), after the low-half change. - Negative control with Accumulate forced to Reset: all three Accumulate lane tests fail, and all four new cases replay divergent. - Negative control with no inward copy: the landing test fails at 4 bytes past a page (2 read 0, 100 read 16). - Before the low-half change, visibility-counting-accumulate replayed divergent at words 3 and 4. - The combine's low-half test fails on the interpreter without the high-half select ([8, 1] for [8, 0]). clippy (plain and --cfg m2v_gpu), rustdoc and scripts/api-docs are clean. SEMANTICS_VERSION: no translated shader changes, but the owned combine module's words do (main's call). RUNTIME_VERSION and the runtime-sources pin are not touched here. (cherry picked from commit 1c172968ad6492cebcae2a568fc99e90565d4d11) (cherry picked from commit 9f47ebcf006920f7561a16a77f77e422de7201c1) |
||
|
|
d806c0a792 |
Write Boolean visibility results as the device's nonzero query result, without the resolve
Metal's Boolean visibility result is nonzero where any sample passed and 0 otherwise. The Apple M3 Max writes 1; Metal on the AMD Radeon Pro 5300M and the Intel UHD Graphics 630 (macOS 26.7.1, the reims-vgpu team's probes) writes the samples that passed. The runtime had a crate-owned dispatch (bind::visibility_resolve_module) after every pass with a Boolean offset whose only job was to rewrite that word to exactly 1. Under AGENTS.md rule 1 the device's native answer is the only form: a Boolean result is now the imprecise occlusion query's own result, which Vulkan states as "When any samples are passed, boolean queries will return a non-zero result value, otherwise a result value of zero is returned" (occlusionQueryPrecise). Across a split pass's render pass instances the combine still ORs the continuations, so zero stays zero exactly where no instance passed a sample. Counting queries stay precise. - Runtime: the resolve's plan, uploads, sets and dispatch are gone from visibility.rs, and OwnedModule::VisibilityResolve from owned_kernel.rs. A pass with no continuation now records only vkCmdCopyQueryPoolResults. The combine's in-place words are declared as shader reads and writes for every combined offset (they were declared only for Boolean ones). A new precision degradation, DeviceBooleanVisibility (device-boolean-visibility), is announced where a pass's Boolean results record; its catalogue entry is in docs/API.md section 9 and a device-gaps row in docs/FAST-PATHS.md, as for the other native-answer kinds. - Translator: bind/visibility_resolve.rs and its tests are deleted (VisibilityResolve, VisibilityResolveModule, visibility_resolve_module leave the public surface). Its shared helpers (windows, words_buffer, u32_value) move into visibility_combine.rs; the combine's plan tests take the two refusal cases only the resolve's tests held. No translation output changes. - Conformance: a new Loosening::Nonzero, and an allowance may name one element of a byte region as <site>/<byte offset>. The visibility family loosens each Boolean result's word, and only that word, by Nonzero, justified by device-boolean-visibility, which its Boolean cases also declare at the notices site. Every other word still compares exactly. No recording changes. README and docs/CONFORMANCE-COVERAGE.md (regenerated) say so. - Validation lane: every Boolean expectation reads the word by its contract (visibility::by_contract: nonzero and not the buffer's starting word reads as 1), in visibility, framebuffer_fetch, host_bytes, depth_never and amplified_draws; the notice is a new lane site (visibility::BOOLEANS) taken by boolean_results_announce_the_device_s_value and expected where other tests' notice sets are exact. boolean_results_are_copied_with_no_dispatch counts one query result copy and no vkCmdDispatch for a pass of two Boolean offsets. Verified: cargo clippy --workspace --all-targets --all-features -D warnings with --cfg m2v_gpu; the runtime's degradation catalogue and site tests, the translator's combine, owned-division, resolve-helper users', api_surface and api_signatures tests; the conformance suite's 1024 device-free tests. The device lane tests run on the M3 with the next step. (cherry picked from commit a4976cdc3734c21c1b9ed4cf603bbf6bab2523f0) (cherry picked from commit 34e44e3a12a46e6ff4b651cc4689002690d680fc) |
||
|
|
185bbd6328 |
Host steps: record off the scheduler's thread, order by what the execution reaches, make only named states
A batch executing indirect commands the GPU may write waits for its gate, then its host step records the commands from their records. Three costs fell on every other queue meanwhile: - The step ran on the scheduler's thread, which submitted nothing while it recorded (thousands of draws take milliseconds). - Its footprint was unknown (tracker::ordered's None), so every later batch of another queue that made a tracked use was held behind it until it was submitted. - At commit, the render settle made a VkPipeline for every live state that supports indirect command buffers, times the topology class's primitive types (1,280 lookups and 513 makings for 256 live states on the measured frame), and the step waited for all of them, up to the command buffer's bound. Now: - The scheduler hands each step to a steps' thread (scheduler/steps.rs, started at the first step, user-interactive like the scheduler's, recording inline where the host cannot start it), which records the steps in order, each a section of the exit guard, and wakes the scheduler. The batch is marked as stepping meanwhile (CommandBufferShared::begin_step/end_step), so it waits and no pass hands it over twice. - commit bounds a step's uses where it can (Segment::bound): for a compute execution, the resources the command buffer made resident and the ICB's storage (and an indirect range's copy); for a render pass, the pass's own uses, the resident resources and each execution's storage. CommandBufferShared::footprint uses that bound, so only a later batch sharing one of those is held. An execution that inherits buffers, is gated or preprocessed, reaches tile memory, has shadows or lends visibility stays unbounded (None), as before. - The render settle makes the states the CPU set on the executed commands (IndirectCommandBuffer::set_render_states, each state once), or the inherited one. A draw of a state a GPU-written record names that no settle made is begun at the step, made on its thread or handed to the device's pool and waited for until the command buffer's bound, as before; it holds no other queue's batch, and it is counted. On the kept recordings of the commit before (item 1), set_render_states reads the states the CPU set from the buffer's per-command map (Commands::states, a range of it), each state once. New counters: WorkCounts::host_steps_recorded, host_step_nanos, and host_step_pipelines_made (the VkPipelines a step began itself, made on its thread or handed to the device's pool and waited for: counted at the variant's making on the step's thread and at pipeline_pooled). The degrade notice host-replayed-indirect-commands states the new cost (degradation.rs and docs/API.md, same text). Verified on the M3 Max (MoltenVK 1.4.2), release, runtime_lane::host_replay_frames (the next commit: 256 live states, an ICB of 5000 draws naming 4, made resident for writing by a compute pass each frame, and a presenter clearing a texture on another queue every 8.33 ms), the parent and this tree run alternately twice, 60 frames each after 4 cold ones, on a loaded host: - the presenter: 80 of 244 and 73 of 192 ticks presented before (commit to completion median 16.9 and 16.4 ms, p90 40.8 and 23.7 ms), 186 of 186 and 185 of 189 after (1.13 and 1.13 ms, p90 1.49 and 2.23 ms); heads held behind earlier commits 23 and 13 before, 0 after; - the first frame's commit: 377 and 168 ms before (513 variant pipelines made, 1,284 looked up), 5.3 and 5.1 ms after (9 made, 24 looked up); a steady commit 2.38 and 2.33 ms before, 0.14 ms after; - the frame itself (commit to the last completion): median 28.7 and 24.4 ms before, 23.3 and 24.6 ms after, within the host's noise; the host step takes about 20 ms of it (host_step_nanos), recording the 5000 draws. The consumer's ICB repro (one state, 5001 draws, the ICB made resident for writing, another queue's one-dispatch command buffers meanwhile), same runs: that queue's commit to completion at the 99th percentile 53.5 and 24.3 ms before, 2.96 and 3.71 ms after, 140 and 119 command buffers in 40 frames before, 2,281 and 2,062 after; the frame alike (21 to 26 ms). Tests: runtime_lane::render_executions:: a_host_step_makes_the_pipeline_of_a_state_only_a_gpu_written_record_names (a blit-copied record naming a state, of another variant, that the CPU set on no executed command: both commands draw, the step's beginning of that state's VkPipeline is counted, and the step's time). --cfg m2v_gpu under the validation layer, on this tree before the pipeline_pooled count and the test: 234 tests of the indirect_*, kept_*, render_executions, render_gpu_executions, render_merged_executions, mesh_commands and executions lanes; 1,644 tests of the runtime crate's lib and the commands_recorded, dispatch_executions, generated_executions, kept_variants, device_commands, queue_order, submission_checks and grouped_submissions lanes. clippy -D warnings, plain and --cfg m2v_gpu; rustdoc -D warnings; scripts/api-signatures --check. Needs a RUNTIME_VERSION bump (what a run submits, when, and its counts) and a runtime-sources pin. (cherry picked from commit 4b05004999403684a2bdf4f3994108b53c7dc776) (cherry picked from commit 3831ba7e1298203779597feb0ea2943f77f9f5df) |
||
|
|
565fbd9153 |
Run unchanged indirect commands from kept recordings, chunk by chunk
An execution of an indirect command buffer read, decoded and recorded every command again at every commit, so an unchanged execution of 16384 draws cost about 44 ms of commit on the M3 Max and 64 ms on the RTX 5080 laptop, where Metal's costs 2 ms. A profile of the render case put a third of it in the records' decode and moves and the rest in recording the draws. Now an execution of commands the CPU encoded records them in chunks of 256 (kept_commands.rs). A render chunk records into a secondary of its own, begun for simultaneous use against the instance's compatible pass, through an encoder over a core of its own whose effects the pass's core takes (EncoderCore::capture, absorb); a compute chunk records as a segment of its own, behind a barrier from everything before. Each chunk takes its command pool, descriptor arena and uploads from a context of its own, lent to the command buffer while it records and held by every command buffer that runs it. A chunk whose recording is plain (every draw passes draw_again's keep test but for being replayed, no step outside its command buffer, nothing its command buffer alone holds, no released state) is kept on the buffer with what it was recorded from: the encoder's inputs (RenderKey, ComputeKey: the inherited state, the pass's compatible pass, shape, extent and sample positions, the encoder's state and scissors, the resident resources), each address its commands named and what it resolved to, and the no-copy moves. A later execution of the chunk under equal inputs, every address resolving as before, nothing detached and every held object alive, runs the kept command buffer and notes its uses, keys, holds and executions again (EncoderCore::run_kept), reading no record. Every CPU write of a command forgets its chunk under the lock the write takes; the buffer's first GPU write forgets them all; a recording from records written meanwhile is not kept. A chunk that is not plain records the rest of the range as before and is noted, so later executions of it record as before until a write reaches it. The buffer's per-command state moves to a map, so a buffer of commands never encoded holds nothing for them. WorkCounts::indirect_chunks_kept and indirect_commands_kept count the kept path. docs/FAST-PATHS.md's known gaps list the executions that still record every command at every commit. Verified on the M3 Max (MoltenVK 1.4.2), --cfg m2v_gpu, under the validation layer: runtime_lane::kept_commands, 5 tests: unchanged render commands run 3 kept chunks of 600 commands reading no record, into another target and twice in one pass; a command written again or reset records its chunk alone; a blit's reset runs no kept chunk and its commands draw nothing; another residency or range records again; compute commands the same, with a command written again and a blit reset. 446 of 448 tests of the 33 lanes that execute indirect commands pass; the two others (extended_range_blends half outputs, padded_loads loading pass) are among the MoltenVK reds the parent already has. clippy -D warnings, plain and --cfg m2v_gpu, for the runtime and validation crates; the runtime's kept_commands unit test; the translator's fast_paths, api_signatures and api_surface tests. Needs a RUNTIME_VERSION bump and a runtime-sources pin. (cherry picked from commit 21b9438ec5b8cbf7a1e79c5dfbf84cdad7b43d91) (cherry picked from commit 922caf3199378b029bafc201429f80b0d43bb048) |
||
|
|
b74a0a4866 |
commit_and_submit: run a head's submission checks on the committing thread
What: a thread in CommandBuffer::commit_and_submit now runs the submission
checks of the head committed first of all itself, without the scheduler's
lock, right before it submits that head, where the head is ready but for its
checks (no host step, no group, no storage-form switch, no rebind) and every
event value it waits for was reached on the device or by the host. It then
passes again under the lock (Inbox::pass_again, which takes nothing in) and
submits that head first, and so on up to PASS_SUBMISSIONS batches in all. A
head whose checks wait for a submitted GPU signal to land, or whose checks the
scheduler's thread took first, stays the scheduler thread's, as before.
Why: reims's Vulkan platform sets a check on every command buffer it commits,
so commit_and_submit never submitted at commit for them (plain_ready held out
every checked head). Metal checks a submission as it submits it, on whichever
thread submits, so running the check on the committing thread is Metal's
behaviour; the check follows the submission handler's rule there (no lock the
caller holds, no GPU wait).
How:
- Held::checks_taken marks a batch whose checks were taken, by check_heads
(left to the scheduler's thread, replacing its Left::holds lookup) or by a
committer (claim_check), so the two never both run them.
- claim_check looks at Order::first_mut (the head take_first would take), so
no head is passed over: commit order holds across threads.
- The committer's handlers keep their Turns tickets: each pass under the lock
takes its own ticket, and its handlers run before the next check.
- The check runs through run_work -> CommandBufferShared::run_checks, the
scheduler's own path, so a code (or a panic) fails the submission exactly
as there (fail_submission, the CB completing with Injected(code)).
- plain_ready now holds out only a checked head whose checks are still to run,
so a head whose checks ran goes with any plain pass.
- Counted: WorkCounts::batches_checked_at_commit (new), beside
batches_submitted_at_commit; classified as Submission by its "batches_"
prefix in the conformance cost rules.
Verified on the M3 Max (MoltenVK, --cfg m2v_gpu, maclock, load 50-90):
- New tests in tests::commit_and_submit:
- a_checked_command_buffer_is_checked_and_submitted_on_the_committing_thread:
40 of 40 checked and submitted on the caller, check then handler, before the
call returned; batches_checked_at_commit 40.
- a_refusing_check_fails_its_submission_alike_at_commit_and_on_the_scheduler:
two submissions split by an event signal, the second refused with code 8:
identical status, error, completed-handler status, submissions seen, bytes
and event value on both paths.
- checked_command_buffers_keep_commit_order_across_commit_and_commit_and_submit:
2 threads x 500 checked CBs, commit and commit_and_submit in turn: checks
and submission handlers in commit order, each check once; 308 of 1000
checks on a committing thread.
- The five commit_and_submit tests: --stress-count 10, 10/10 passed.
- Negative controls:
- claim_check answering None: all three new tests fail (0 checked at commit).
- claim_check neither honouring nor setting checks_taken: the order test
fails 4/4 (checks out of commit order, checks run twice).
- runtime_lane::submission_checks' in-flight test gains a commit_and_submit
variant whose wait is met only by a GPU signal in flight: its check ran only
after the signal landed and never on the caller, Event and SharedEvent.
submission_checks, grouped_submissions and queue_order lanes: 24/24 passed.
- Runtime tests matching scheduler|check|teardown|completion|submission|inbox|
order: 169/169 passed. Conformance cost, fast_paths and api_signatures
tests 38/38; clippy -D warnings (runtime + validation, --cfg m2v_gpu) clean;
public rustdoc clean. api_signatures.tsv blessed (one new field).
(cherry picked from commit 91d0ea691a95649cbdc7828d4cc9ee6762a7ae53)
(cherry picked from commit 6c5fca926e855ee7d7236bc850bb9b281f4dd9cd)
|
||
|
|
7e48216b37 |
Make the canonical encoding's image scratch without zeros
What: under ExtendedRangeBlitPolicy::Canonical, a blit into a compressed BGRA10_XR or BGRA10_XR_sRGB image rewrites its texels through a scratch buffer: a copy out, one dispatch a region, a copy back. The scratch was made with Device::own_buffer, which zeroes a Private buffer in a submission's first work (a copy of the device's zeros on a device with unified memory, a fill on a discrete one), in a command buffer of its own. The copy out writes every byte the dispatches and the copy back read (the regions, tightly packed) and nothing reads the alignment gaps, so the scratch is now made with Device::unzeroed_buffer (Private, tracked as before), as shadow_merge's fully written scratch already is. Nothing the program or Metal observes changes; the work counts do. Why: the whole-set conformance cost check on the M3 Max read compressed-blits-bgra10xr and its sRGB twin over their records since |
||
|
|
7996b9a164 |
Mark a queue long by its command buffer's own GPU time, not the host's view of its head's age
What: a command queue is now marked long where one of its command buffers' own timestamps (its first batch's start to its last's end) span over LONG_HEAD (2 ms), in the completion turn that read them (CommandBufferShared::place_gpu_times), before the turn finishes it. The waiter's host-age check in command_buffer/completion.rs (HeadWatch, Device::head_watch) is removed, and went_long returns at once unless the device shares. A device whose command buffers write no timestamps the host reads (gpu_times_from_host, a driver whose timestamps wait for every queue's, or no calibrated timestamps) no longer shares: queue_switch_check::timed() gates the check, and recall settles Unchecked and counts the new WorkCounts::queue_sharing_untimed where the device has two VkQueues of one family to share. Two runtime extensions, doc-hidden, for the lanes and the probe: CommandQueue::vk_queue_sharing() (its VkQueue and long mark) and Device::shares_vk_queues(). Why: the host's view of a batch's age as its VkQueue's oldest also holds its wait for the GPU to start it and the waiter's lateness to see it complete, so short command buffers marked their queues long for good. On the RTX 5080 Laptop GPU, 2x3 runs in a slow stretch had each thread's queue marked long mid-run (at 20 ms to 1,238 ms) and settled apart, the PerQueue placement, at PerQueue's rates. Measured cause, with a diagnostic build printing each host-age mark beside the command buffer's own GPU span: beside another process's 30 ms command buffers, draws of 11 and 16 us of GPU time were seen 2.0 and 2.3 ms after they became their VkQueue's oldest, 1.8 and 2.1 ms of that before they started; that run's thread queue settled apart and ran at PerQueue's 4.1k. In the runs without contention, every true mark had a GPU span within 1.2 ms of its host age (the 30 ms command buffers and the probe's 2.7 ms sizing one); under contention the sizing command buffer's host age exceeded its span by 4.2 ms. Neither suggested alternative fits: the false marks came mid-run, not only in a queue's first command buffers, and decaying the mark after short heads would let the trap and alternating shapes' long queues rejoin and stall the compositor again. Tests: tests::queue_share_device gains a_device_that_answers_gpu_times_from_the_host_does_not_ share_and_counts_it (expected, not run, to fail without the gate on the 5080: there it printed "Unchecked ... could share: true", so the recorded Idles verdict would make it share), and asserts queue_sharing_untimed == 0 elsewhere; its isolation runs print each queue's VkQueue and mark over the run. The queues lane's a_queue_joining_another_s_busy_vk_queue_is_announced_once now makes its device under QueueSharingPolicy::Adaptive (over the lane's exact_answers()), lets the busy queue's fills be submitted first, and asserts queue_joins > 0 exactly where the device shares, saying why where it does not. cross_queue_shadows gains the signal-in-between and the waiting-writer cases on one VkQueue: no spin, Adaptive, the check settled, queue 2 joining queue 1's busy VkQueue; they assert the join, neither queue long, the hold still withheld while the waiting writer has not completed, and the bytes. Docs: QueueSharingPolicy::Adaptive, the FAST-PATHS row (the rule, the untimed exclusion, the new ranges), docs/API.md (the policy section and the notice), the queue-sharing notice's cost text, queue.rs and queue_share.rs; api_signatures blessed (additions only). Verified on the RTX 5080 Laptop GPU (NVIDIA 615.71.09, msi, under gpu-locks, no VM), release probe: - 2 threads x 3 in flight, 10 runs each in turn: Adaptive 48.3, 28.0, 50.7, 52.9, 28.1, 53.7, 48.6, 29.9, 31.5, 53.0k against PerQueue 21.4, 24.9, 27.8, 28.0, 27.6, 27.4, 27.1, 23.3, 26.9, 27.3k, Adaptive above PerQueue in each pair; no thread's queue marked long in any run (gone long 1 each: the probe's sizing queue). The 28-31k runs keep the shared placement, with waiter parks 0.23 against 0.02-0.05 per command buffer in the fast ones: a host-side mode, not a move. - Beside another process's 30 ms command buffers, 3 runs each: the old rule 4.1k (a thread's queue marked long by its host age), 5.2k, 6.6k; this rule 6.7k, 5.4k, 5.1k (no mark); PerQueue 4.1k, 4.1k, 4.0k. There, draws' own spans reached 1.16 to 1.52 ms (timesliced), under the bound. - Isolation, 3 runs each: trap and slow-alternating 64 completions over 10 ms under Adaptive (the one first-long stall, at most 26.4 to 30.1 ms) against none under PerQueue (at most 5.6 to 9.7 ms); alternating none under Adaptive (at most 5.7 to 9.8 ms) against 7, 0, 0 under PerQueue. Unchanged from the host-age rule's runs. - 8 threads: 3 in flight 53.4k, 54.4k against 27.8k, 27.4k; 1 in flight 50.1k, 49.3k against 14.0k, 13.9k. - Device tests (debug, --cfg m2v_gpu): tests::queue_share_device 8/8, the joining lane test and cross_queue_shadows 7/7 (the one-VkQueue cases: X's and Y's queues both on VkQueue 1, neither long, holds withheld 2, gated copies in 2). The compositor isolation test, old rule and new in turn, 3 each: p99 2.66-2.94 ms against 2.16-2.83 ms, 0 stalls, the same placement (the compositor alone on VkQueue 1, the application long on VkQueue 0, gone long 1). Its one earlier failure under this rule (p99 7.93 ms, 20 stalls, 5,579 of ~9,600 commits made) ran right after a 74 s compile inside the hold, with the same placement and gone long 1: host load, not the rule. On the M3 Max (MoltenVK, no sharing), tests::queue_share*, command_queues, cross_queue_shadows, gpu_time and host_memory: 90/90. clippy -D warnings plain and --cfg m2v_gpu; RUSTDOCFLAGS=-D warnings cargo doc; fast_paths, degradation*, api_signatures, api_surface, work_counts pass. No RUNTIME_VERSION bump or pin here. (cherry picked from commit 4fd88b7564cd9cd3651543bb3f8cd529b021709e, two claims corrected to what was run) (cherry picked from commit eb0153e9d0fe6d272f2411c65f0a1ecda2c78bc2) |
||
|
|
aa9b38e6fd |
State the padded sRGB twins' code and decode bounds as measured
DevicePackConversion's documented bound for the extended-range and padded conversions said "a code within one" of Metal's. For R10Unorm_X6_sRGB and RGB10A2Unorm_sRGB that is wrong. Metal's write of these formats rounds the value clamped to [0, 1] to 2^-13 (nearest even) and then looks it up in its encode table (R10X6_SRGB_ENCODE_FIRST). The device writes the MSL transfer by its own maths, times 1023, RoundEven. In the transfer's linear segment, one 2^-13 step spans 1.6 codes, so the two can land two codes apart. Measured: for each 2^-13 step over [0, 1], the f32s at and next to both edges, where Metal's code is constant within a step and the device's code rises with the value. The device's code (exact transfer) lies at most two from Metal's table. It reaches two only below 0.0031308: at 1.5/8192, just above 6.5/8192, and at 24.5/8192. Everywhere else it is within one, beyond the Pow's bound. Metal's recorded writes and stores of RGB10A2Unorm_sRGB on the M3 Max under macOS 27.0.1 (rgb10a2-srgb-writes, -stores-f, -stores-h) show exactly that: three words each, at k/16384 for k = 3 and 49, and at the 1.5/8192 special. Metal's decode of RGB10A2Unorm_sRGB's colour (the rgb10a2-srgb-reads recording, every code) lies up to 1.637 steps of 2^-13 from the exact transfer (code 952: Metal 0.84912109, exact 0.84932096). That is the 1.64 the docs gave for R10Unorm_X6_sRGB only. So artifact.rs's DevicePackConversion, the FAST-PATHS air.pack row and API.md's catalogue entry now give, for those two formats only: a colour code within two below 0.0031308, and a decoded colour within 1.64 steps. Doc text only: the device's conversion is unchanged (rule 1), and so is behaviour. No version bump. (cherry picked from commit 8bfaab43bd6c6368c41d58caa7e9c91fe64820d5) (cherry picked from commit e728f0fa394c46c528d2f99df89a33751f5691d7) |
||
|
|
e94d068b3b |
State the queue sharing row's measured rates over the 5080's spread
What: docs/FAST-PATHS.md's queue sharing row now gives each shape's measured range with its run count, in place of the first three-run set's. Why: two more sets on the RTX 5080 Laptop GPU (NVIDIA 615.71.09, release, one-draw command buffers, each thread its own queue) widened the ranges: - 2 threads with 3 in flight: Adaptive 27.0k to 46.5k a second in 13 runs after a hold's first. It fell within one hold, from 42.5k to 27.0k, while PerQueue stayed at 25.6k to 27.5k. Two more runs gave 15.4k and 17.7k; in both, one of the two queues was marked long as it began (gone long 2 or more, against 1 in every fast run). PerQueue: 25.2k to 27.7k in 14. - 2 threads with 1 in flight: 16.9k to 20.7k against 10.1k to 11.5k (5 each). - One thread over 16 queues in turn: 21.7k to 43.3k against 10.2k to 11.1k. Over 2,048: 20.0k to 39.2k against 10.2k to 11.2k (4 each). The 8-thread shapes keep their three-run ranges. One third of one hold, where both policies fell to 8.1k to 13.0k, is left out. Under PerQueue the pair of VkQueues made no difference: 2 x 3 with the second queue 1, 7 or 13 places after the first ran 25.6k to 27.5k. Verified: tests::fast_paths (19 passed). (cherry picked from commit adb362078504cca24358e8d9c331eb1b831a2b57) (cherry picked from commit 27999318cbb31bc8a46f24a28c40a6b80c7e2f4d) |
||
|
|
be47523f80 |
State queue sharing's residual stall and the unshared form for queues that must never wait
What: docs/FAST-PATHS.md's queue sharing row, docs/API.md's policy bullet and the runtime README's new_command_queue_unshared entry now state the residual stall exactly: once per logical queue that goes long, for a queue that joined its VkQueue during its short phase, about one long command buffer's length. They also say a queue that must never wait (a compositor's) is made with Device::new_command_queue_unshared. The row's cost column carries the measured rates. The queue_share example's rates mode takes --threads, --in-flight and --one-vk-queue for one shape. It prints each command buffer's GPU end and commit to its completed handler, the submission, scheduler and wake counts per command buffer, and the busiest threads' CPU from /proc (Linux). Why: on the RTX 5080 Laptop GPU (NVIDIA 615.71.09, release, 3 runs a side), the trap and slow-alternating shapes cost a shared compositor 64 completions over 10 ms, at most 29.4 to 30.6 ms, in every run, with one join each. That is the first long command buffer of the application it joined during the application's short phase. PerQueue had none in 5 of those 6 runs and 4 in the sixth (at most 3.7 to 10.7 ms). An unshared compositor had none over 10 ms in any run. No join rule built on what a queue has shown can avoid the first one: the long command buffer gives no sign before it runs. A re-pick at submission would not either: the compositor holds about 4 uncompleted command buffers at each commit (p50 commit to handler 0.78 to 0.87 ms at a 208 us period), and the stall is all or nothing in a queue's own order. So the docs name the unshared form as the answer for such a queue. The probe settled the 2 threads x 3 in flight drop (15.4k against 26.0k a second in one run): it was the lock hold's warm-up. In the hold's first runs both policies ran slow (11.1k and 10.4k), and later runs gave Adaptive 46.5k and 39.7k against PerQueue's 25.2k and 26.5k. Two queues on one forced VkQueue ran 38.1k to 46.6k under PerQueue and 41.4k to 49.9k pinned under Adaptive, so one VkQueue is not slow in the runtime's path. No runtime thread was busy in the slow runs (scheduler 10%, handler threads 5%, waiters 3%), and every shape made one vkQueueSubmit per command buffer. Verified: tests::fast_paths, degradation_catalogue and degradation_sites (25 passed); clippy of the example with all features. (cherry picked from commit b1dbea95dad3a5a156191df01084db0f86cb67a0) (cherry picked from commit 24af60dbf8175da8e60ea24f38f9103c20c23e8b) |
||
|
|
510e0c0cca |
Share VkQueues between command queues where the GPU idles at each switch, with an unshared opt-out
What: a new DevicePolicy switch, queue_sharing: QueueSharingPolicy { Adaptive (default),
PerQueue }; exact_answers() selects PerQueue. Under Adaptive, on a device whose own self-check
finds its GPU idle when consecutive work comes from another VkQueue, a command queue chooses its
VkQueue again each time it makes a command buffer while it holds no other uncompleted one (the
slot take with held.all == 1, under its slots lock): it joins the busy VkQueue of its family
whose oldest batch has run under 0.5 ms, the most batches in flight first, then the latest
submission (Device::pick_vk_queue: one pass of atomics over the round robin's VkQueues, no lock).
A queue whose batch ran over 2 ms as its VkQueue's oldest is marked long by the waiter that saw
it complete, under the completion's pending lock, before the turn that finishes it
(command_buffer/completion.rs); no queue joins a long queue's VkQueue, and the long queue moves
once more at its next idle point, to the least recently used idle VkQueue no long or unshared
queue holds. Its mark moves with it and a dropped queue subtracts its marks. Presenting queues and
a queue that lent its VkQueue (with_vk_queue, pinned from then on) never move. A queue's vk_queue
is now an atomic; everything that reads it does so between a command buffer's make and its
completion, when no move can happen.
The self-check (queue_switch_check.rs) is the runtime's own, kept like the in-place check's, not
a DriverFact row: on a thread of its own, once per driver, release and runtime, 24 rounds of two
timestamp-only batches held behind one host-signalled gate on two same-family VkQueues against
24 on one; the switch cost is the difference of the median gaps; Idles above 20 us, DoesNotIdle
below, Unchecked where the device has no calibrated timestamps, no two VkQueues of one family, or
a run failed. Its verdict is written as one record in the shader cache's content directory and
read back as the next device of the same driver, release and runtime is made. Before the verdict,
every queue keeps the VkQueue it took at creation.
Device::new_command_queue_unshared(count): a queue that never moves and that no adaptive queue
joins; a queue already on its VkQueue leaves at its next idle point. Placement where the device
shares: a round-robin VkQueue no command queue holds, least recently used first; else one no
long or unshared queue holds, the fewest queues first; else the round robin's next. Why that
order: an empty VkQueue gives isolation at once, with no wait for another queue's idle point; of
the empty ones the least recently used is the one least likely to hold a moving queue's work in
flight (a queue that just left it may still have batches there, and the unshared queue would
wait behind those); where none is empty, the least held one has the fewest queues to move off,
each at its own next idle point, so isolation arrives soonest, and a VkQueue a long or unshared
queue holds is never taken since that would put the opt-out behind exactly the work it opts out
of. A queue's claim of a VkQueue and an unshared queue's are ordered so that two at once never
both succeed: each counts itself there first, then reads the other's count (SeqCst both sides).
Under PerQueue, and where the device does not share, it is
new_command_queue_with_max_command_buffer_count. A count of 0 and a lost device are refused.
Why: NVIDIA 615.71.09 on the RTX 5080 Laptop GPU leaves the GPU idle 56 to 62 us whenever its
next work comes from another VkQueue, so one VkQueue per command queue, round robin, capped eight
threads' one-draw command buffers at 25,800 to 29,500 a second (GPU idle 60% of its time at the
switches), where one VkQueue ran 54,700 to 58,700 (the audit that set this design). Moving only
at idle points keeps every queue's own order without a cross-queue fence. The cost is the
runtime Degradation kind QueueSharing ("queue-sharing", performance), announced once per device
at the first join, in CommandQueue::command_buffer on the making thread: the first long command
buffer of a queue that shared holds the command buffers committed behind it on its VkQueue for
its whole length. The opt-out exists so a compositor never pays even that one stall.
Counted: WorkCounts::queue_moves, queue_joins, queues_gone_long, long_queue_settles,
queue_moves_off_unshared, joins_withheld_from_unshared, queue_switch_checks_run and
queue_switch_checks_recalled. The policy keys no profile (tests::fast_paths), so
SEMANTICS_VERSION does not move. Docs: FAST-PATHS row, docs/API.md (the policy and the notice
catalogue), the runtime README (the opt-out, with_vk_queue's pin), queue.rs's module doc on
isolation; REFUSALS regenerated (the new site of MaxCommandBufferCount); api_surface and
api_signatures (additions only). The example queue_share runs the workloads under either policy.
Verified: cargo clippy --workspace --all-targets --all-features -D warnings, and the runtime and
validation crates with --cfg m2v_gpu; RUSTDOCFLAGS=-D warnings cargo doc --workspace
--all-features --no-deps; nextest of tests::queue_share (the choice, settling, the unshared order,
the record), tests::fast_paths, tests::degradation*, api_surface, work_counts: 66 passed. On the
RTX 5080 Laptop GPU (release) the check answered Idles at 51.3 us, and its form measured 49.0 to
50.7 us in five more runs, where a chained form measured 53.2 to 59.3 us. The device tests
(tests::queue_share_device, runtime_lane::command_queues::a_queue_joining_...) are not yet run
on a GPU in this commit.
(cherry picked from commit a2f17a5132faf0312fb3953d634e21c927cde62e)
(cherry picked from commit 862b2cb49a9481d0a2a19fb1bc3acec79932d1bd)
|
||
|
|
a1ee191fd1 |
Filter a 3D mipmap chain by compute where the driver's blits do not filter a volume
the_device_s_blit_chain_filters_each_level_and_is_announced failed on the
Apple M3 Max through MoltenVK 1.4.2 for its 3D textures only. Measured there:
vkCmdBlitImage with VK_FILTER_LINEAR from level 0 of an 8 x 8 x 4
R8G8B8A8_UNORM image into level 1 does not answer Vulkan's linear filter, the
average of the eight texels around each destination centre. Of the level's
128 bytes, 4 lie within a code of it, 67 within a code of source slice
2z + 1's four texels alone, and 2 of slice 2z's alone. 2D, 2D-array and cube
blits filter as Vulkan states. NVIDIA 615.71.09 on the RTX 5080 Laptop GPU
filters the same 3D image correctly, and the test passes there. So this is a
driver difference, and FAST-PATHS row 73's claim of the blit chain "where its
blits filter the format" did not hold for a volume on MoltenVK.
Following the runtime's driver-defect pattern:
- New RuntimeDriverDefect::VolumeBlitsUnfiltered, with Affected { MOLTENVK,
clean: &[] } in driver_defects.rs, keyed by driver as the other defects are,
never by the release. Its doc holds the measurement.
- `plan_mipmaps` takes the driver's defects. A 3D texture on such a driver
takes the compute filter (MipmapPlan::Filter) where the filter computes the
format. Elsewhere the blit chain stays, announced as before
(device-filtered-mipmaps). Nothing is refused, and no note is added.
- blit_texture.rs passes the device's defects. The mipmap_plan unit tests pass
them too.
- New unit test a_volume_takes_the_compute_filter_where_the_driver_s_blits_do_not_filter_it.
It fails without the change.
- tests/driver_defects.rs lists the defect for MoltenVK.
- api_signatures.tsv has the new variant, and FAST-PATHS row 73 names the
defect. REFUSALS.md regenerated with no change.
- mipmap_chains expects the compute filter for 3D textures where the device
has the defect, each level still within a code of the filter. Its diagnostic
print is removed.
Verified: cargo nextest run -p metal2vulkan-runtime for the mipmap_plan and
driver_defects tests passes, and the new test fails without the change. The
lane test's M3 rerun follows.
(cherry picked from commit a160bb01e43d7e5f4916b700012663a4020cf2a7)
(cherry picked from commit 7e77515beeb4d938a67de4b659ad31b8bed3394f)
|
||
|
|
78f6377e4a |
FAST-PATHS: an empty command buffer is not submitted, so drop its old commit-to-completion number
The commit-to-completion entry measured an empty command buffer against a bare barrier (51.6 µs against 45.1 µs on a Radeon 780M). Empty command buffers make no vkQueueSubmit now; the submit path's bench measured commit and wait at 2.6 µs on the RTX 5080 and 1.8 µs on the M3 (p50). The timestamp cost on MoltenVK and its switch are unchanged. (cherry picked from commit f7abac8bbb7971b7bb9fd2c8638af94d7f96f51e) (cherry picked from commit bef265b91124cc376bbeda1fead475bd87ebf805) |
||
|
|
36f5029870 |
commit_and_submit: the committing thread submits for itself
A runtime extension. CommandBuffer::commit_and_submit commits as commit
does, with the same checks and refusals. Then, where no submission pass is
under way, the calling thread becomes the passer (Scheduler::
submit_at_commit, Inbox::pass_once_then). It takes in the inbox and submits
the ready heads committed first, in commit order, up to PASS_SUBMISSIONS,
while each needs no host step, no submission check, no group, no storage-
form switch and no rebind (plain_ready with Passer::Committing:
submits_without_the_program's handler exclusion dropped, the rest kept).
Still counted as the passer and outside the state lock, it runs their
submission handlers, then lets go of what the pass held; a last reference
goes through let_go_elsewhere. It then counts out, wakes the scheduler's
thread where it left work or a commit was handed to it meanwhile, and makes
an owed completion turn. The commit is posted with no mark and no wake
(Inbox::post_quietly, Hand::Pass), so the scheduler's thread is not woken
for work the committer takes. A plain transition to Scheduled runs inline
as its batch is published; one with scheduled or submission handlers goes
to its queue's context as before. Called from the runtime's own threads (a
handler on the scheduler's thread or a waiter) it commits as commit does.
Plain commit is unchanged: Metal's commit returns before scheduling.
Submission handlers keep submission order whichever thread runs them.
Each pass that takes batches with submission handlers takes a ticket
under the scheduler's lock, in pass order (State::handler_ticket), and
runs them once every earlier ticket's ran (Turns). This departs from
the design's "handlers then count out": the scheduler's own pass counts
out before running its handlers, so a counted committer alone cannot
keep them in order. The new order test showed it: without the turns its
handlers ran out of commit order in 4 runs of 4.
Counted: WorkCounts::scheduler_passes_at_commit,
batches_submitted_at_commit (the conformance cost's scheduler_ and
batches_ prefixes already cover them). Docs: the method, the scheduler
and inbox module docs, add_submission_handler's thread bullet, the
runtime README's extensions, RUNTIME-PORTING, and FAST-PATHS's "commit
returns at once". api_signatures blessed (3 added); REFUSALS regenerated,
unchanged.
Verified on the M3 Max (MoltenVK 1.4.2), --cfg m2v_gpu:
- tests::commit_and_submit, 6 runs:
- the submission handler ran on the caller inside the call, reading
Committed, 40 of 40, with the scheduled handler on a handler thread;
- 1000 command buffers from 2 threads alternating commit and
commit_and_submit: handlers in commit order, 362 to 449 of them on a
committing thread;
- a checked head and the one behind it were left to the scheduler's
thread, with 0 batches at commit.
- Negative control: Turns::wait made to return at once failed the order
test 4 of 4 (e.g. 238, 239, 240, 255, 256, 241).
- The runtime suite: 1512 passed.
- clippy -D warnings with and without --cfg m2v_gpu, and rustdoc
-D warnings, clean.
RUNTIME_VERSION and the runtime-sources pin follow at hand-over, on the
lane tip.
(cherry picked from commit 5909e96c63004822e2a22d4cbf27b998f90e75a8)
(cherry picked from commit 40a67ba10398c38f13494fcdf3f64c2925f7eba8)
(cherry picked from commit 4270a52b85cfcd8c5a3cd8ea201b1a731a261eac)
|
||
|
|
91cdb80938 |
Say what a YCbCr twin's half sample through a runtime sampler slot rounds to: measured toward zero
What: PrecisionNote::HalfTexelConversion's doc, its docs/API.md catalogue entry, docs/FAST-PATHS.md's
texel-conversion row and the comment where select.rs records the note said a two-plane YCbCr
texture on the grid 8192, sampled through a runtime sampler slot whose word reads one texel,
rounds that texel's step to nearest even. It is the device's rounding of the step's float, and
on MoltenVK 1.4.2 over the Apple M3 Max that is toward zero: runtime_lane::ycbcr_textures'
srgb_twins_read_what_metal_reads measured 8,409 channels of the _sRGB twins over six surfaces and
three matrices, each within one half ulp of Metal's ties-away step (lane commit
|
||
|
|
4837c93ca4 |
Announce decoded-texel-precision at the decoded twin's first read, not at its texture's making
What: a decoded twin whose texels are not Metal's decode exactly (an ASTC LDR form's 8-bit codes, an EAC 11-bit format's 16-bit codes, a 4:2:2 texture's device conversion) announced decoded-texel-precision where its texture was made, though only a sampled view reads the twin: copies, blits, fills and CPU accesses move the carrier's blocks. A consumer that makes notes fatal died on a test that only fills a BGRG422 texture and on one that checks the runtime's fills. How: the twin carries what a read of it announces (TwinRead, made with the twin and with an ASTC carrier's second twin). It is announced, once per device, where a command may first read it: - Texture::bound_view, a command's sampled binding of the texture or a view of it: the set-0 slot path (slot_view, draws, dispatches, tile dispatches) and a heap entry a command names (binding.rs); - heap_sets::bind, the first command that binds a heap set holding the twin's view, named or not (each set keeps its twins by resource ID beside its shadows); - a twin's placement into a heap set whose shared version a command buffer that bound it and has not completed still holds, or whose own version an uncommitted command buffer bound (SetEntry::twin), announced once whatever announce_each says, as a submission may place it on a runtime thread. Placing the view in a heap set uses Texture::held_view, which announces nothing. carried-decoded-twin (performance) is still announced where the texture is made. Docs: degradation.rs's contract, docs/API.md's catalogue entry and docs/FAST-PATHS.md's ASTC and 4:2:2 rows say where it is announced; texture/decoded_twin.rs's and heap_sets.rs's module docs gain the reads. Lanes: texture_fills and texture_blits' mipmaps no longer expect the note at making (twins_carried keeps its carried half alone). Conformance: the allowances of cases that read no twin (texture-fills, chroma-pair copies, texture-pairs-usage-crossings, format footprints) no longer name decoded-texel-precision; the reads' and samples' keep it. Test: tests::twin_reads walks every route on a device of its own (ASTC_4x2_LDR on every device, BGRG422 and GBGR422 where the device converts them): made, written by replace_region and blits, filled, copied and read back announces no decoded-texel-precision; the route's first read (slot read, sample, gather, a view's read, a heap read named and unnamed) announces it once; a twin placed in a set a pending command buffer bound announces as it is made; an ASTC sRGB twin announces nothing and its LDR view's second twin announces at the view's first read. Verified at this commit: tests::twin_reads (3 tests) and ycbcr_device's 4:2:2 test pass on this M3 Max (MoltenVK 1.4.2, --cfg m2v_gpu), walking ASTC4x2LDR, BGRG422 and GBGR422. (cherry picked from commit 37f72d3ffb402ad9afae9571489edbf2b8157442) |
||
|
|
a00edd042e |
Measure what extended_range_blits = Canonical costs against Kept
The ledger's extended_range_blits row said "Not measured". It now gives the cost of Canonical against Kept on two hosts. The consumer will make Canonical its default only if it costs nothing measurable, and it does cost something on both hosts. Method: a scratch release bench, not committed. It opens two devices in one process whose DevicePolicy differs in extended_range_blits alone, uses Private BGRA10_XR textures that Metal keeps compressed (ShaderRead only, allowGPUOptimizedContents) at 256x256 and 2048x2048, and runs one whole-texture blit per command buffer, the two values interleaved: 20 warm-up blits, then 300 timed. Three processes per host. Kinds: buffer into texture (Private and Shared buffer), texture into buffer (Private and Shared), texture into texture. - RTX 5080 Laptop, NVIDIA 615.71.09: calibrated GPUStartTime/GPUEndTime. Run under msi's gpu-locks.sh with SCHED_OTHER. - M3 Max, MoltenVK 1.4.2: GPU times come from the host clock there, so the ledger cites 16 blits per command buffer, per blit. Evidence the pass ran: - Shared-texture byte checks: Canonical wrote Metal's encoding in all three directions; Kept kept the bytes. - Work counts: one vkCmdDispatch per blit under Canonical, none under Kept. - ExtendedRangeBitsKept was announced only under Kept. Verified: cargo fmt; nextest -p metal2vulkan -E 'test(fast_paths)', 17 passed. (cherry picked from commit e8eb63b8acd94897718c8e5784e715dbe6e89b9b) |
||
|
|
4b194d24af |
Write Metal's encoding through compressed BGRA10_XR blits under an exact-answers switch
What: a new DevicePolicy switch, `extended_range_blits` (ExtendedRangeBlitPolicy::Kept, the default, and ::Canonical, which `exact_answers()` selects). Under Canonical a blit or fill through a BGRA10_XR or BGRA10_XR_sRGB texture Metal keeps losslessly compressed writes Metal's canonical encoding: each 16-bit field's low six bits cleared and, for a blit, the alpha code clamped to [384, 894]. - bind::extended_canonical_module, a compute kernel that rewrites a texel range's words in place (bind/extended_canonical.rs, with extended_range_canonical as its reference and interpreter tests); the runtime owns it as OwnedModule::ExtendedCanonical. - The runtime (extended_canonical.rs): after a blit into such a texture, or out of one into another texture of the format, the written regions go out to a scratch buffer, one dispatch per region rewrites them, and they go back; after a blit out of one into a buffer, or into a texture over a buffer's bytes, one dispatch rewrites the words in place at the layout's rows. A fill's texel is encoded before it is written (fills clear the low bits alone: Metal's fill keeps alpha codes 4 and 1023 on the M3 Max under 27.0.1). A buffer the device cannot bind (offset or pitch off 4, past maxStorageBufferRange) or a texture over a buffer whose rows share bytes keeps the bytes and announces extended-range-bits-kept, as under Kept. Under Canonical the note is not announced for the blits it makes exact. - copy_from_buffer_to_texture's body moved into buffer_into_texture, which a fill's row copies call with Writer::Fill (so a fill announces its own wording and is never rewritten as a blit). Why: Metal's GPU blits through the compression rewrite these bits (measured on the M3 Max under macOS 27.0.1, plain Metal, xr_matrix: compression iff allowGPUOptimizedContents, shorter side >= 16, neither ShaderWrite nor PixelFormatView usage; every storage mode alike; CPU copies keep the bytes; fills clear the low six bits only). The device's copy keeps the bytes. It is the runtime's choice, not a native answer (no device arithmetic is involved: a copy's bytes), so per rule 1 the fast form stays the default and the exact form is the switch. Ledger: FAST-PATHS row (fast defaults), API.md section 1 bullet and the extended-range-bits-kept catalogue entry, the Degradation doc, the conformance Policy doc. Known gaps: the 28 rows of compressed-blits-bgra10xr and -srgb (7 sites x 2 formats x Apple M3 Max and llvmpipe) dropped: under the suite's exact policy those sites now hold Metal's bytes. RUNTIME_VERSION 1728 -> 1731 (a run under the exact policy writes other bytes). Also fixes forward a clippy needless borrow in engine_arith's pack test (7a99b93af2). Verified (M3 Max, macOS 27.0.1, MoltenVK 1.4.2; and lavapipe in scripts/linux-gate, arm64, LLVM 21.1.8 128 bits): - runtime_lane::compressed_blits on MoltenVK: both tests pass; the new extended_range_blits_write_metal_s_encoding_under_the_canonical_policy checks every direction, level 3 into padded rows, Shared CPU/blit mixes, texture to texture both ways, a fill of a compressed and a plain texture, and a copy into a texture over a buffer with padded rows, under both values (Canonical: Metal's bytes and no notice; Kept: the bytes and the notice once). - conformance replay of the four compressed-blits cases on MoltenVK: exit 0, the ledger as edited (bgra10xr and -srgb `announced` only for staged-texture-copy/shadowed-texture). - the full `conformance replay --cpu` on lavapipe at 68074019a3 and at this change: the only difference is the 14 llvmpipe sites of the two XR cases, which no longer diverge (divergent 244 -> 242, exact 458 -> 460); the 265 other ledger mismatches of that arm64 venue are the same at both (it is not CI's amd64 lavapipe). - 154 touched validation lanes on MoltenVK (blits, fills, extended-range, NaN, pack, padded, rotated, no-copy, two-plane heap): 143 passed, 10 failed, 1 ignored; the same 10 fail with the same messages and the same differing texels at 68074019a3 (pre-existing). (cherry picked from commit 612ff50b86bc29515b158d9b2596b14a45431467) |
||
|
|
452c17aa2c |
Carve MoltenVK on the M3 Max's identity out of DevicePackConversion for the measured forms
reims-vgpu treats precision notes as fatal on Apple GPUs. On the M3 Max (MoltenVK 1.4.2, macOS 27.0.1) the module's air.pack/air.unpack of rgb565 in float, and in half of unorm4x8, snorm4x8, unorm.rgb10a2 and unorm.rgb565 (both ways) and unorm2x16 and snorm2x16 (packed), answer Metal's words, so DevicePackConversion was recorded where nothing differs. What: DriverDeviation::MetalPackConversions (VkProperty::MetalPackConversions), taken by the APPLE9 MoltenVK row alone. Where taken, select_pack records no note for a form lower::arith::pack::measured names and the module requires the property (ArithPlan::metal_packs). The lowering is unchanged on every profile. Kept noted, with the inputs that differ (probe over the same inputs, fast and precise math): the sRGB format (85,511 of 3,083,776 float packs, 3,286 of 65,536 half packs, every unpack), unorm.rgb10a2 in float (9,163 of 131,072 unpacked words, 1,257 packed floats), the half unpacks of unorm2x16/snorm2x16 (8 lanes: our float quotient rounded twice), and snorm.rgb10a2 (unmeasured). Docs: Metal's float rgb565 measured to round the product to float first (the exact-product model misses 55 of the tie set) and to unpack by the float reciprocal; the artifact rustdoc and API.md said Metal rounds the exact product and divides correctly rounded for every format, now qualified for rgb565 in float. Verified (all on this M3 Max): - Plain Metal running runtime_lane::pack_conversions' own AIR (12 kernels: every code of every field, every half in every channel, 68,672 float words incl. 33 around each 5/6-bit tie): the lane's model matches Metal in every word. - runtime_lane::pack_conversions on MoltenVK: no kernel records the note, 0 inputs differ. - tests::engine_arith::pack_conversions_are_metals_where_measured: all 32 normalized forms on lavapipe and moltenvk-m3 (note and property per form); it fails without the deviation row (its takes == moltenvk-m3 assertion) and without the select_pack change (the note). - Focused core run (engine_arith, driver_facts, fast_paths, golden, api_signatures, pack, engine_tile, engine_texture): 197 passed. Also: drops an unused binding the NaN-moves commit left in engine_native_half. The NaN-moves commit's message gives SEMANTICS_VERSION 1946; since the rebase onto 68074019a3 it is 1948 (ARTIFACT_FORMAT_VERSION 483), which covers this commit too. FAST-PATHS row for air.pack updated. api_signatures blessed (two variants); golden hashes re-blessed (the moltenvk-m3 profile). (cherry picked from commit b344f5e515e5b1c586877ca45fedead512ea0ad2) |
||
|
|
b0bed82331 |
Record a pixel sample's centre denormals only where its centre can run
ed08da17f6's pixel-sampler fix recorded PrecisionNote::DeviceDenormals unconditionally for every texel-centre position, TexelBySpec and TexelByWord included. Those two are the runtime slot's and the argument buffer's samples, whose centre `floor(x) + 0.5` sits behind the NearestPixelSampler specialization or the table word's test: code that no normalized state reaches. So every stage that samples through a runtime or argument-buffer sampler, normalized ones included, gained an unconditional DeviceDenormals at making, which a host that refuses any precision note on an Apple GPU dies of (cubic stages died of it before reaching their own BicubicFilterArithmetic, which is unchanged). The note is real where the centre runs. Measured on the M3 Max with a 21x13 texture and clamp-to-zero and white-border states, at x = -2^-149, -2^-140 and -2^-127: Metal's nearest pixel sampler reads texel -1 (the border), MoltenVK's `floor` flushes the subnormal to -0 and reads texel 0. It shows through every centre form: a constexpr nearest sample with an offset (UnnormalizedTexel), a constexpr edge fetch with an offset, a constexpr nearest array sample (Texel), a runtime slot under a nearest pixel state (TexelBySpec) and an argument buffer under one (TexelByWord). The shader keeps the device's floor (owner's rule 1). centre_denormals now gives the note per form: - a constexpr sampler's Texel or UnnormalizedTexel centre, and a fetch under an offset: unconditional, as before; - a runtime slot's TexelBySpec: only under NearestPixelSampler == 1, which is 0 for every normalized state; a runtime slot's Texel (an integer texture): only where its word has the pixel bit; - an argument buffer's TexelByWord: none of its own; ArgumentPixelSamplerScaling, which the runtime announces only while a pixel state lives, records it (its doc now says so). Tests: - tests::engine_sampler::normalized_and_cubic_stages_record_no_note_ their_states_cannot_run (moltenvk-m3) holds the unconditional notes of the sampling, handle, argument-buffer, pixel-argument and cubic fixtures (plain and the cubic variant under normalized and pixel words) to 9f5776bf31's, and checks every specialized DeviceDenormals clause tests the nearest-pixel constant or the pixel bit. It fails on ed08da17f6's select.rs (DeviceDenormals among the unconditional notes). - runtime_pixel_accesses_hand_the_device_the_scaled_coordinate now checks the nearest kernels' one specialized DeviceDenormals entry and that the gather has none. - runtime_lane::pixel_edges::normalized_states_announce_no_pixel_note dispatches the slot and argument-buffer kernels under normalized nearest and linear states and asserts no DeviceDenormals or pixel note, then a nearest pixel state and asserts DeviceDenormals (slot) and ArgumentPixelSamplerScaling (argument buffer). On ed08da17f6 it fails on the Apple M3 Max with DeviceDenormals under normalized states. docs/API.md (device-denormals, argument-pixel-sampler-scaling) and the DeviceDenormals row of docs/FAST-PATHS.md state the per-form rule and the measurement. SEMANTICS_VERSION 1947: an artifact's notes changed. Verified before this commit on MoltenVK (M3 Max, under maclock and memcap): runtime_lane::pixel_samplers, pixel_edges (the new test included) and pixel_downscales, 8 of 8; sampler translator tests 121. The full checks follow on this tree. (cherry picked from commit 382e940c470becee8cfdf560f2f1284ce2844599) |
||
|
|
ec9e0546eb |
Hold a constexpr linear pixel sample to Metal's answer, not the normalized control, off MoltenVK
A constexpr linear pixel sampler now reads through the device's own linear filter in unnormalized coordinates. On lavapipe that path's arithmetic is its own rather than the normalized filter's at a moved coordinate: 79 to 107 of 800 cells of clamp to zero and to the border differ from the normalized control in their last bits (none of clamp to edge), so `pixel_samplers_answer_metal_s_texels` failed its control rule there. Such a configuration is the device's native filter (`device-sampling`): where the device's sampler is not Metal's it is printed and no longer held to the control; on a device with Metal's own sampler it must still answer Metal's hash, as every constexpr and nearest configuration must. docs/FAST-PATHS.md's pixel row scopes its nearest claim to the edge probes and says what a constexpr linear sample is on lavapipe. Verified: the pixel lanes (pixel_samplers, pixel_edges, pixel_downscales; 7 tests) pass on arm64 lavapipe in linux-gate under --cfg m2v_cpu_icd, where pixel_samplers failed before this change, and on the M3 Max under MoltenVK; no nearest cell off Metal's rule was printed on either (`PIXEL-EDGE-DEVICE`). The fast_paths ledger tests pass. (cherry picked from commit 427ed1fa9dd6fc2ca7a9f8b12bd60a8bfa23d93a) |
||
|
|
575ac2b103 |
Read a pixel-coordinate sample's texel as Metal's sampler does
A `coord::pixel` sampler handed the device the coordinate divided by the texture's size. At a texel edge whose quotient is inexact the device's normalized sampler read the texel before it: on the consumer's 258x258 matrix 28 of 1042 nearest clamp-to-zero and clamp-to-border cells on MoltenVK and up to 500 on an RTX 5080. Metal reads `floor(x)` for nearest and quantizes `x - 0.5` to its 1/256 grid for linear filters and gathers. Now, decided from the sampler's state and the access's structure: - A constexpr pixel sampler that Vulkan's unnormalized sampler can state (one filter, no mip filter or anisotropy, clamp to edge, zero or border; a 1D or 2D non-array image, no comparison, no status read) samples and gathers through the device's own unnormalized sampler at the coordinate itself, on a view of level 0 (`CombinedSampler::unnormalized`, `SamplerDesc::unnormalized`). A linear sample's or gather's constant offset folds into the coordinate; a nearest sample's offset is applied to its texel's centre (`floor(x) + 0.5 + k`). - A constexpr nearest pixel sampler the unnormalized form cannot take (an array, a mirror mode) samples at its texel's centre over the size, `(floor(x) + 0.5) / N`, which the device's normalized sampler reads as that texel exactly. - A runtime slot's sampler takes the centre where a new pipeline constant, `SpecKey::NearestPixelSampler`, says the bound state is a nearest pixel sampler (1 only for those, so normalized states make no new pipeline); an argument buffer's sampler tests its word (`SamplerWord::nearest_pixel`, which replaces `exact_fetch`). - Linear samples and gathers through runtime or argument-buffer samplers, arrays and 3D, comparisons, level queries and status reads keep the scaled coordinate and its note: their state is unknown where the shader is made, or Vulkan's unnormalized sampler forbids them. `PixelSamplerScaling` is now recorded only where a scaled form remains; `DeviceDenormals` where a centre's `floor` may read a subnormal coordinate as the device does. The pixel_samplers lane also asserts Metal's answer for every constexpr and nearest configuration on MetalSampler devices. The conformance case declares `pixel-sampler-scaling` for its linear cases alone, and the llvmpipe ledger rows follow the run: two `rgba16f-nearest-mirror` rows are gone (Metal's answer now), seven take the new digests. `SEMANTICS_VERSION` 1945, `ARTIFACT_FORMAT_VERSION` 482. No `RUNTIME_VERSION` bump: an unchanged artifact (no unnormalized sampler, no new constant) binds and runs as before. The new fixture `px_edges` (own MSL, through regen-air-fixtures) samples every form at texel and block edges, quarter offsets and each border colour on three NPOT sizes, and the new `runtime_lane::pixel_edges` holds each nearest cell to the CPU's `floor` rule on every device and every probe to Metal's digests on MetalSampler devices. Fixture comments in `sampling` and `sampling_completion` no longer say the coordinate is scaled (their AIR bodies are unchanged). Verified on the M3 Max under MoltenVK 1.4.2: the consumer's matrix compared with Metal's results, 0 differing cells on every kernel and size (28 of 1042 before on three kernels); lavapipe 0 before and after; `runtime_lane::pixel_edges`, `pixel_samplers` and `pixel_downscales` pass; conformance replay of the 23 pixel cases holds the ledger on MoltenVK; on arm64 lavapipe the whole set's replay departs from the parent's ledger, beyond what the parent's own replay does, at exactly the nine rows edited here (the answers are the report's own). Core suite 4988 passed; validation suite under `--cfg m2v_gpu` passes the new and pixel tests, its other failures fail the same on the parent commit; conformance 1007 passed; goldens, hashes and inventory blessed. Release translation of every px_edges and px_samplers kernel on four profiles: slowest 0.08 s, largest peak 6 MB. (cherry picked from commit 888ad9bae9f0aaaf769360740e1dd16817245ca4) |
||
|
|
253dedccc3 |
Drop ASTC attachments from passes and bind a neutral at ASTC storage slots
What: on every device and for every ASTC form (LDR, sRGB, HDR, every footprint, in its own block or in a carrier): - a render pass drops an ASTC color attachment that resolves nothing (`render_pass::layout`): it loads, clears and stores nothing into it, its level's extent still bounds the pass, and the pass's other attachments run as they would. No notice: that is Metal's answer. - a draw or dispatch binding an ASTC texture at a storage slot binds the slot's neutral (`PlanDiagnostic::AstcStorageNeutral`): its writes leave the blocks as they were, its reads answer zero. The runtime announces the new `astc-storage-neutral` (precision) once, catalogued in docs/API.md, its lane site `ASTC_STORAGE`. A render pipeline of an ASTC color attachment stays refused (Metal ends the process), as do a resolve of an ASTC attachment (unmeasured), 1D and multisampled textures and another footprint's view. Why: the runtime answers plain Metal, not its validation layer. Plain Metal (an M3 Max under macOS 27.0.1, probe `astc_passes_writes_footprints`) completes such a pass for every load and store action, with a draw and without, leaving the blocks unchanged and the other attachment as without it; it completes a kernel's `write` and `read_write` and stores bytes no format defines into the blocks (`read_write` reads their decode). No Vulkan format of a block is an attachment's or a storage image's, so the pass drop is exact and the neutral differs, announced. Tests that fail before: the translator's `a_stand_in_compile_is_the_compile_of_its_formats_bind_ and_no_other` (every ASTC format at a storage slot plans the neutral with the diagnostic); the runtime's `degradation_sites` closure (a lane site for the kind); the lane's `runtime_lane::astc_passes_and_writes`: every one of the 48 ASTC formats at color 0 of four passes (clear and store, load and draw, dontcare both and draw, clear and draw) with an RGBA8 color 1: the blocks unchanged and color 1 the pass's without the attachment (192 passes); a pipeline of an ASTC attachment refused; every format bound to `write` and `read_write` kernels: blocks and texels unchanged, `astc-storage-neutral` announced once. Verified: MoltenVK lane on the M3 Max, `runtime_lane::astc*` 9 of 9 (192 passes, 96 dispatches); runtime touched tests. (cherry picked from commit 68a296589040b208634abd7b8dfa6ce938cf8c96) |
||
|
|
e972337dd8 |
Hold ASTC's 4x2 and 8x4 footprints in a carrier with a decoded twin
What: the six ASTC formats of Apple's 4x2 and 8x4 footprints (LDR, sRGB, HDR), which no Vulkan format holds, are made on every device as the other ASTC formats are on a device without ASTC: their blocks in the 16-byte carrier (BC7, BC3, BC2, BC5, ETC2 or EAC; one ASTC block over 4 x 4 carrier texels whatever its footprint), their reads through a decoded twin of 8-bit codes (LDR, sRGB) or halves (HDR). `AstcDecode::of` takes every footprint from `metal::format::block_extent`; the format table maps them decoded-only (no direct format); the footprint module answers 26 formats now, and the heap size query takes the modelled ASTC block layout for them. Copies map regions in blocks (`copy_plan::block_bytes`), a partial last block as Metal rounds it. Why: plain Metal makes every such texture (2D, 2D array, cube, 3D; Shared and Private; read, write, render-target usage) and copies them in whole blocks, the last ending at the level's edge (probe `astc_passes_writes_footprints`). The orchestrator's brief suggested an uncompressed 16-byte-texel carrier; the existing compressed carrier already holds any 16-byte block per 4 x 4 carrier texels, so it serves every footprint with the decode passes, CPU decodes, second twins and copy paths the other ASTC formats use, with no new image kind. Tests that fail before: the translator's format tests (`astc_4x2_and_8x4_are_named_and_read_ through_their_twin`, counts and twins), the decode digests of 4x2 and 8x4 against Metal's (`astc_decode` tests, HDR coverage), the runtime's image-plan, heap and pixel-format tests, and the lane: `runtime_lane::astc_textures` and `astc_hdr_textures` now take every footprint (32 LDR and sRGB, 16 HDR), the round trip at every level and slice 4x2 and 8x4 (partial blocks at 37x23 and 29), the colour-space views 4x2 and 8x4. The conformance case `format-footprints-astc-4x2-and-8x4` now makes and round-trips them: its ledger row (the refusal) is gone and it declares the three notices the carrier announces. Verified: translator and runtime touched suites; MoltenVK lane (`runtime_lane::astc*`, 9 of 9 on the M3 Max); conformance replay on MoltenVK of the footprint case and the ASTC cases, compliant (the footprint case announced, every byte Metal's); lavapipe replay: every byte Metal's, the notices undeclared before this commit's declaration. (cherry picked from commit 2a8dd25c6b9d4cc62ff79816fa61d984969b3c22) |
||
|
|
1210972f03 |
Hold multisampled word-format textures in their word's format
Metal makes 2- and 4-sample textures of R8Unorm_sRGB (11), A1BGR5Unorm (41), ABGR4Unorm (42) and RGB9E5Float (93) for every usage, memoryless included (our probe msaa_word_formats.m, M3 Max, macOS 27.0.1). The RTX 5080 samples these formats but renders none, so Vulkan states one sample for their images and the runtime refused each at creation (TextureSampleCount, FramebufferColorSampleCount(4)). What changes: - image_plan::word_samples: where the device samples the format, renders it at no count and renders the word's format (R8_UINT, R16_UINT, R32_UINT), a multisampled texture's image is the word's format, mutable to the format's sampled view (and an 8-bit sRGB format's UNORM twin, for its resolve). Every sample holds Metal's word by construction: the existing word lowering writes it, clears write Metal's clear word, reads decode through the format's view, copies are bitwise. Shader writes stay unavailable (Metal writes no multisampled texture from a function). A device that renders the format keeps its native image. - The resolve of such an attachment is the crate-owned one: Metal's for RGB9E5Float and 8-bit sRGB, a near-equivalent within one code for the packed formats, announced as the new Degradation::WordResolve (word-resolve). The NotImplemented(Format) refusal of word resolves in resolve.rs is gone; an attachment that takes neither input attachment usage nor the copy is still refused. - DeviceOptions::withheld_attachment_formats (doc hidden, a test hook): a device made with formats' color attachments withheld, so the word path runs on MoltenVK, which renders all four. - RUNTIME_VERSION 1721. Docs: API.md (word bullets, the multisampled word paragraph, the word-resolve catalogue entry), FAST-PATHS known gaps (word resolves no longer refused), word.rs, image_plan.rs and resolve.rs module docs; runtime-sources pin recomputed. Routes over the committed profiles (tests::word_samples, pinned): the word for all four formats at 2 and 4 on NVIDIA's three profiles, for R8Unorm_sRGB and RGB9E5Float on ANV's four, and RGB9E5Float at 4 on the gate's lavapipe; native on MoltenVK and RADV; refused where the word's format renders one sample or the textures take no such count (swiftshader, lavapipe's profile, the floors). Verified: - cargo nextest run -p metal2vulkan-runtime --all-features: 1188 pass (the three word_samples planning tests among them). - Device lane runtime_lane::word_samples_msaa on the M3 Max through MoltenVK (--cfg m2v_gpu, maclock), new owned fixture wsm_samples: the device as it is (each format natively) and with the four attachments withheld (each held in its word, printed per format). On the word path every stored sample is Metal's word (all 32 or 64 per shape), reads decode them, the sRGB and RGB9E5 resolves are Metal's in every pixel, the packed resolves within a code (7-9 of 16 pixels exact after a draw, 13-16 after a load), a packed blend's words Metal's in every sample. word-resolve and shader-resolve announced. Negative control: with word_samples disabled the lane fails. - clippy -D warnings (default and --cfg m2v_gpu), rustdoc -D warnings, private intra-doc links at their ceilings, refusal_surface --check, api_signatures --bless (DeviceOptions field, Degradation::WordResolve added), METAL-COVERAGE and CONFORMANCE-COVERAGE --check current. Not in this change: the golden tables for the new fixture (golden_hashes, the engine inventory, the air_input printout) are re-blessed on development. Blends of an 8-bit sRGB or RGB9E5Float word stay refused as the device lacking the format, as they are at one sample. (cherry picked from commit ad8b94cd840f3d0bf4bb9552904fbdf2f253b9af) |
||
|
|
7130d5d6e7 |
Make ASTC HDR textures where Metal makes them: native, else a carrier with a twin of halves
Metal on an M3 Max (macOS 27.0.1) makes every 2D ASTC HDR texture (MTLPixelFormat 222-236) with read, write and render-target usage; the runtime refused them on every device without the Vulkan SFLOAT block (the RTX 5080 among them) as a format it cannot hold. - Translator: bind::AstcDecode decodes the HDR profile, written from the Khronos Data Format Specification's ASTC chapter (new hdr.rs): HDR endpoint modes 2, 3, 7, 11, 14 and 15, the LNS-to-half mapping, LDR modes and void-extent blocks in an HDR texture, and the HDR void extent, on the CPU and in the GPU decode kernel (kernel/hdr.rs). Where the probe showed Metal's own answer it is the one taken: an LDR channel in the HDR profile is C/65536 truncated to a half (1 for 65535); a void extent's NaN halves read as the quiet NaN; an error block reads NaN in every channel. Public API: AstcDecode gains `hdr`, AstcTexels gains `Half` (R16G16B16A16_SFLOAT), AstcDecode::form picks a profile's compact form, and AstcDecode::texel_bytes is now a method (a consumer calling AstcDecode::texel_bytes(texels) writes decode.texel_bytes(texels)); api_signatures.tsv blessed. - Format table: each ASTC HDR format takes its ASTC_*_SFLOAT_BLOCK where the device holds it (the device's decode, rule 1), else FormatEmulation::Decoded over R16G16B16A16_SFLOAT. - Runtime: such a texture is the existing carrier (its 16-byte blocks, which copies and getBytes move unchanged) and a decoded twin of Metal's halves, exact, kept in step by the same GPU and CPU decodes; a new texture's twin starts at the error block's NaN. Notices: carried-decoded-twin and cpu-block-decode, as for ASTC LDR; no decoded-texel-precision (the halves are Metal's). A view in another profile (an HDR texture's LDR or sRGB view, or the reverse) is refused on a carrier (Feature::TextureView, as another footprint is); render passes into one and kernel writes of one stay refused typed (the Vulkan formats take neither), where Metal's validation stops each. - Docs: API.md's carried-decoded-twin entry, FAST-PATHS known gaps, module docs of bind::astc_decode, astc.rs and decoded_twin.rs. - Conformance: the 42 ASTC cases now name the twin notices for HDR rows too, and the decoder cross-check holds Metal's recorded HDR reads. Versions: RUNTIME_VERSION 1720 (an HDR texture is now made and read where it was refused). No SEMANTICS_VERSION or ARTIFACT_FORMAT_VERSION bump: translation output is unchanged (the Decoded candidate admits sampling usages only, so no pipeline's format answer moves) and no encoded artifact carries AstcDecode. Runtime-sources pin recomputed. Verified: - CPU decode bit-exact against Metal for 2048 seeded blocks of each of the fourteen footprints (every endpoint mode, partitions, dual plane, void extents, error blocks), as float and half reads and nearest samples (probe `reads`), checked by per-footprint digests and a 66-block fixture of Metal's float bits (bind::astc_decode::tests::hdr); the GPU kernel equals the CPU decode on every texel; the kernels are valid on every committed profile; the conformance suite's recorded astc-*-hdr reads equal the decoder's. - Plans: moltenvk-m3 native for all 14; nvidia-rtx5080-laptop, lavapipe, amd-780m-radv and intel-arl-anv in a carrier (runtime tests::image_plan). - conformance replay of the 42 ASTC cases on lavapipe (linux-gate, --cpu): the 14 HDR rows `announced` (texels exact, carried-decoded- twin and cpu-block-decode fired), exit 0; on MoltenVK the 14 HDR rows `exact` with no notice. - Touched tests in metal2vulkan, metal2vulkan-runtime, metal2vulkan-conformance; clippy (plain and --cfg m2v_gpu); refusal_surface --check, both coverage docs current; private intra-doc link loop at its ceilings. (cherry picked from commit eb6828adddde978fab87dc7d05ea1a2a55738008) |
||
|
|
ef7a8d6f08 |
Lower Metal's pull-model interpolation (interpolant inputs)
A fragment function reading an `interpolant<T, P>` input through
interpolate_at_center, _centroid, _sample or _offset was refused as invalid
input (the AIR key air.interpolation_function was unknown), so a guest whose
device answers supportsPullModelInterpolation could not run one.
AIR: the key marks a fragment input `Sampling::Interpolant`, a device-space
handle (`AbiHandle::Interpolant`); `air.interpolate_{center,centroid,sample,
offset}_{perspective,no_perspective}.{f16,f32 x1..4}` parse as
`AirIntrinsic::Interpolate`, decided from the intrinsic family and the
metadata ABI, never names.
Lowering: the interpolant is a float Input variable of its form (NoPerspective
where not perspective), read only through its calls:
- center: as a center varying is read (its pixel-center form at more than
one sample where the device has one);
- centroid / sample / offset: GLSL.std.450 InterpolateAtCentroid,
InterpolateAtSample (index & (SampleCount - 1), Metal's i mod n) and
InterpolateAtOffset (offset moved to the device's origin and NClamped to
[minInterpolationOffset, maxInterpolationOffset], which Vulkan requires).
These need sampleRateShading (and MoltenVK's portability member): without
them the function is refused Unsupported(PullModelInterpolation).
- MoltenVK's SPIRV-Cross hands InterpolateAtOffset(v) to Metal as
interpolate_at_offset(v + 7/16): such a device gets the new
VkProperty::InterpolateAtOffsetFromSevenSixteenths and the module moves
the offset by 7/16 (a module annotation picks the property).
- An interpolant used any other way (a select of two) stays
NotImplemented(PullModelInterpolation); on RADV
(InterpolationNeedsTheWholeQuad) a sample or offset read after a discard
or outside the first block is refused; lavapipe refuses a multisampled
centroid read as it refuses a centroid varying.
- GraphicsState::interpolates_at_sample states a fragment stage that reads
at a sample (Vulkan takes no InterpolateAtSample with custom sample
locations); Sampling::Interpolant carries center/centroid/sample.
Metal measured on the M3 Max, macOS 27.0.1, with the new probe
probes/pull_model_interpolation.m over the owned fixture
pull_model_interpolants (cases origin, grid, samples, centroid, lane): an
offset is read from the pixel's corner as given, no range, no grid, NaN for
a non-finite one; sample i reads i mod n at Vulkan's standard positions;
centroid is the center when the pixel is covered whole, else the lowest
covered sample. The offset's range and grid are the device's:
PrecisionNote::DeviceInterpolationOffset (validation: Recorded), in
docs/API.md's catalogue and FAST-PATHS.md's device gaps; a centroid read
notes MultisamplePosition as a centroid varying does.
Verified: tests::engine_pull_model (309 pipelines over every committed
profile at 1 and 4 samples: instructions, mask's planned SampleCount,
origin, NClamp, note, property, L3; refusals on vk12-floor, RADV after a
discard, lavapipe centroid at 4x; pm_selected refused everywhere),
engine_multisample, engine_fragment, engine_coverage_loop, fast_paths,
api_tests, codec and cache tests, metal2vulkan-air abi/intrinsics tests and
api_surface; runtime degradation and catalogue tests; clippy all features.
Before: every pull_model_interpolants function failed InvalidInput
(Abi(UnknownKey)). Goldens: only new rows and the moltenvk-m3 profile hash
moved (its new property); inventory 24 new rows, 0 moved cells.
SEMANTICS_VERSION 1941 (refusals became translations), ARTIFACT_FORMAT_VERSION
481 (IoSampling, PrecisionNote, VkProperty and GraphicsState encodings).
(cherry picked from commit 70e01b4bd6f8a0d1421ae07ed710714fb4ce985b)
|
||
|
|
6f8ec46671 |
Draw a draw whose own band the translator refuses at the nearest width
A draw whose own band variant the translator refuses where the state's
first band compiled (a varying or push data the draw's variant adds, such
as a shader-side depth test's window depth and depth range, past
maxTessellationEvaluationOutputComponents or maxPushConstantsSize) was
refused with the translator's Unsupported(WideLines). Only its later
draws took the nearest width. That breaks the owner's rule that an
accuracy note is logged and never fatal: the draw can run at the nearest
width.
The draw now takes the nearest width, announced as a state's refusal is
(lines-at-nearest-width, the translator's refusal the reason). The
refusal is still kept per state and primitive (GraphicsState::refuse_band,
two answers a state). A draw's variant key follows from its bind shape,
and its route sets that shape, so a per-key memo would need the shape
before the route. Recording a draw factors what its lines' route decides
(the route, provoking vertex, listed strip, private form, settings) into
RenderLowering::routed_draw and a RoutedDraw. draw_resident settles in a
loop. Where the settle answers the translator's refusal of the draw's band
(LineRoute::refused), it marks the state's primitive refused and routes
the draw again. Routed again it draws no band of the primitive, so it
settles once more at most. settle_draw hands that refusal back to the
caller before its snapshot and shadow retries, as before.
Docs: line_width.rs, the runtime README, FAST-PATHS's known gap, API.md's
and degradation.rs's lines-at-nearest-width (no refusal named any more).
REFUSALS.md does not move (refusal_surface --check passes): the
translator's refusal stays. RUNTIME_VERSION 1717 (a refusal became an
announced draw); runtime sources re-pinned.
Verified: the new pure test
a_draw_whose_band_the_translator_refuses_takes_the_nearest_width covers
every committed profile under both policies, lines and edges, widths 0 to
16. Each band route takes either refusal (not implemented, and the
evaluation-output limit) as its primitive's. Routed again, it is the
nearest width with the refusal as the reason, or the device's lines, and
never a band. A non-WideLines refusal or a runtime gap stands. It does
not compile against be2d725fdb, which had no such decision. A negative
control that drops the decision for lines fails it ("amd-780m-radv,
Device, Lines at 0: left None, right Some(Lines)"). Runtime line_width
tests 4/4 pass. Also clean: clippy with all features and with
--cfg m2v_gpu, refusal_surface --check, the runtime-sources pin test.
Not run: the GPU lane. No draw on MoltenVK reaches this cheaply: the base
key's band and a draw's differ only by shader-side tests' additions or
push data. The orchestrator's gate covers the restructured draw path.
(Carried to development from steelbrain/reims-graphics-kext 06f08298fd.)
|
||
|
|
b3d483fd72 |
Draw triangles' wide edges as bands, and refused bands at the nearest width
Metal draws a triangle in fill mode Lines at a width other than 1 as its three edges, each the line parallelogram, facing as the triangle does and culled by it, its flat inputs from the provoking vertex (the probe's `edges` case, committed with the lane before this). The runtime drew those edges with the device's lines, at the nearest width they draw (1 pixel on MoltenVK), announced. Translator: the band variant takes a primitive (`BandPrimitive`, in `VariantKey::line_band`, `LineBandState::primitive`, `BindState` and `BindShape::line_band`). A triangle's patch is its three vertices in the quad domain at outer levels (11, 1, 6, 1) and inner levels (3, 2): the inner ring degenerates to a segment, so the spec's deterministic fans from its two vertices cover the u = 0 and u = 1 edges, and the evaluation stage places those fans' vertices at the corners of the edges' parallelograms (from the vertex of the largest w, which never moves at the near plane), every other triangle degenerate. The band faces as the triangle (the sign of its homogeneous determinant, a zero-area one back) by turning the minor axis, so the draw's own cull mode, front face and depth bias apply. `LineBandState::PATCH_CONTROL_POINTS` gives way to `BandPrimitive::patch_control_points`. A pure test checks the fan tables against the spec's triangulation: every triangle is degenerate or one of the nine that cover the parallelograms once, and each winds as a line's band, turned by the facing. Runtime: a triangle's edges (lists, strips, fans, Metal's private triangle types) route as lines do: the device's lines where they draw the width, else the band, on every device with tessellationShader; strips are listed, the last provoking vertex read from the list led by it. The band's depth bias is the device's per band triangle: announced (new `Degradation::WideEdgeDepthBias`) under a slope factor or a constant over a float depth. A pipeline state whose band variant the translator refuses (barycentric weights, a selected slice or viewport, synthesized geometry, multiview, too many outputs) now draws its lines and edges at the nearest width, announced with the refusal as the reason, instead of failing the draw: the state's first band compiles the variant of its base key and remembers a refusal per primitive (`Unrouted::Refused`). Mesh draws and tessellated patches keep the nearest width. Docs: line_width.rs, band.rs, the runtime README, FAST-PATHS (row and known gap), API.md (band variant, catalogue), REFUSALS.md regenerated; api_signatures blessed (BandPrimitive added, LineBandState::PATCH_CONTROL_POINTS removed, the three line_band fields now carry the primitive). SEMANTICS_VERSION 1940, RUNTIME_VERSION 1716; runtime sources re-pinned. Verified (M3 Max, MoltenVK, --cfg m2v_gpu, maclock and memcap): runtime_lane::line_widths 7/7 pass under both policies; 148 cases, 145 drawn as Metal's pixel for pixel, 28 of the 31 wide edge cases (facing, culling, zero-area, strips, flat IDs and primitive IDs at both provoking modes, depth across an edge, 4 samples), the other 3 the depth-bias edge cases, announced (two differ from Metal, by slope and by exponent; the uniform-depth one matches); 93 draws as bands, 0 at the nearest width. Before this commit the same lane failed 4 of 7 (31 edge cases at the nearest width, refused bands refused). Also: engine_line_band and the band's fan tests, golden_hashes_match_the_table and the engine inventory parts unchanged (no bless), runtime line_width tests (the route table for lines and edges on every profile under both policies, refused rows), api_surface, api_signatures, refusal_surface --check, clippy with all features and with --cfg m2v_gpu, rustdoc with -D warnings. (Carried to development from steelbrain/reims-graphics-kext be2d725fdb.) |
||
|
|
b5e18d8fb3 |
Document the nearest-width line route; name its cause in the notice
Follows the previous commit, which drew at the nearest width what neither line route draws. Its nearest width is Metal's drawn width: w', and 1/16 at w' = 0 (Metal draws 0 as 1/16, the width-0 commit this rebased onto), clamped into lineWidthRange where the device enables wideLines, else 1. - line_width.rs: module docs for the Nearest route and what still refuses (a strip's band whose segment list cannot be drawn; the band variant's forms the translator does not build). The lines-at-nearest-width notice's object names the edges or lines drawn, its reason the width drawn, lineWidthRange (or no wideLines) and the cause. - The runtime README's line widths, FAST-PATHS.md's wide_lines row (counter nearest_width_line_draws) and its known gap (what is drawn at the nearest width, announced, instead of refused), RUNTIME-PORTING's SetLineWidth row. - refusal_surface reach.tsv: gap WideLines now reaches only a strip's band list; feature WideLines only the translator's band forms. REFUSALS.md regenerated (gap::WideLines sites 5 -> 1, the runtime's Unsupported(WideLines) site gone). - api_signatures blessed: Degradation::LinesAtNearestWidth, WorkCounts::nearest_width_line_draws. - RUNTIME_VERSION 1715 (a refusal became a run, a new announcement); runtime-sources pin recomputed on this tree (pin-compute.py, which reproduces 9ada26c9fa's pin on that tree). Verified: refusal_surface.py --check exit 0; cargo nextest run -p metal2vulkan-runtime -p metal2vulkan --all-features -E 'test(/line_width|degradation|api_signatures|api_surface|refusal_surface|apple_only|error_kinds|draw_shape|call_checks/)' 27 passed; cargo clippy --workspace --all-targets --all-features -D warnings clean. (Carried to development from steelbrain/reims-graphics-kext 7aed54b621.) |
||
|
|
eb41a55e82 |
Draw every width Apple's setLineWidth: takes, as Metal draws it
RenderCommandEncoder::set_line_width refused every width but 1 (AppleOnly::LineWidth). Measured on the Apple M3 Max under macOS 27.0.1 (probes/line_widths.m): each encoder starts at 1 and the width holds across draws and pipeline states; Metal draws w' = floor(16 w) / 16 clamped to [0, 16] (NaN and negatives as 0, infinity as 16); at w' = 1 its ordinary diamond-exit lines; at every other w' Vulkan's non-strict parallelogram (major axis the larger extent, x on a tie; minor-axis edges through the endpoints, w' long and centred; ends not extended; centres inside, top-left ties; the width not rounded); at 0 exactly the pixel centres on the segment; one parallelogram per strip segment with no joins; triangles in fill mode Lines draw their edges so; at 4 samples every width is the parallelogram at the sample positions. The runtime (render/line_width.rs) keeps the quantized width in the encoder state and routes each draw at w' != 1: - the device's own lines (lineWidth w', no Bresenham mode) where it enables wideLines and w' lies in lineWidthRange above 0: exact where strictLines is unset, nonStrictWideLinesUseParallelogram set, w' > 1 and on lineWidthGranularity; elsewhere announced device-wide-lines under the default DevicePolicy::wide_lines = WideLinePolicy::Device, and the band under WideLinePolicy::Exact (exact_answers() selects it); - the pipeline's band variant otherwise (no wideLines, MoltenVK among them; w' outside the range; w' = 0 at half a width of 2^-subPixelPrecisionBits): cull none, the band's front face, fill mode, a PATCH_LIST of two points, viewport 0's half extent pushed with the half width; strips and loops listed as their segments (ListGap::WideLines), flat inputs under the last provoking vertex read from the list led by the last vertex, which covers the same pixels. Refused: Unsupported(WideLines) needing tessellationShader where neither route draws a line; NotImplemented(RuntimeGap::WideLines) for a triangle's edges or a mesh draw's lines the device's lines do not draw, an amplified band, a rate-mapped pass and an execution's commands. Counted: WorkCounts::device_wide_line_draws, line_band_draws. The lane test runtime_lane::line_widths draws the probe's cases through owned fixtures and compares every pixel with Metal's answers (line_widths_m3_max.txt, the probe's output), checks each wide draw took a route, and that every fragment is front-facing; its site WIDE_LINES holds the new kind in the lane's degrade-notice closure. Docs: FAST-PATHS.md's row for wide_lines and a known-gap bullet (edges and mesh lines on devices without wideLines, near-plane cuts, band fragments' inputs uncompared, width 1 on multisampled targets off MoltenVK); API.md's policy bullet and degrade catalogue; the runtime README's Line widths; RUNTIME-PORTING's row; REFUSALS.md regenerated (reach rows for feature and gap WideLines, apple LineWidth gone). Validation: the line limits the device description gained describe execution and are not compared in a profile's subset check; the generator's CORE_PROPERTIES and roadmap-2022's m2v_layer_presentation state them at the reader's absent values; opened_chains reblessed (one member more, wide_lines, on every device with it); golden_hashes' profile fingerprints reblessed (no output cell moved); api_signatures and api_surface name WideLinePolicy and LineBandState. RUNTIME_VERSION 1712; the runtime-sources pin rewritten. Verified on the M3 Max under MoltenVK 1.4.2 through maclock with the validation layer: runtime_lane::line_widths, 4 tests pass. Default and exact policies each: 102 cases, 100 matched pixel for pixel, 2 refused (the two fill-mode Lines cases at width 4, NotImplemented(WideLines)), 0 announced; 46 draws took the band, 0 the device's lines (MoltenVK has no wideLines). a_band_needs_tessellation (tessellationShader withheld: width 0 refused needing it, width 2 refused, width 1 matches) and the_lane_s_maps_tell_the_widths_apart pass. Negative control: the band widened by 1/16 of a pixel fails both runs at LANE lines 0.5. Also cargo clippy --workspace --all-targets --all-features -D warnings, plain and with --cfg m2v_gpu; nextest of metal2vulkan, -air, -runtime and -devtools (4954 run, the one failure the missing lane site, now declared), of metal2vulkan-validation (the failures the profile rules, chains and pin fixed here, rerun green) and of metal2vulkan-conformance (1007 pass). Not run: lavapipe, RADV, ANV and NVIDIA lanes, which take the device route. (Carried to development from steelbrain/reims-graphics-kext b16d03150c.) |
||
|
|
245b51ef7a |
Read NVIDIA's 10-bit two-plane codes through Metal's arithmetic, and judge the YCbCr lanes by the device's bounds
On the RTX 5080 Laptop GPU (NVIDIA 615.71.09, Linux), development failed 27 of the YCbCr validation tests (runtime_lane::ycbcr_textures 22, ycbcr_minify 2, ycbcr_in_place 2, dma_buf_imports' YCbCr test). Bisect on the 5080, each step built on its own, with the filters test(/runtime_lane::ycbcr/) | test(/dma_buf_imports::a_ycbcr/): - |
||
|
|
3fd1f6672b |
Cut copied host buffers' CPU sync: page-at-a-time compare, log-gated copy in, merge only what may be written
The consumer's 4K boot on the RTX 5080 at the stock vm.max_map_count was unusable past its import gate: about 680 MiB of live copies (2,934 made) were compared whole at every commit and every completion, costing about half a core on both sides. Until the GPU copy is wired, three exact cuts, plus the dirty-log reports change 1 needs (the consumer's audit, A to C). - Change 3, a page-at-a-time compare (copied.rs sync): each 4 KiB page is compared whole (slice equality, vectorized), and the byte-exact merge runs only inside a page that differs. Same bytes as before; unit-tested against the old routine on random data, both sides changed included. - A, the copies' merge-back is reported: each copy keeps its pages' DirtySource and a writer id. sync collects the runs it wrote, and merge_back reports them with wrote_as before the completion is visible. Bytes a read-only copy drops are not reported. - B, the runtime's own CPU writes into logged pages are reported: replaceRegion into a heap's shadow texture (texture/heap.rs), the argument encoder and copyParameterDataToBuffer, as buffer_texture.rs already did. - C, GPU writes into logged pages imported in place are reported: each command buffer's written uses over memory with a dirty source, as writer 0 (the consumer's own writes, which every copy counts). They are reported at commit, before signals in the completion turn, and at completion, minus the shadows' own copy-backs. Collection is on while copies or such imports are live. Past the use cap, each written import is reported whole. A texture's use is reported as its whole buffer or heap (correct, coarse). This also closes the texture-shadow gap for pages reached through two imports. - Change 1, the log gates the copy in: where a copy's pages have a log (HostRam::with_dirty_pages, or the object's HostMemory::with_dirty_pages), a commit compares only the pages the log reports written since the copy last agreed. It uses one stamp per log and commit for every copy, waited for as the shadows' gated copy-in waits (DirtyPages::wait). A false wait, a copy's first copy in, bytes no log covers, and a copy that merged back 1 MiB or more since its last copy in compare everything. The copy in now runs before the commit's second state-lock block, since it may wait up to the log's bound. - Change 2, merge-back skips copies no finished batch may have written. Its "may write" is the bindings' write answers plus unnamed reach: a command buffer with a function that reads addresses (a root table), or one that executes an indirect command buffer, counts every copy as written. WorkCounts (new): copied_copy_in_bytes_skipped, copied_merges_compared, copied_merges_skipped. RUNTIME_VERSION 1705. Docs: copied.rs (Cost, Coherence), dirty_pages.rs' trait doc (what the runtime reports), FAST-PATHS (copied-host-pages known gap; the shadow gap closed), HOWTO copied host buffers. Measured, release, 680 MiB of live copies (2,049), median of 7, copy in / merge back in ms: - RTX 5080 laptop host (Core Ultra 9 275HX): - nothing changed: 231.8 / 231.6 before; 0.16 / 0.00 with all three; - 1% of pages changed: 233.7 / 233.8 before; 3.43 / 33.0; - one copy redrawn: 254.6 / 261.6 before; 29.4 / 34.1. - M3 Max: - nothing changed: 314.5 / 314.0 before; 0.12 / 0.00; - 1% of pages changed: 321.4 / 321.4 before; 4.54 / 18.5; - one copy redrawn: 353.9 / 395.4 before; 39.4 / 54.9. The merge-back figures are with the batch naming what it writes. A real frame's skip rate was not measured; the new counters show it. Verified: - M3 Max, MoltenVK 1.4.2, --cfg m2v_gpu, under memcap and maclock: the runtime lib suite passes 1445, 2 skipped. - RTX 5080 Laptop, NVIDIA 615.71.09, one 42 s hold: copied|dirty_pages| host_ram|event 101 pass. - New tests: 6 plain gating and merge-skip tests; a contract test that a concurrent CPU write survives both ways, log on and off; 7 device tests of the B and C reports, the gated copy, a read-only batch skipped, and an unnamed write still merged back. - Negative controls, each shown failing then passing once restored: gate forced off; A's report removed; C's registration or completion reports removed; the shadows' copy-backs not subtracted; B's heap report removed; merge skip forced off; unnamed reach ignored. - clippy plain and --cfg m2v_gpu (Mac, and msi niced), rustdoc -D warnings, api_signatures, api_surface, fast_paths. Lane commits: ws/cpusync-lane (180fc103c1 .. 59d82299ad, 9 commits). One work packet, landed as 2 commits on archive/development-linear-2026-10-29: bb00ae47f6, then 2b8ad3ab58 (the re-pin). |