Files
metal2vulkan/crates/metal2vulkan-runtime/src/command_buffer
Anees Iqbal 44d97aaa5e Record each command into the driver's command buffer at the call
Recording at the call replaces the deferred replay, with the pipeline-wait test settling the
device's in-place check that recording at the call made fall inside its run.

One work packet, landed as 2 commits on archive/development-linear-2026-10-29, in order:

* Record each command into the driver's command buffer at the call (6c9d1f4551)

An encoder's command buffers are the driver's VkCommandBuffers from the command
buffer's pool, recorded at each call on the program's thread. The deferral is
gone: the per-command log, the deferred handles, the replays and the recorder
thread, the scheduler's wake of it, the host pages' replay holds, and
WorkCounts::{command_buffers_deferred, command_buffers_replayed,
command_buffers_replayed_inline} (removed public fields; none is read by the
consumer). The slots' routed entry points stay as a counting door:
WorkCounts::commands_replayed counts each command at the call, across every
command buffer (the scheduler's barrier buffers and primaries begun ahead
included, so its totals rise: the drag frame's 1000 -> 1094). A shadow's copy in
over dirty-logged host pages becomes a segment its batch's submission records
(Deferred::GatedCopyIn), so its regions are still decided after the commit's
dirty-log stamp. Rebind re-encode (replay.rs, reencode.rs) is unchanged.
RUNTIME_VERSION 1692.

Verified on the Apple M3 Max (MoltenVK): runtime device suite 1392/1393 twice
(pipeline_wait_order's "a batch waiting for a pipeline holds only the batches
that share its resources" fails under suite load only, a known load flake that
now fails more often; 3/3 alone; the base passed 1395/1395 under the same
load); new recorded_at_the_call::a_fill_is_recorded_at_its_call; the three
dirty_pages_device tests through the gated segment; plain runtime 1145/1145;
conformance plain 1007/1007 (its racy-count test now reads wakes_spared and
command_buffers_submitted); clippy plain and --cfg m2v_gpu; rustdoc.
Release A/B on the M3 (5 interleaved pairs, host load 16-43): drag frame
commit-to-handler p50 3.416 -> 3.386 ms back to back, 4.185 -> 3.671 ms paced
at 60 Hz; encode per draw +7.9% back to back, +15.7% paced (the recording moved
onto the program's thread). Not run: the validation plain suite, the
validation lanes edited, lavapipe; conformance's MoltenVK cost records hold
begin/end/barrier bounds from the narrower count and need re-recording.

* Settle the device's in-place check before the pipeline-wait test frees its no-copy buffer (40c79d69e6)

The test's texture over a no-copy buffer starts the device's check of images
over host pages, whose rounds make internal submissions on the
m2v-in-place-check thread. On MoltenVK freed memory waits for every device-own
submission issued before it went (freed_memory.rs), so a check submission in
flight as the test drops the buffer delays its deallocator
(host_deallocators_delayed 1). That wait is the runtime's documented behaviour;
the unrelated batch holds no reference to the buffer (a temporary backtrace on
the device's internal submissions showed every one from the check thread, none
from barrier buffers, primaries begun ahead or gated copy segments). The test
assumed no other device work was in flight, and recording at the call made the
test about 2.5x faster, so the release fell inside the check's run. The test
now calls settle_in_place_checks (a condition-variable wait, no sleep) before
its work.

Verified on the Apple M3 Max (MoltenVK): with three heavy device tests beside
it, 10/10 pass (5/10 without the settle, each "the deallocator waited for the
import"); alone 5/5; the runtime device suite 1393/1393. Also run there, all
passing: the validation lane device tests record at the call edited
(commands_replayed, detach, hidden_depth, clear_reach, rate_mapped_passes,
frame_costs, and the row_copies/frame_costs_plain measurements).
2026-10-29 15:43:49 +02:00
..