db2bdfbe9548d76b8626d02edddded4f31c04417
1100
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
db2bdfbe95 |
Draw an encoder's last direct draw again: a draw that repeats it with no call between records its Vulkan draw alone
A render encoder keeps its last plain direct draw (render/draw_again.rs): the call, what it assembled, its draw and in-place index source, what it read of the state that changes with no call of the encoder (no-copy moves, residency generation, host aliases, the parts and holds its noting reads), its command buffer and its Vulkan draw command. Every call but the two direct draws forgets it as it logs itself, refused or not. A draw that matches it records the kept vkCmdDraw* alone, notes its uses' reads of fresh textures, keeps itself for recording again, adds its execution record where the device keeps them, and counts itself in encoder-local counts that reach the device's at the next call, the pass's end or an error (WorkCounts::draws_as_before, new). Only a draw that recorded one Vulkan draw into its instance as it stood, through a pipeline made ahead, with no barrier, write, split, shadow, snapshot, rewrite pass, set 1, root table or push hole, and no notice announced at every occurrence, is kept. Exact: the same Vulkan commands and barriers, the same notices, retains and refusals. A draw again repeats only steps whose answer is provably the kept draw's; the rest are idempotent (the drawn area, coverage, gathered uses, noted uses, retains); PassStartReads' Written::add now skips an equal range already held, so a repeated read adds nothing. In builds with debug assertions the first draw again of a kept draw and every second after it take every step and assert they announced nothing, recorded no state command, kept an equal draw, retained only the index buffer again, and left drawn area, coverage, reads, gathered uses, noted uses and the instance as they were. Tests: src/tests/draw_again.rs (5 device tests: draws again record the commands, barriers and pixels the same draws record with a do-nothing call between; indexed draws of the same indices; other draws take every step (base instance, indirect, a fragment-write draw); a draw after a no-copy buffer moved takes every step; a notice announced at each occurrence is announced at every draw). draw_shape_notices and the draw_work lane count draws_as_before beside draw_shapes_reused. Runtime GPU suite on MoltenVK (M3 Max) passes, the cross-check on. host_ab encode, release, 10k draws per command buffer, 200 timed, us/draw, three interleaved rounds: median of round medians / mean of round medians / max of round p90s. Apple M3 Max, MoltenVK 1.4.2: static 1.260 / 1.251 / 1.290 -> 0.042 / 0.042 / 0.047 offset 1.464 / 1.455 / 1.521 -> 1.493 / 1.480 / 1.545 bind 1.645 / 1.647 / 1.713 -> 1.693 / 1.687 / 1.742 The offset and bind draws take every step and pay the keep (+29 and +48 ns on the M3). The RTX 5080 rounds follow in the next commit's message. (cherry picked from commit 8e6b49b8c371ec2e3c2aa6031a3a09145997cd2e) |
||
|
|
5bf9843569 |
host_ab: offset-only draws, and draws on 1 to 8 threads at once
The encode workload gains `draw_offset`: one vertex buffer's offset changes before each draw (`setVertexBufferOffset:atIndex:`), the consumer's measured per-draw shape, between `static` (nothing changes) and `bind` (buffer and texture change). A `threads` workload draws the encode workload's static and offset draws on 1, 2, 4 and 8 threads at once, each through a command queue of its own (`Gpu::with_own_queue`) into its own target, of its own rectangles, texture and sampler, once through one shared pipeline state and once through a pipeline state of each thread's own. Per case, over 3 runs: the draws a second of all threads together, each thread's CPU time per draw and the process's. The trait's device, libraries and render pipeline states are `Sync` for it (Metal's are; Metal's buffers and textures are not marked so in objc2-metal, which is why each thread makes its own). Verified: clippy -D warnings on the example (both sides compile on macOS); `draw_offset` ran on the M3 Max and the RTX 5080 Laptop (numbers in the next commit). (cherry picked from commit 5ae9a2d98135b7129b0f44b4ab2b98982f2588d7) |
||
|
|
0491eb2c75 |
Pin the runtime sources after the submit and completion path's changes
What: crates/metal2vulkan-validation/runtime-sources.sha256 recomputed on this tree
(pin-compute.py: listed=58 inputs=494, 5045f87b...). The pinned inputs this branch changed are
the runtime's command_buffer/{mod,own,completion,submit}.rs, contexts/mod.rs, scheduler/mod.rs,
exit_guard.rs, error.rs, texture/first_move.rs, work_counts.rs and the translator's
cache/mod.rs (RUNTIME_VERSION 1737): the completion-seen handlers, command buffers that need no
GPU work taken with no submission, and idle waiters and scheduler sleeping untimed; the
behaviour change is the bump before this commit.
Verified: candidate::engine::artifact::tests::the_runtime_sources_are_the_committed_ones passes
on this tree.
(cherry picked from commit c87df4e91ae16916c369e753af103d458bf76cb2)
|
||
|
|
3820cb43ed |
Bump RUNTIME_VERSION to 1737: the submit and completion path's changes
A run of an unchanged artifact and plan may now do something else in what it submits and where its handlers run: a command buffer with a completion-seen handler (a new runtime extension) runs it on the thread that saw its completion; a command buffer that needs no GPU work (nothing recorded, no event or semaphore waits or signals, no first work waiting) is taken with no vkQueueSubmit and completes in its queue's order, finished by the thread that took it where its queue has nothing in flight; idle queue waiters and an idle scheduler sleep with no timeout. 1737 is the number this change was given (1735 and 1736 are other lanes'). (cherry picked from commit ab4390d60cb275e6fe7ce48d5f05a890d83145c3) |
||
|
|
d5c71b9848 |
Add the submit_path example: a command buffer's fixed cost on the submit and completion path
What: crates/metal2vulkan-runtime/examples/submit_path.rs, registered in the crate's manifest (autoexamples is off). Modes: latency (one thread commits a 16-byte fill with a scheduled and a completed handler, or with --seen a completion-seen handler instead, and blocks on a condition variable the handler signals: commit to handler start at idle gaps of 0, 100 us, 300 us and 2 ms, p50/p90/p99 over 2000), cpu (the same command buffers as fast as the slots allow, never waited for: command buffers a second and CPU per command buffer by thread group, from /proc/self/task/*/schedstat on Linux, else the process's CPU less the committer's), empty (commit and wait of a command buffer with nothing encoded, back to back and at a 300 us gap; then never waited for, with the queue submissions made). Why: the consumer's per-command-buffer path (record, add handlers, commit, never wait) had no measurement in the tree that runs on both the M3 Max and Linux; host_ab is being changed elsewhere. Verified: built in release on the M3 Max and run there (the numbers are in the change reports, not here); clippy clean with all targets. (cherry picked from commit 067b6a7792210909bbf4f1e66bf2eb9b39334c0d) |
||
|
|
ede69fae31 |
Let idle queue waiters and an idle scheduler sleep until they are woken
What: a queue's waiter parked with no batch of its queue pending now sleeps on its condition
variable with no timeout (completion.rs `wait`); parked with a batch pending (left to a turn
under way, held by a drain, a failure pending) it keeps the 100 ms slice. The scheduler's thread
sleeps with no timeout where its order and group hold nothing, no head has a bound and no
driver's stall is due; otherwise it keeps its slice. The GPU waits (fence and timeline, in
`poll`/`settle`), a drain's wait and rerun.rs's fence waits keep their slices. New WorkCounts:
completion_waiter_parks and completion_waiter_parks_timed_out (reported, not gated, in the
conformance cost half: when a thread sleeps).
Why: an idle device's five waiter and scheduler threads each woke every 100 ms (on the M3 Max
over 350 ms idle: 15 waiter parks that timed out, 3 scheduler slices), which is CPU and wakeups
for nothing on a consumer's idle guest, and the slice hid any missed notify behind a 100 ms
stall.
Audit: every change a parked waiter waits for, each made under `pending`'s lock and notifying
where `Pending::parked` says it sleeps, or every waiter:
- Completion:⌚ a batch pushed on its queue; notifies that queue's waiter where parked.
- Completion::watch_unsubmitted: as watch, except where the batch owes its turn to the taker
(queue reached, no turn, no hold, no failure, not exiting): then the taker's turn_owed makes
the turn, or the turn under way takes it at its next look, or another taker's turn took it.
- turns(): a look that takes a queue's batches notifies its waiter where parked and its queue
still holds a batch, or the waiters stop (a parked waiter with an empty queue has nothing to
arm for; the next watch wakes it).
- take_pending (a failure's drain): wake_all after giving the batches back.
- Completion::stop: stopping set, wake_all.
- exit() and a waiter that found the process exiting in its wait: exiting set, wake_all.
- A waiter's failed wait sets `failed` and wakes no one: the turn it or the turn under way makes
takes it as Turn::Failed, which ends in take_pending's wake_all.
- `reached` and `waiting` change only for the waiter's own queue, by that waiter.
The scheduler: a commit (Inbox::post marks the state under its lock, or leaves it to a counted
passer, whose look_again or passed_over wake covers it), a host signal (Scheduler::waker,
decode_finished, wake_for), and stop (stopping under the lock, then notify_all) each notify the
thread where it sleeps; completions matter only with a head held, where the slice is kept.
Tests (--cfg m2v_gpu, M3 Max, MoltenVK 1.4.2): tests::completion_wakes::
an_idle_device_s_waiters_and_scheduler_stay_asleep (0 parks, 0 timed out, 0 scheduler sleeps
or slices over 350 ms idle; with the waits kept timed: 15 and 15, 3 and 3, fails) and
with_parks_unbounded_every_change_still_wakes_its_waiter (a test-only switch makes every park
untimed, pending batch or not; three queues of fills with handlers, empty command buffers alone
and behind fills, a head held for a host signal, idle gaps, then the device's drop on a bounded
wait: passes; with Completion::watch's notify removed it stalls at round 0's held command
buffer and fails at its 20 s bound). The whole runtime GPU suite 1509 of 1509; the conformance
crate's tests 1010 of 1010; clippy clean in both configurations.
(cherry picked from commit ac3a8ff8de6e780e0c7233340dcc2b0ac95c0b5d)
|
||
|
|
53e2a6be78 |
Complete a command buffer that needs no GPU work without submitting it
What: a command buffer whose encoders recorded nothing and whose one batch waits for and signals no event and no binary semaphore (so presents no drawable) is taken by the scheduler with no vkQueueSubmit (State::needs_no_gpu, decided from what it recorded), once it leads its logical queue's line, no group is held and no first work of the device's waits (that still rides in it, as before). Everything else its last batch's taking does is kept: kernel times, scheduling (by a hang's thread where one makes it), submission handlers, heap tickets, own textures, holds. Its batch is watched at its VkQueue's last submitted value (Completion::watch_unsubmitted), so it completes in its queue's order, after the work submitted before it, from the turn that finishes that work. Where its queue reached that value already and no turn is under way, no waiter is woken: the thread that took it (the scheduler's after its round's submission handlers, or a thread about to block, after its pass) makes the turn once it holds no lock (Completion::turn_owed), running only the transitions a thread there may run. A turn no longer wakes a parked waiter whose queue it emptied (it has nothing to arm for; the next watch or a stop wakes it). New WorkCounts: command_buffers_unsubmitted, completion_turns_where_taken. GPU-time placement is unchanged (NoWork: a point at the later of its kernel end and its queue's latest end), which the new conformance case shows matches Metal's booleans. Why: the consumer commits empty command buffers as sync points; each was a vkQueueSubmit, a waiter wake and a turn. Metal completes them without its GPU (M3 Max, macOS 27.0.1: idle, commit and wait 15 us p50, GPU interval 0 to 0.3 us, 1 to 9 us after kernelEndTime; behind a fill, after the fill, 65 to 135 us after its GPUEndTime). Conformance: new case empty-command-buffers (statuses in handlers and after the wait, the four timers' signs and orders, GPU interval one point, behind a 64 MiB fill: completed-handler order, the fill's status in the empty one's handler, kernel and GPU times against the fill's), recorded on the M3 Max (5 of 5 runs identical), cost and contrast and times written; replayed on the M3 Max over MoltenVK: announced (only gpu-times-from-host, declared). completion_turns_where_taken is reported, not gated (which thread made the turn is a race with the GPU); the M2 handler counters are classified with the submission region. Coverage doc regenerated. The lane test empty_command_buffers_submit_no_command_buffer becomes empty_command_buffers_make_no_submission (0 submissions, 8 unsubmitted). Verified on the M3 Max (MoltenVK 1.4.2), --cfg m2v_gpu: tests::unsubmitted (3 tests; idle: 81 unsubmitted, 0 queue submissions, 40 of 40 waited ones finished by the taker, 0 waiter wakes); negative control with the path disabled: 0 unsubmitted, 81 submissions, 40 waiter wakes, both empty tests fail. The whole runtime GPU suite: 1506 of 1507, the one failure video_interop::a_raw_submission_is_ordered_by_a_shared_event_s_semaphore read its event's signal already Reached under the full suite's load, and passed 6 of 6 alone (its command buffers wait and signal, so never take this path). The conformance crate's tests 1010 of 1010; clippy (workspace, all targets and features; and runtime + validation under --cfg m2v_gpu) clean. Not run here: the validation lane tests (commit_work, first_use, gpu_times) and lavapipe. Owed on development: conformance cost bounds of cases with empty command buffers now read fewer queue_submissions and a nonzero command_buffers_unsubmitted (a re-bless). (cherry picked from commit 304bdd2a24e31f7aeb3045e33b9d21209ca7df97) |
||
|
|
fd7c93af53 |
Run a command buffer's completion-seen handlers where its completion is seen
What: `CommandBuffer::add_completion_seen_handler`, a runtime extension with no Metal counterpart. Its handlers run as the command buffer's transition to `Completed` or `Error` runs, right after its status, error and GPU times are final, before its completed handlers and before `wait_until_completed` returns. A transition with completion-seen handlers and no completed handler runs where seen (`Transition::where_seen`, `Run::runs_where_seen`), on the queue's waiter, as a plain one does: no handler-pool turn. Where the transition is posted (a completed handler, an earlier transition of the queue in its context, a deallocator of the program's held), the handlers run in it on the handler thread, so they keep the queue's commit order against every completed handler. A wait in one for what has not happened is refused with the new `DeadlockCause::CompletionSeenHandler`, as a submission handler's is, wherever it runs. `Contexts::run_here` takes the predicate its caller may run: the waiters and the scheduler (`exit_guard::serving_completion`) run where-seen items, any other thread plain ones only. Why: the consumer's per-command-buffer completion pays a handler-pool wake after the waiter (about 100 us from an idle CPU on the RTX 5080 laptop, and its p90 tail). Its completed handler is short and posts a record; moved into a completion-seen handler, the command buffer finishes on the waiter with one wake fewer. Order choice: the handler runs inside its transition, never ahead of it, so a command buffer's completion-seen handler cannot run before an earlier command buffer's completed handler on the same queue's context; it runs at the turn only where that context holds nothing else. Counted: `WorkCounts::completion_seen_handlers_run` and `completion_seen_handlers_where_seen`. Verified (M3 Max, MoltenVK, under the GPU lock): `tests::completion_here` (the new `a_completion_seen_handler_runs_where_the_completion_is_seen`: 20 of 20 ran on `metal2vulkan-queue-wait-*`, status `Completed`, GPU end positive, own completion wait refused, own scheduling wait returned; with a completed handler 0 of 20 where seen, each before the completed handler), `tests::own`, `tests::contexts` (the new where-seen run_here test): 24 passed. Negative control: with completion-seen handlers making the transition not where-seen, the new test fails (0 of 20). Workspace clippy (all targets, all features) and runtime clippy under `--cfg m2v_gpu` clean. api_signatures blessed, docs/REFUSALS.md regenerated. (cherry picked from commit bb7fd805045a9903a3a1ae06595e264ad771049c) |
||
|
|
a5e4bd1aca |
Pin the runtime sources after moving decoded-texel-precision to the twin's first read
What: crates/metal2vulkan-validation/runtime-sources.sha256 recomputed on this tree (pin-compute.py, 9cced23b...). The pinned inputs this branch changed are the runtime's texture.rs, texture/decoded_twin.rs, heap_sets.rs, degradation.rs and chroma_pairs.rs: the announcement of decoded-texel-precision moved from a decoded twin's making to its first read, which a run of an unchanged artifact and plan observes, so RUNTIME_VERSION is 1734 (8c84951a7e). Its message's "(1732 and 1733 are other lanes')" is an assumption, not checked: 1734 is the number the orchestrator gave. SEMANTICS_VERSION stays 1949: no translator output changed. Checks on this branch (M3 Max, macOS 27.0.1, MoltenVK 1.4.2; Rust 1.98): - cargo fmt; clippy -D warnings with --all-features and with RUSTFLAGS='--cfg m2v_gpu': clean. - Private intra-doc links 0 / 3 / 70 / 0 / 0 / 0 (at the ceilings); api-signatures --check; the refusal surface regenerates unchanged. - core nextest (metal2vulkan, air, runtime, devtools): 5,007 passed, 23 skipped. Conformance: 1,007 passed. The runtime guard (the_runtime_sources_are_the_committed_ones) passes with this pin. - The runtime's suite with --cfg m2v_gpu on MoltenVK: 1,502 passed, 3 skipped (twin_reads' three tests among them). - Lanes on MoltenVK (texture_fills, texture_blits, degrade_notices, chroma_pairs, astc, etc, pvrtc, compressed, format_footprints, ycbcr, two_plane_samples): 116 run, 114 passed. The two failures, two_plane_samples_are_metal_s (6 of 8 cases differ from Metal) and a_ycbcr_sample_through_an_unmeasured_filter_is_announced (no ycbcr-filter-not-exact for an anisotropic constexpr sample), fail identically on 57b3b26ba0: not this branch's. - Conformance replay on MoltenVK of texture-fills-240/241, chroma-pair-copies-*, chroma-pair-texel-reads-*, chroma-pair-texel-samples-*, texture-pairs-usage-crossings and format-footprints-astc-4x2-and-8x4: 9 announced (justified), 1 exact; decoded-texel-precision fired in the four texel read and sample rows alone. (cherry picked from commit 17a1c34c1c45b62e99b07b5ba19558a4f32bbee4) |
||
|
|
07b2c5574a |
Bump RUNTIME_VERSION to 1734: decoded-texel-precision moved to the twin's first read
A run of an unchanged artifact and plan now announces decoded-texel-precision at a command's first read of a decoded twin (a sampled binding, a heap set holding the twin, or its placement in a set a pending command buffer bound) instead of where the texture is made: a run that makes, writes, fills or copies such a texture and reads no twin announces it no more. 1734 is the number this change was given (1732 and 1733 are other lanes'). (cherry picked from commit 8c84951a7e98d20ccd04c523619309dd4f0d487b) |
||
|
|
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) |
||
|
|
5dec29242f |
Pin the runtime sources after the half-conversion and NaN-encoding carve-outs
What: crates/metal2vulkan-validation/runtime-sources.sha256 recomputed on this tree (pin-compute.py, 3830c23e...). The pinned inputs this branch changed are the device derivation files (device/derive.rs, driver_facts.rs, profile.rs, requirements.rs): two new driver deviations and their properties, which only the translator reads. A run of an unchanged artifact and plan does nothing else (the runtime names neither deviation, and a profile that takes them has a new fingerprint, so an artifact compiled before misses the cache), so RUNTIME_VERSION stays 1731, as for the earlier MetalNanMoves and MetalPackConversions carve-outs. SEMANTICS_VERSION 1949, ARTIFACT_FORMAT_VERSION 484. Checks on this branch, rebased onto ef392b28b1 (M3 Max, macOS 27.0.1, MoltenVK 1.4.2; Rust 1.98): - cargo fmt --check; clippy -D warnings with --all-features, with metal2vulkan's serde, ash and cli each alone and with no feature, and with RUSTFLAGS='--cfg m2v_gpu': clean. - Rustdoc -D warnings; private intra-doc links 0 / 3 / 70 / 0 / 0 / 0 (at the ceilings); scripts/api-docs; api-signatures --check; conformance coverage --check; the refusal surface regenerates unchanged; goldens re-blessed unchanged. - core nextest (metal2vulkan, air, runtime, devtools): 5,007 passed. Conformance: 1,007 passed. Validation: 1,362 passed, 4 skipped (the runtime guard among them). Doctests: none run. - The runtime's suite with --cfg m2v_gpu on MoltenVK: 1,499 passed, 3 skipped. - 401 validation lanes on MoltenVK (the 56 modules that check announcements or these notes): 393 passed, 8 failed; each of the 8 fails identically at cd578f9cbc (driver_deviations' five float and half answer lanes, native_maths' recorded bounds, mipmap_chains' blit chain, the YCbCr unmeasured-filter announcement). (cherry picked from commit 57b3b26ba058342fe84795a508bb2e115dc275ae) |
||
|
|
eac2986705 |
Fix forward three core tests the carve-outs moved
What: - tests::engine_sampler::normalized_and_cubic_stages_record_no_note_their_states_cannot_run: sample_grad's half result is the conversion of an image instruction's texel, measured to be Metal's on moltenvk-m3 (MetalHalfConversion), so it records no NativeHalfConversion; the cubic half samples, whose filter the module sums in float, keep it. - tests::engine_native_half::native_half_rounding_records_its_kind_and_requires_no_fact: on moltenvk-m3 both kernels convert a float the function holds (and add halves natively), so they record no note and require VkProperty::MetalHalfConversion; the other profiles are unchanged and require nothing. - tests::engine_handles::a_heap_texel_write_is_the_devices_write: a float texel written through an argument buffer's texture records no DeviceNanEncoding on a profile that takes both MetalHalfStorageNans and MetalSmallFloatNans (moltenvk-m3), and requires VkProperty::MetalSmallFloatNans wherever the profile takes it; a half texel's heap write keeps the note everywhere. Verified: the three tests pass (core nextest --all-features, filtered). (cherry picked from commit d5f35ffc7b507db9cf88485c9ba4e07c5d206161) |
||
|
|
196bdf8135 |
Fix forward the expectations the half-conversion and NaN-encoding carve-outs moved
What: - tests::engine_extended_range::half_float_storage_slots_leave_their_writes_to_the_device: a formatless half-float storage slot's float write no longer records DeviceNanEncoding for the packed small float format on a profile that takes MetalSmallFloatNans (moltenvk-m3), and requires VkProperty::MetalSmallFloatNans there; the test and its doc now say so. - runtime_lane::native_maths::half_rounding_answers_within_its_recorded_bound: a module whose conversion is measured to be Metal's (VkProperty::MetalHalfConversion) announces nothing and must answer Metal's exactly, as under the float controls. On MoltenVK it does: 8192 of 8192 answers Metal's exactly. - runtime_lane::ycbcr_textures::a_four_four_four_texture_s_writes_store_metal_s_codes: the half write's YCbCrWrite variant bitcasts the widened half's lanes to words for the runtime's encode, which records NativeNanEncoding on every device (as before). The kernel's own stage no longer records it on MoltenVK, so the variant's dispatch announces it there; the lane expects it exactly where the write's stage does not record it (Kernels::half_write_nans). - runtime_lane::ycbcr_textures::srgb_twins_read_what_metal_reads: a half nearest sample of an sRGB twin through a runtime sampler slot is the device's rounding of the float it reads (MoltenVK: toward zero, 8,409 channels over the six surfaces and three matrices, each within one half ulp of Metal's ties-away step), which HalfTexelConversion announces at the bind. The lane licensed it by the stage's NativeHalfConversion, which the read no longer records; it now asserts the bound and that HalfTexelConversion was announced (assert_half_samples). - golden_hashes.tsv: the moltenvk-m3 profile's hash (the two new deviations). Verified on this M3 Max (MoltenVK 1.4.2, macOS 27.0.1): the core test passes; the three lanes pass. The diagnosis of the 4:4:4 note used a temporary dump of the variant's instructions (not committed): StorageImageClass::YCbCrWrite, R32G32B32A32_UINT, a Bitcast of each widened lane. (cherry picked from commit 0baa910d6acff2838ffb801f608ad29bffa0331c) |
||
|
|
763965c854 |
Record a texture write's NaN encoding only where its stored NaN is not measured to be Metal's
reims-vgpu treats precision notes as fatal on Apple GPUs. A kernel's write of halves into a
32-bit float or RG11B10Float texture died with DeviceNanEncoding, and through NativeNanEncoding,
on the M3 Max where the stored bytes are Metal's; a write of a constant texel with no NaN died
the same way on every device.
What:
- A new DriverDeviation::MetalSmallFloatNans (VkProperty::MetalSmallFloatNans), taken by the
APPLE9 MoltenVK row alone: the device stores a float's or a half's NaN written to a
B10G11R11_UFLOAT_PACK32 storage image as Metal does.
- half_write_nans (a half texel's write) classifies the slot's storage choice: a 16-bit float
format takes MetalHalfTexelWrites as before, a 32-bit float one MetalNanMoves (the widened
half's bits are Metal's 0x7fc00000), the packed small float one MetalSmallFloatNans; a taken
deviation drops the note and requires its property. A slot declared without a format (every
float storage choice on MoltenVK and lavapipe) records the note under the bound format's class
(a SpecializedNote of BoundTexelFormat), one clause per class the profile does not cover, so
the runtime announces it only when such a texture is bound.
- half_storage_facts (a float texel's write) drops the small-float note the same way.
- A texture write of a constant texel none of whose lanes is a NaN records neither note.
- A new module side table, stored_texels, records each texture-family write's texel (kept
through edit.rs's retain and the roll pass's check). narrow::moves_unfolded no longer counts a
widened half's store as such a texel as an escape: the write's own DeviceNanEncoding accounts
for its stored NaN under the format it stores.
Verified on this M3 Max, byte for byte against plain Metal (an MSL probe): a float4 write of
33,792 words (16,446 NaNs) and a half4 write of all 65,536 halves (2,046 NaNs) into RG11B10Float,
RGBA32Float, RG32Float and R32Float store Metal's bytes; into R16Float and RGBA16Float a half
NaN's payload differs (the device stores 0x7e00), so those keep the note.
- runtime_lane::half_write_nans on MoltenVK: half writes into rgba32f, r32f and rg11b10f announce
nothing and 0 texels differ; rgba16f announces device-nan-encoding (2,045 NaNs differ). Without
note_stored_texel the lane fails ("write r32f: ... native-nan-encoding true").
- New core tests: a_half_texel_write_s_nan_into_wide_and_small_float_images_is_metal_s_where_
measured (declared and formatless choices on moltenvk-m3 with and without each deviation, and
lavapipe; the bound-class clauses evaluated per format) and a_constant_texel_without_a_nan_
records_no_nan_encoding (zero and 0x7e00 constants, every committed profile); the existing
device-nan-encoding and half-storage-notes tests follow the deviations. Each fails with its
change disabled (the NaN test forced true; the stored-texel exemption removed).
- Notes of every public fixture on moltenvk-m3, lavapipe and nvidia-rtx5080-laptop before and
after: DeviceNanEncoding leaves 65 moltenvk-m3 rows and 6 rows on each other profile (constant
texels), 17 formatless rows per profile go from unconditional to specialized by bound format,
58 moltenvk-m3 rows lose their small-float clause, NativeNanEncoding leaves 11 moltenvk-m3 rows,
and no row gains a note. Consumer AIR on moltenvk-m3: DeviceNanEncoding 33 entries to 21,
NativeNanEncoding 9 to 5.
Docs: API.md (device-nan-encoding and native-nan-encoding exemptions), HOWTO.md, the
PrecisionNote, VkProperty and deviation rustdoc, the driver-facts measurement record.
api_signatures gains the two variants. The versions bumped in the previous commit cover this one.
(cherry picked from commit 05d96c61107989813c186961087ee70d573cf876)
|
||
|
|
217cc233f5 |
Carve MoltenVK on the M3 Max's identity out of NativeHalfConversion for measured conversions
reims-vgpu treats precision notes as fatal on Apple GPUs; NativeHalfConversion was its largest group of Mac-only failures (37 tests). The note says a half rounded through the device's conversion to 16 bits and back may differ from Metal's. On the M3 Max (MoltenVK 1.4.2, macOS 27.0.1), MoltenVK writes OpFConvert to 16 bits as MSL half(x), which is Metal's half(float), and Metal's compiler folds the conversion of an image instruction's float texel into the access. What: a new DriverDeviation::MetalHalfConversion (VkProperty::MetalHalfConversion), taken by the APPLE9 MoltenVK row alone. Where the profile takes it: - narrow::round_measured rounds a float the function holds (an AIR fptrunc or air.convert from float, through resize) by the conversion pair and records the pair's narrowing in a new module side table, measured_roundings (kept through edit.rs's retain and the roll pass's check); - narrow::rounds_unmeasured finds any other conversion pair: one neither recorded nor of a texel an image read, fetch, sample or gather hands back (directly, through a composite extract, or through a parameter every call passes such a texel); - the compile records NativeHalfConversion only where such an unmeasured pair exists, and otherwise requires the property. A half operation or function computed in float and rounded keeps the note: Metal's half tanh answers 7 of the 65,536 halves otherwise than the conversion of its float tanh. exp, sqrt and a reciprocal on half matched, but they are functions, not the conversion, so they stay noted. Verified on this M3 Max, word for word against plain Metal (an MSL probe, fast and safe math): - the conversion of a float loaded (425,216 words), of a sum, product and quotient (144,896 pairs each), of an fma (123,648) and of an integer's quotient (190,208): 0 words differ; - the half result of read, nearest sample at the centre, linear sample a quarter texel off and gather of every texel of ten formats (RGBA32Float, RGBA16Float, RGBA8Unorm and its sRGB twin, RGBA8Snorm, RGBA16Unorm, RGBA16Snorm, RGB10A2Unorm, RG11B10Float, RGB9E5Float): 0 differ. - New lane runtime_lane::half_conversions on MoltenVK: load, sum, product and fma kernels carry no note and 0 of 253,958 lanes per kernel differ from the half model; the half tanh kernel keeps the note. With measured_conversion forced false the lane fails. - New core test half_conversions_are_metals_where_measured: the four forms lose the note and require the property on moltenvk-m3 with the deviation, keep it without the deviation, and the half tanh keeps it on both; it fails with the carve disabled. - Notes of every public fixture on moltenvk-m3, lavapipe and nvidia-rtx5080-laptop before and after: NativeHalfConversion leaves 58 moltenvk-m3 rows, and no row gains a note. Consumer AIR on moltenvk-m3: 23 entries noted before, 2 after (a heap texture's held half read). Docs: API.md (native-half-conversion exemption), HOWTO.md, the PrecisionNote, VkProperty and deviation rustdoc, the driver-facts measurement record. SEMANTICS_VERSION 1949 and ARTIFACT_FORMAT_VERSION 484 (new VkProperty variants in the codec); these bumps cover the rest of this branch. api_signatures gains the two variants. (cherry picked from commit 266f7cd26327e408d9cd1f0d6ea5ba33e49e10b3) |
||
|
|
a44a550cbb |
Pin the runtime sources after the reserved queues
crates/metal2vulkan-validation/runtime-sources.sha256 recomputed on this tree (~/.cache/m2v-orch/pin-compute.py: 58 listed, 494 inputs, 2f1b9c71...). The hash alone moves: RUNTIME_VERSION stays 1731, as no run of an unchanged artifact and plan does anything else. With DeviceOptions::reserved_queues at its default of 0, queue_plan makes the plan it made before (the round robin less presenting's two, the same presenting and staging queues), the device's queue_families are the same, and no message is sent; only a consumer that asks for reserved queues gets a different queue plan. (cherry picked from commit ef392b28b1c6d1443ae9d6c672d4bf059403385d) |
||
|
|
5a09b10c21 |
Read whether a device spares a reserved queue from its round robin, not from its plan
The device test a_reserved_queue_is_a_runtime_family_s_and_no_command_queue_takes_it took its expectation from queue_plan, so a plan that never reserved would have passed it on its no-spare path on every device. It now reads the expectation from what the same device without the reservation does: it spares a queue exactly where that round robin has more than its floor of LEAST_QUEUES VkQueues, and the reservation then leaves the round robin one fewer (unless it sat at ROUND_ROBIN_CEILING with a queue free past presenting's). The plan stays a cross-check. LEAST_QUEUES and ROUND_ROBIN_CEILING are pub(crate) for it. Verified on the M3 Max (MoltenVK 1.4.2): the touched device tests pass (32 of the device, queue_sharing, video_interop and reserved_queues tests). (cherry picked from commit f72b73bbb47dc1792db894b9f7fcde9ae415dd41) |
||
|
|
0dae0acd0d |
Reserve queues of the runtime's own families for the caller, out of the round robin
DeviceOptions::reserved_queues asks a created device for that many queues of its own queue families, which DeviceHandles::reserved_queues returns as ReservedQueue (family, VkQueue). They are the round robin's last queues, taken out of it: the round robin shrinks by each one, and no command queue, presenting or not, and no internal or staging copy ever submits to them. A consumer that waits on the GPU for its own work (a video decode's timeline) before a copy into the runtime's buffers no longer holds back a command queue that shares the VkQueue it borrowed through CommandQueue::with_vk_queue. queue_plan takes the reserved count: the round robin keeps its first four (LEAST_QUEUES) and the presenting reservation its two before the caller has any, so presenting keeps its priority, and a family with queues past the round robin's ceiling and presenting's two gives those first. On NVIDIA's graphics family of 16, one reserved queue leaves the round robin 13 and presenting 2. A device with none to spare (MoltenVK's four families of one queue, lavapipe's one queue, a family of six) reserves what it has and is made all the same, saying so once in an informational message (metal2vulkan-reserved-queues-absent). Extra queues are placed after the reservation and never take a reserved queue. queue_families includes the reserved queues' families, so the runtime's buffers and images are always shared with them; the docs say what a submission there may do with the runtime's objects (no ownership transfer; their handles' contracts; semaphores or completion; GENERAL images). API: a new DeviceOptions field (reserved_queues: u32, 0 by default), a new DeviceHandles field (reserved_queues), a new public struct ReservedQueue. Nothing breaks for a consumer: both structs are #[non_exhaustive]. api_signatures.tsv blessed; docs/REFUSALS.md regenerated unchanged. Tests: - tests::device::reserved_queues_leave_the_round_robin_after_presenting (pure): NVIDIA's shape with 1, 10, 11, 64 and u32::MAX reserved, families of 5, 6, 7 and 24, MoltenVK's and lavapipe's shapes, equivalent families, extra queues beside a reservation, and the message. - tests::reserved_queues (device tests, m2v_gpu / m2v_cpu_icd): a reserved queue is of one of queue_families, the round robin takes one VkQueue fewer than the same device's without it, and none of 17 command queues or 3 presenting queues takes it; a device asked for one more than it spares reports the absence and runs a command buffer; a raw copy on the reserved queue moves the runtime's own Private buffers between command buffers ordered by a shared event's semaphore. Verified on the M3 Max (MoltenVK 1.4.2): the device tests pass on their no-spare path (0 of 1 reserved, reported; round robin 4 with and without); clippy clean with all features, plain and --cfg m2v_gpu. (cherry picked from commit dc75265b857b79bee7795a3692940cc723bf7fd9) |
||
|
|
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) |
||
|
|
1b72a7a7b7 |
Pin the runtime sources after the compressed-extended-range blits; fix forward the gate's findings
What:
- crates/metal2vulkan-validation/runtime-sources.sha256 recomputed on this tree
(`pin-compute.py`, c96c5883...). RUNTIME_VERSION is 1731 (set by the extended-range blits
commit), SEMANTICS_VERSION 1948, ARTIFACT_FORMAT_VERSION 483.
- tests::engine_sampler::normalized_and_cubic_stages_record_no_note_their_states_cannot_run (from
the lane's pixel-note fix) expected NativeNanEncoding on moltenvk-m3 for `sample_grad` and the
cubic half samples. Since the MetalNanMoves carve-out those stages' half widenings move
through registers as measured, so they record NativeHalfConversion (and the cubic stages
BicubicFilterArithmetic) without it: the expectation now says so.
- runtime_lane::nan_moves and pack_conversions: clippy's manual_is_multiple_of under
`--cfg m2v_gpu`.
Gate on this branch (M3 Max, macOS 27.0.1, MoltenVK 1.4.2; Rust 1.98):
- cargo fmt --check; clippy --workspace --all-targets --all-features -D warnings, plain and with
RUSTFLAGS='--cfg m2v_gpu': clean.
- core nextest (metal2vulkan, air, runtime, devtools, --all-features): 5,003 run, 5,002 passed,
the one failure the engine_sampler expectation above (passes now).
- conformance nextest: 1,007 passed.
- the runtime's suite with --cfg m2v_gpu on MoltenVK: 1,495 passed, 3 skipped.
- 154 touched validation lanes on MoltenVK: 143 passed, 10 failed, 1 ignored; the 10 fail
identically at 68074019a3 (same messages and differing texels): color_fills plain,
extended_range_{planes,blends,targets x2,two_planes x3}, padded_loads' loading pass and
texture_fills (its 4:2:2 DecodedTexelPrecision predictor).
- api-signatures --check, conformance-coverage --check, the refusal surface: current.
- private intra-doc links: metal2vulkan 0, air 3, runtime 70, validation 0, conformance 0,
devtools 0; the public rustdoc with -D warnings: clean.
- validation's the_runtime_sources_are_the_committed_ones: passes with this pin.
(cherry picked from commit cd578f9cbc222eef0b8295fa7d3ff5acc8103529)
|
||
|
|
66d39ceb8e |
Regenerate the refusal surface for buffer_into_texture's sites
What: docs/REFUSALS.md regenerated (python3 scripts/refusal-surface/refusal_surface.py). Three refusals' sites (OverlappingSurfaceRows, MultisampledBufferCopy, Copy) now name blit_texture.rs's buffer_into_texture, where the previous commit moved copy_from_buffer_to_texture's body so a fill's row copies share it. Why: the generated surface names each refusal's building function; no refusal, RuntimeGap or basis changed (0 variants without a reach mark, 0 without a basis). (cherry picked from commit ead4b73a198ad597b502de5f20b246c64c9424c2) |
||
|
|
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) |
||
|
|
3e28f68331 |
Carve MoltenVK on the M3 Max's identity out of NativeNanEncoding for NaN moves
reims-vgpu treats precision notes as fatal on Apple GPUs; NativeNanEncoding was its largest group of Mac-only failures. Measured on the M3 Max (MoltenVK 1.4.2, macOS 27.0.1), the device's widening of a half to float, its narrowing back, and float fneg/fabs and half fabs answer Metal's NaN bits, so the note was recorded where nothing differs. What: a new DriverDeviation::MetalNanMoves (VkProperty::MetalNanMoves), taken by the APPLE9 MoltenVK row alone. Where taken: - a float fneg or fabs records no NativeNanEncoding and the module requires the property (SPIRV-Cross writes -x and abs(x), Metal's own operators on the same operand); - a half's widening to float (fpext, air.convert) and a half fabs, and a module's reads and encodes of a half's bits, record no note and require the property, but only where the module moves its halves through the registers as measured. narrow::moves_unfolded keeps the note where a widened half is stored anywhere but a buffer, workgroup memory or a function's float variable, passes through a call, return, group, atomic or image operation, has its bits read (a bitcast that is not stored, frexp/modf/ldexp: the frexp routines stay noted), or where the module holds a float NaN constant other than 0x7fc00000. - A half fneg stays noted on every profile: the measured shapes matched only because the driver's compiler moved the negation onto the half. By construction: MoltenVK's MSL writes float(as_type<half>(x)) and half(f); Metal's compiler folds half(float(h)) across selects, phis and a function's local float variable, so moved halves keep their bits as Metal's do. Verified (all runs on this M3 Max): - Plain Metal running the lane's own AIR (8 kernels; every one of the 65,536 half patterns, 98,368 float words including 65,536 structured NaNs) matches the lane's model in every word. - runtime_lane::nan_moves on MoltenVK: the note is absent from every kernel but the half fneg, and 0 lanes differ from Metal in all 8 kernels. - Earlier MSL probe, fast and precise math: the same equalities over 262,144 float words. - New core tests: half_moves_are_metals_only_where_the_device_folds_them (a payload NaN constant keeps the note), the frexp negative control in engine_metal_routines, float_sign_operations and the class C/D NaN tests with a moves argument, and the driver-facts lists. - Core nextest (metal2vulkan, air, runtime, devtools, --all-features): 4,989 passed. Docs: API.md (native-nan-encoding exemption), HOWTO.md, the PrecisionNote and deviation rustdoc. SEMANTICS_VERSION 1946, ARTIFACT_FORMAT_VERSION 483 (a new VkProperty in the codec); these bumps cover the rest of this branch. api_signatures blessed (two variants); the moltenvk-m3 profile's golden hash re-blessed. (cherry picked from commit 93ae66b6ddb46b4d0d3db1944a4b043c40911592) (Note on the development copy: this message names SEMANTICS_VERSION 1946; the commit sets 1948, after a rebase.) |
||
|
|
723191efb4 |
Pin the runtime sources for the video plumbing
The runtime's sources changed for the extra queues, the video feature structures, the shared event's caller signals, plane textures over the caller's VkImage and Buffer::vk_host_memory. RUNTIME_VERSION stays: each is a new opt-in surface, and a run that uses none of them (no extra queue asked, no listed video extension, no caller signal reserved, no plane texture, no host memory asked for) submits, answers, refuses and announces as before. Recomputed with pin-compute.py. (cherry picked from commit 51f7262b7a57a39a8df109626b2d3a39a8e79469) |
||
|
|
9613166920 |
Document the video plumbing; regenerate the refusal surface and the signatures table
- crates/metal2vulkan-runtime/README.md: the extra_queues option, the feature structures the
listed video extensions take, DeviceHandles' extra queues and the sharing rule for them, the
shared event's semaphore (signal-index counter, vk_wait, reserve_vk_signal), plane textures
over the consumer's VkImage and their refusal, and Buffer::vk_host_memory.
- docs/REFUSALS.md regenerated (python3 scripts/refusal-surface/refusal_surface.py) for
RuntimeGap::VkImagePlaneCopy and WrappedImageProblem::{Plane, PlaneFormat}; reach.tsv marks
the gap `none` (a runtime extension's path). 0 variants without a reach mark or a basis.
- crates/metal2vulkan/tests/api_signatures.tsv blessed: 28 added records (ExtraQueue,
VkEventWait, VkEventSignal, VkHostMemory, the new fields, methods and variants), none removed
or changed.
- The extra-queue device test prints the video features enabled through the runtime's own
query (listed_structures, listed_reported) and asserts each required one is on where its
extension is enabled.
docs/METAL-COVERAGE.md and docs/CONFORMANCE-COVERAGE.md check current.
(cherry picked from commit bb2a4c2c6101458026253461402ac463c1bcb323)
|
||
|
|
4329b26664 |
Answer where a no-copy buffer's bytes lie in the device's import of the caller's pages
Buffer::vk_host_memory (unsafe, Option) answers the VkDeviceMemory, the offset of byte 0 in it, the import's bytes from there, its memory type and its handle type (HOST_ALLOCATION_EXT) where the buffer's bytes are the caller's host pages in place in one allocation the device imported by their pointer: a no-copy buffer's, or a heap-over-host-memory buffer's, imported by pointer or bound in a guest RAM chunk's import. A VkBuffer of the caller's own (a video decode's bitstream source) binds there: the import is never a dedicated allocation. It is read apart as vk_buffer is (ReadApart::VkBuffer), which keeps a releasable import imported for good. None for everything whose memory is not one import of the pages themselves: buffers in the device's own memory or the caller's VkBuffer, copied host buffers (a copy synced only at the runtime's commits and completions), dma-buf imports (several sparsely bound allocations), read-only-view imports (Metal's private bit 24, writes dropped), detached buffers, and the stand-in of an import that could not be made again. The answer holds until a rebind or a detach. Byte 0 lies at the placement's offset plus the pages' offset in it (Device::pages_of's contract), which a heap's buffer adds its offset in the heap to. Test (device, m2v_gpu): a no-copy buffer over a pointer 256 bytes into a page answers offset 256 and an 80 KiB window less 256 on the M3 Max (MoltenVK); a VkBuffer made for host allocations bound there takes a raw vkCmdFillBuffer that the host reads in the pages from byte 0 over the length and nowhere else; a buffer of the device's own memory answers None. Verified: passes, and passes with no Khronos validation-layer message (probe run, not committed). Without the pages' offset (answering the placement's alone) it fails: offset 0, "the fill reached the pages from byte 0". (cherry picked from commit 16dfe5a626c903ef5c43d790da50be4c479b1de4) |
||
|
|
0dbfc43a5d |
Test the video plumbing on a device: extra queues, the event's semaphore, NV12 planes
Three device tests (compiled under m2v_gpu or m2v_cpu_icd), each printing what the device reported: - extra_queues_are_made_or_reported_and_the_video_features_enabled asks for a COMPUTE and a VIDEO_DECODE_KHR extra queue with the video extensions optional: each made queue belongs to a family containing its flags and takes an empty submission, each absent one is named in the metal2vulkan-extra-queues-absent message, the decode queue is made exactly where the device has a decode family, and videoMaintenance1 is enabled where its extension is. - a_raw_submission_is_ordered_by_a_shared_event_s_semaphore: a raw copy on the extra queue waits for a command buffer's encodeSignalEvent (value 10 is counter 1) and signals the counter reserve_vk_signal(20) gave (2, after 1), which releases a command buffer's encodeWaitForEvent for 20; the data flows fill -> raw copy -> blit copy, and the second command buffer has not completed before the raw signal. - a_texture_over_each_plane_of_an_nv12_image_reads_its_bytes: a G8_B8R8_2PLANE_420_UNORM image, CONCURRENT across the device's and the raw queue's families, MUTABLE_FORMAT|EXTENDED_USAGE, SAMPLED, filled per plane on the raw queue and left in GENERAL, read through R8Unorm and RG8Unorm plane textures by invert_texels; every texel matches the plane's bytes, and a blit copy of a plane is refused with RuntimeGap::VkImagePlaneCopy. The raw submissions use only the test's own buffers (wrapped with new_buffer_with_vk_buffer where Metal-side code uses them): the device's own objects are shared among its queue families alone, which the extra-queue docs now say. Verified on the M3 Max (MoltenVK): all three pass, and pass with no warning or error from the Khronos validation layer (a probe run with VK_LAYER_KHRONOS_validation enabled, not committed). (cherry picked from commit e04878dd38ecefd8db4822b2e7bbe20636030deb) |
||
|
|
4a33ffeee9 |
Make textures over a plane of the caller's multi-planar VkImage
Device::new_texture_with_vk_image_plane is newTextureWithDescriptor:iosurface:plane: over a Vulkan image's plane: a texture of the descriptor's format (R8Unorm or RG8Unorm for NV12's planes, R16Unorm or RG16Unorm for P010's) at the plane's extent, whose views name the plane's aspect. The caller makes and keeps the image (only it knows its video profile and picture buffer role): the runtime never moves its layout (it stays in GENERAL, which VK_KHR_unified_image_layouts lets serve video too), never takes queue family ownership, and never frees it, as for new_texture_with_vk_image. Barriers name the colour aspect, which Vulkan takes of a multi-planar image. plane_plan checks the image against the descriptor and the contract: a multi-planar format with that plane (the registry's plane table), a compatible format, the plane's extent, optimal tiling, MUTABLE_FORMAT and EXTENDED_USAGE, the shader usages, and sharing with the device's families. The runtime's copies name the colour aspect, which Vulkan refuses of a multi-planar image, so what would copy the plane is refused as a new gap, RuntimeGap::VkImagePlaneCopy: blit copies, fills and mipmap generation, a render pass that renders it, and usage and view shadows. Sampling and shader reads and writes, through its views, run. Verified: tests::wrapped::a_plane_of_a_multi_planar_image_is_planned_by_its_plane (NV12 and P010 planes, each refusal, the plane table against the format names) and the existing wrapped-image tests pass; clippy is clean. (cherry picked from commit 8ae428f79b9bc5888b9a21be11743b1297a8863e) |
||
|
|
9e0e3f854f |
Let the caller's submissions wait for and signal a shared event's values
A consumer that decodes video on its own queue orders that work against the runtime's command buffers' encodeWaitForEvent: and encodeSignalEvent: through the event's timeline semaphore (SharedEvent::vk_semaphore). Its counter is a signal index the runtime maps to Metal's values, not the value itself: Metal's value only rises by maximum and a host set takes effect at once, which a timeline semaphore cannot carry (VUID-VkSemaphoreSignalInfo-value-03258). So: - SharedEvent::vk_wait(value) answers the counter value a Metal value is (VkEventWait: Reached, Counter, or NotYet while no signal submitted, reserved or set reaches it); - SharedEvent::reserve_vk_signal(value) reserves the next index for the caller's signal under the scheduler's lock, so no batch takes it meanwhile (VkEventSignal: Counter with the index to signal and the one to wait for first, or Dropped where Metal's maximum makes it a no-op). No completion turn sees the caller's signal, so a per-device watcher thread waits for each reserved index on the host, in reservation order, and observes it as a completion turn does (EventTimeline::landed): the value rises, host waits wake, notifications post, the scheduler looks again. It never observes past a signal behind a copied host buffer's merge. Its thread starts at the first reservation and ends after a second with none left. vk_semaphore's contract now states the counter's meaning, no binary use, signals only as reserved, and the lifetime. Verified: tests::event_timeline::the_caller_s_signals_take_the_next_index_and_land_through_the_watcher and the eleven existing timeline tests pass; clippy is clean. (cherry picked from commit d00d0f8770f68e6c3d7556cb14d79146e04ae0f8) |
||
|
|
5671cdd6bd |
Make extra queues for the caller beside a created device's own
DeviceOptions::extra_queues asks a created device for queues of given flags (VIDEO_DECODE_KHR for a consumer that decodes video on the device, for example), one per entry, which DeviceHandles::extra_queues returns as ExtraQueue (the flags asked, the family, the VkQueue). The runtime never submits to them. Each takes a queue the device's own plan leaves free, of the first family whose flags contain the entry's and has one. Where none is free (MoltenVK's four families of one queue, all the device's own), the device gives up its last queue of such a family: a presenting reserve first, then the round robin's last, then the staging queue, never its first queue. A device with no queue for an entry is made all the same, and says so once in an informational message (metal2vulkan-extra-queues-absent). ash prints flags only with its debug feature, which stays off, so the flags print through a small formatter. Verified: tests::device::extra_queues_take_a_free_queue_else_one_the_device_gives_up covers NVIDIA's, MoltenVK's, a six-queue and lavapipe's family shapes, the staging fallback and the message; clippy is clean. (cherry picked from commit b18b4723daab3845e6ed9ad1517151123d5cc151) |
||
|
|
7883f78632 |
Enable the video maintenance and unified image layouts feature structures of listed extensions
A consumer that decodes video on the runtime's device lists VK_KHR_video_maintenance1, VK_KHR_video_maintenance2 and VK_KHR_unified_image_layouts. The runtime now knows their feature structures as it knows swapchainMaintenance1's: where the device lists one, the device enables videoMaintenance1, videoMaintenance2, or unifiedImageLayouts with unifiedImageLayoutsVideo. ash 0.38 has the first structure; the other two are laid out from the registry. Each known feature now says whether Vulkan requires it of every device listing the extension (the specification's feature requirements). unifiedImageLayoutsVideo is the first optional one: it is enabled where the device has it, and its absence neither refuses a listed extension nor leaves an optional one out. Verified: tests::enables::video_extensions_take_their_features_the_optional_one_where_the_device_has_it and the two existing listed-extension tests pass. (cherry picked from commit 4189380ad4db568d0df97f5c5dcbb60c76adcf55) |
||
|
|
f747833ca5 |
Pin the runtime sources after recording pixel centres' denormals per form
The note fix edits sources the runtime pin hashes: the sampler selection, PrecisionNote's documentation and SEMANTICS_VERSION. No run of an unchanged artifact and plan does anything else (the change moves which notes a new artifact records, and new artifacts carry SEMANTICS_VERSION 1947), so RUNTIME_VERSION stays at 1728 and the pin alone moves (pin-compute.py: 66c5f8bd...). Verified: the_runtime_sources_are_the_committed_ones passes against a build of this tree. (cherry picked from commit 68074019a34494346cb27673aeee32a4388a908e) |
||
|
|
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) |
||
|
|
35006080be |
Restore three sampler word tests a pixel-sampler commit dropped
888ad9bae9 ("Read a pixel-coordinate sample's texel as Metal's sampler
does") deleted a_sampler_word_answers_the_linear_predicate,
a_samplers_word_holds_metals_levels_on_its_grid and
a_samplers_clamp_is_the_descriptors from metal/sampler.rs through an
over-wide replacement; nothing in that change meant to remove them.
They come back as they were at its parent, with the linear-predicate
test's doc corrected to say what it checks.
Verified: the three tests pass (cargo nextest run -p metal2vulkan
--all-features -E 'test(a_sampler_word_answers_the_linear_predicate) |
test(a_samplers_word_holds_metals_levels_on_its_grid) |
test(a_samplers_clamp_is_the_descriptors)').
(cherry picked from commit 9fa628eab7994de0a4c69e24d7fa6e08bdd4abba)
|
||
|
|
a9e07b6bf4 |
Bump RUNTIME_VERSION to 1728 and pin the runtime sources for the placements outside the space
What: RUNTIME_VERSION 1722 -> 1728; the runtime-sources pin recomputed on this tree
(`pin-compute.py`, 99e3d83d...).
Why: a run of an unchanged artifact and plan now answers other addresses. The in-place check's
buffers, a device-made texture buffer's texels and a visible function table's words no longer take
ranges of the Metal space, so a program's `Any` buffers made after or beside them answer lower
`gpu_address`es, and a pin there that was refused `PlacementConflict::Held` is made. Bumping it
also renames the in-place check's record, so each host checks once more; its verdicts do not
depend on the placement.
Verified on the M3 Max (MoltenVK), on this tree:
- the runtime suite with `--cfg m2v_gpu`: 1487 passed; plain: 1194 passed;
- the validation lanes for texture buffers, function tables, pools, in-place textures, rebinds,
memoryless textures, swizzles, render arguments, chosen pointers and indirect executions: 177 of
178 passed. The one failure, `function_tables::tables_and_handles_answer_as_metal_s_do` (a
binary function's handle answers None), fails the same way on the base ed08da17f6;
- the two lane tests of c62deff2e3 fail with its two placements set back to `Any` ("out of Device
memory" for the texture buffer and the table made while the space is held);
- the consumer's repro: exit 1 in 5 of 5 runs on the base (a pin at 2^32 or 2^32 + 16 MiB refused
`Held` by the check's 40 MiB at 2^32), exit 0 in 5 of 5 runs on this tree (about 110,000 pins
made while the check ran, 78 to 82 ms; Pointer and Fresh passed, DmaBuf unchecked);
- `the_runtime_sources_are_the_committed_ones` passes against a build of this tree; clippy (all
features, plain and `--cfg m2v_gpu`) and `signatures.py --check` are clean.
(cherry picked from commit be8a19940bcd68c8700e499417e38f1a56b0e20f)
|
||
|
|
12aa3ba277 |
Place device-made texture buffers' texels and function tables' words outside the Metal space
What: a texture buffer the device makes (`newTextureWithDescriptor:`, `newSharedTextureWithDescriptor:`; `Device::new_texture_buffer`) lies over a buffer made by `new_buffer_placed` at `AddressPlacement::Outside`, otherwise as `new_buffer` makes it (kept among the program's resources, announced alike); a visible function table's words buffer is placed `Outside` instead of `Any`. address.rs's "Outside the space", the two modules' docs and the runtime README say so. Why: Metal shows no program an address of either. MTLTexture and MTLVisibleFunctionTable answer a `gpuResourceID` and no `gpuAddress`, and the runtime exposes neither buffer: no getter answers a device-made texture buffer's buffer, and a table's words are reached through its binding at a buffer index, its resource ID in an argument buffer (set 1's function-table array) or its words' Vulkan device address (`VisibleFunctionTable::listed`). A texture buffer's texels are read through texel views and the texture table by ID. Nothing reads either relative to the Metal space, so taking a range of it only moved the program's own `Any` buffers and could refuse its pins, unlike a texture of its own memory, which takes none. Heap texture buffers stay in their heap's range, which Metal exposes. Tests (validation lane, device): `texture_buffers_the_device_makes_lie_outside_the_metal_address_space` and `a_table_s_words_lie_outside_the_metal_address_space` hold the whole space with one address pool (`pool_slots::holding_the_space`, which checks that a buffer at `Any` is then refused `OutOfMemory` and one `Outside` is made), and make a plain and a shareable texture buffer (the CPU reads back what it wrote) and a function table (a kernel calls the functions it holds once the space is free again for the dispatch's output). Verified on the M3 Max (MoltenVK): both pass. (cherry picked from commit c62deff2e3504ef6d71cd8a49ae914adbbb572d5) |
||
|
|
cbd20364dd |
Place the in-place check's buffers outside the Metal address space
What: the device's in-place check (`in_place_check.rs`) makes its 40 MiB buffer per class of pages at `AddressPlacement::Outside`: the Fresh class through `Device::new_buffer_placed` (what `new_buffer` does, at a placement; `new_buffer` is it at `Any`), the Pointer and DmaBuf classes through `no_copy_kept`'s descriptor `with_placement(Outside)`. address.rs's "Outside the space" and the check's module docs say so. Why: the check runs on a thread of its own on a new RUNTIME_VERSION's first device per host, while the program makes its resources. At `Any` its buffers took the lowest free 40 MiB of the Metal space, from 2^32, so a program pinning there (`AddressPlacement::At`, `setPinnedGPUAddress:`) got `PlacementConflict::Held` for a range no object of its own held, breaking address.rs's rule that the runtime's own buffers lie in `[2^47, 2^48)`. The consumer's repro refused a pin at 2^32 in 5 runs of 5 on MoltenVK. The placement is the only thing that changes: the address space hands out a number, and the buffers' memory, fresh pages, import, image and first move do not read it (`placed_new_buffer`, `place_window`), so no verdict can. Test: `tests::in_place_check::the_in_place_check_takes_no_range_of_the_metal_space` (device test): with the space past its first GiB held by one address pool and a 16 KiB pin every 16 MiB of that GiB held through the check (no free run fits a check buffer), the check answers every class as a reference device's check over an empty space, and the pins between the held ones, made and released in turn while it runs, are all made. Without the fix it fails every time: Pointer and Fresh come back Unchecked (their buffers found no range). Verified on the M3 Max (MoltenVK): the test fails on the base (Pointer and Fresh Unchecked against Passed) and passes with the fix (Pointer Passed, Fresh Passed, DmaBuf Unchecked, as the reference; 4921 rounds of pins while the check ran). (cherry picked from commit 113c132f47b2f9c258c3a22251d949419a9f36e4) |
||
|
|
bd264821bf |
Regenerate REFUSALS.md for the draw-shape sites
The per-draw changes moved RenderState's scissor check from set_scissors to scissor_rects, and the cross-encoder shape memo's layout view now builds TileAtSampleCount too. refusal_surface.py --check passed with the old site lists (it does not compare them), so the table went stale. Regenerated with python3 scripts/refusal-surface/refusal_surface.py; the diff is the six site-list lines alone. (cherry picked from commit ed08da17f6ca8d1f7714f76e02053c8ae68d6583) |
||
|
|
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) |
||
|
|
18c507a4ea |
Pin the runtime sources after reading pixel samples' texels as Metal does
The pixel sampler change edits sources the runtime pin hashes: the binder's sampler descriptions and views (`bind/`), the sampler mapping, and a runtime doc comment. No run of an unchanged artifact and plan does anything else -- the unnormalized sampler, its level-0 view and the `NearestPixelSampler` constant appear only in artifacts the new translator makes, which carry the new `SEMANTICS_VERSION` and `ARTIFACT_FORMAT_VERSION` -- so `RUNTIME_VERSION` stays and the pin alone moves. Verified: `the_runtime_sources_are_the_committed_ones` passes against a build of this tree. (cherry picked from commit 70b7ca9f15c054fb074e8d0746cffbf1ec5f361f) |
||
|
|
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) |
||
|
|
6c294fe742 |
Pin the runtime sources after keeping the pass end's gathering lists
The commit before this one changes the runtime's sources but no run's answers, refusals, announcements or what it records and submits: a pass records the same commands and barriers from lists the device kept for it as from new ones (the per-draw repro's WorkCounts command counts are unchanged). So RUNTIME_VERSION stays, and only the runtime-sources pin moves. The translator's bind output is untouched, so SEMANTICS_VERSION stays. Verified: pin-compute over the tree, and the validation guard test the_runtime_sources_are_the_committed_ones passes; the runtime crate's suite passes (1194 tests) and, under --cfg m2v_gpu on MoltenVK (M3 Max), 1486 of 1486; the conformance suite (1007) passes; clippy (all features, plain and --cfg m2v_gpu) is clean; api-signatures --check is clean; the runtime's private intra-doc link diagnostics are 70, its ceiling. (cherry picked from commit b20c1e18e36d5d15df2063d9b27f447ff5d1bea9) |
||
|
|
1c909271db |
Keep a render encoder's gathering lists for the next pass, and move less at its end
A render pass's end freed what its draws gathered into, and the next
encoder's draws made it again: the first instance's shadowed textures and
buffer bytes (two BTreeMaps), its drawn rectangles and the pass's (two
BTreeSets), and the pass's fragment writes and reads (three key maps). It
also moved the 1.6 KB current instance with the encoder, collected each
tracked part's map into a vector before ordering its keys, looked heap
keys up under the heaps' lock with no live heap, worked out the
attachments' uses twice, and passed its end through the later color groups'
call with none.
Now:
- The device keeps up to 4 emptied draw rooms (render/draw_room.rs: the
first instance's InstanceShadows and DrawnArea, the pass's DrawnArea and
PassStartReads), each up to 64 entries; an encoder takes one as it opens
and its pass's end gives it back. A larger one goes.
- Those lists are sorted vectors that keep their room when cleared, in the
order the maps and sets they replace iterated, so the uses, ranges and
rectangles a pass end reads are the same.
- The current instance is boxed, so the encoder's moves at its end carry a
pointer; earlier instances (a split) stay unboxed.
- EncoderUses::finish_parts orders references to the tracked lists.
- HeapKeys::among returns at once on a device without a live heap.
- shadows::plan takes the attachments' uses end_pass worked out.
- Ended::later_groups runs only for a pass of several color groups.
The pass records the same commands and barriers, tracks the same uses and
holds the same objects; no notice, refusal or counter changes. Over the
repro's runs only scheduling counters moved, by at most 0.03 per command
buffer either way (batch-barrier command buffers, begun ahead, completion
arms, parked buffers).
Verified: unit tests a_room_given_back_is_taken_again_empty,
a_cleared_area_is_a_new_one_with_its_room,
written_ranges_keep_their_lists_when_cleared and
a_cleared_instance_gathers_into_the_room_it_kept (cleared lists keep their
room, and gather the same order as new ones); device test
pass_end_tiles::a_pass_takes_the_room_an_earlier_pass_left (four passes,
loaded, cleared and DontCare, make one room). With the pass end's give
taken out it fails (4 rooms made, not 1). The runtime suite passes
(1194), and the pass-end device tests pass on MoltenVK (M3 Max).
Release, the per-draw repro on the M3 Max over MoltenVK, 35 draws in 6
passes per command buffer, 5 interleaved rounds per configuration (flat
out 3000 command buffers, 60 Hz 1800), base 9f5776bf31, p50 medians:
end_encoding us draw us CPU per cb us
cache, flat out 5.67 -> 4.71 (-17%) 4.12 -> 4.17 223.5 -> 213.2
cache, 60 Hz 7.38 -> 6.62 (-10%) 4.92 -> 4.83 351.9 -> 341.7
pages, flat out 8.08 -> 7.71 (-5%) 4.12 -> 4.33 231.0 -> 247.3
pages, 60 Hz 10.83 -> 9.62 (-11%) 5.04 -> 5.04 420.5 -> 396.2
Per-round paired end_encoding ratios have medians of 0.82, 0.90, 0.91 and
0.92; draw p50 is unchanged (paired medians 0.99 to 1.03). CPU per buffer
moves within this host's run-to-run noise (paired medians 0.92 to 1.03),
so no change there is claimed.
(cherry picked from commit 1aaf95c79fdf479e2c15840cefe163713dd1cca9)
|
||
|
|
b46a52da5a |
Pin the runtime sources after carrying draw shapes across encoders
The commit before this one changes the runtime's sources but no run's answers, refusals, announcements or what it records and submits: a draw that takes a kept shape records the same commands its derived shape would (every WorkCounts command count of the per-draw repro is unchanged, and a debug build asserts the carried settings equal a fresh derivation). So RUNTIME_VERSION stays, and only the runtime-sources pin moves. The translator's bind output is untouched, so SEMANTICS_VERSION stays. Verified: pin-compute over the tree, and the validation guard test the_runtime_sources_are_the_committed_ones passes; the runtime crate's suite passes (1190 tests) and, under --cfg m2v_gpu on MoltenVK (M3 Max), 1481 of 1481; the conformance suite (1007) passes; api-signatures --check is clean. (cherry picked from commit 9f5776bf312807f5f2678c19a49469403f6dba0d) |
||
|
|
104ded7e34 |
Carry a draw's shape to a later encoder's first draw of the same values
A render encoder's shape memo finds a draw's settings, draw state and VkPipeline by the versions of the encoder's state and the instance's shape, which are new in every encoder. So each encoder's first draw of a pipeline state derived its shape again, though a frame encodes the same passes with the same state every time: 16 of the per-draw repro's 35 draws per command buffer. Each drawing state now keeps its last 8 shapes by value (KeptShapes, in render/draw_shape.rs): the assembly and primitives, the pass layout's facts (its pixel formats, depth and stencil, samples, extent and tile memory), and the encoder's state but its scissor rectangles and vertex amplification, floats by their bits and a depth-stencil state by the object the encoder holds. No key holds an address that can be reused. A draw that misses its encoder's memo takes the settings of a kept shape of equal values, with the draw state and VkPipeline a draw of it found once they are found; the VkPipeline still answers to the instance's compatible pass by version or value and to the pass's sample positions. A full table evicts the shape used longest ago. A rate-mapped pass, and a shape whose derivation announces a notice the device announces at every occurrence, keep nothing. What a shape reads of the pass layout goes through LayoutView, whose facts are the key, so a derivation cannot read a value the key misses; a debug build derives a carried draw's settings again and asserts they are equal. New counter WorkCounts::draw_shapes_carried (a public field: the api-signatures table gains it). draw_shapes_reused now counts a carried draw that also takes its draw state and VkPipeline; its doc says so. The conformance cost gate reports draw_shapes_carried beside draw_shapes_reused and bounds neither: a shape is kept by the same rule, which moves with the case selection. Verified: device test draw_shape_notices:: an_encoders_first_draw_takes_the_shape_of_the_same_values encodes two passes of the same values (the second's first draw is carried), then a changed cull mode and a changed target size (both miss), then the first values again (carried); it fails with 0 carried with the carry taken out, and with the encoder state left out of the key the debug assertion fires. The draw_shape_notices tests expect one more reused draw per pass. Runtime unit and device suites, conformance suite and clippy (plain and m2v_gpu) pass on MoltenVK (M3 Max). Release, the per-draw repro on the M3 Max over MoltenVK, flat out, 3000 command buffers, 10 interleaved rounds each: a draw with its setters p50 4.06 -> 3.90 us, mean 4.34 -> 4.15; the first draw of its state in its pass p50 4.81 -> 4.40 us; a later draw unchanged (3.54 -> 3.50); end_encoding unchanged (p50 4.92 -> 4.92); encoding thread CPU per command buffer p50 200.0 -> 193.8 us, mean 205.4 -> 198.4. Per buffer draw_shapes_carried is 16 and draw_shapes_reused goes from 13 to 25; every other WorkCounts field is unchanged. The repeated-state mode (one state, many draws) is unchanged within noise. (cherry picked from commit 192416101676532ddcc42527e38916574a0cc94b) |
||
|
|
8463a6e288 |
Pin the runtime sources after the per-draw changes
The two commits before this one change the runtime's sources but no run's answers, refusals, announcements or what it records and submits: the scissor rectangles moved beside the encoder state (each draw records its own scissor as before) and the hosted-key filter skips a lookup that answered nothing. So RUNTIME_VERSION stays, and only the runtime-sources pin moves. Verified: pin-compute.py over the tree; the runtime crate's suite passes (1189 tests) and, under --cfg m2v_gpu on MoltenVK (M3 Max), 1478 of 1478. (cherry picked from commit 521c5ee88e01e0921e8f2fe05d3503f7e02667f2) |
||
|
|
0ef00e80ed |
Tell keys of no host-pages buffer apart without the rebinds lock
While a device has a buffer over host pages (a no-copy buffer), every key an encoder's commands name first is held (rebind::Holds::hold): looked up among those buffers under Rebinds' lock, the lock a command buffer's first submission holds while it judges its holds. A compositor's draws each name a texture of their own, so each looked a texture's key up in turn, and waited on the scheduler thread's submission under the lock (__psynch_mutexwait under Holds::hold was about 1.4% of the draw call's samples on the M3). Rebinds now keeps a filter of the keys it registered (HostedKeys: 4096 bits by key, set as a no-copy buffer registers its key, before any command can name it, never cleared). A key whose bit is clear names no buffer over host pages, for a key is never another resource's: Holds::hold answers None for it without the lock. A set bit (a hosted key, a key sharing its bit, or a buffer gone since) is looked up as before. What is held is unchanged. New counter WorkCounts::host_holds_looked_up (a public field: the api-signatures table gains it; no consumer breaks) counts the lookups. Verified: device test host_hold_filter::only_hosted_keys_are_looked_up (a blit chaining 8 Private buffers after a copy from a no-copy buffer looks up 1 key; the bytes arrive) passes on MoltenVK (M3 Max), and fails with 10 lookups with the filter check removed. Release, the per-draw repro on the M3 Max over MoltenVK, flat out, cache mode: no WorkCounts field per buffer changes but the new one (host_holds_looked_up 6: the RAM buffer once per encoder). The draw timings are within this host's run-to-run noise (a draw p50 3.96 -> 4.00 us, mean 4.19 -> 4.22 in the quieter interleaved round); the lock's wait leaves the draw's profile. (cherry picked from commit d25c36c78c7059e155935cbdfb8ad1c333032a23) |