Files
metal2vulkan/crates/metal2vulkan-runtime/src/indirect_command_buffer
Anees Iqbal 7765813cb4 RUNTIME 2321: An indirect command buffer's home waits for its placing inside an exit-guard section
Home::drop waits on the host for the staging submission that placed the records in
device-local memory. The drop runs wherever the buffer's last hold lets go, and
that can be a command buffer's completion on its queue's waiter or a handler
thread. When the host had not seen the placing submission complete, the wait's
vkWaitSemaphores ran there outside any section. In debug builds exit_guard::check
ends the process at such a call: the XTX abort of
runtime_lane::resource_ids::an_indirect_command_buffer_s_id_is_held_as_metal_holds_it
at pin 94 (queue-wait-0, complete_rest's drop of the residency).

The wait now runs inside a section, as texture/staging_copy.rs's Flushed::drop
does. While the process exits no section starts: the drop returns without
waiting, and the records' buffer stays to the end, as release.rs leaves every
object then. exit_guard::check is unchanged. vkWaitSemaphores is already in the
sections' call table.

Verified: cargo fmt. The device runs of the previous commit's test are reported
with the landing.

Test: Device test: a command buffer's completion that lets go of an indirect command buffer last waits for its placing.
On a device that places indirect command buffer records in device-local memory, a
buffer the program lets go of while a command buffer that uses it is in flight goes
as that command buffer completes, on a queue's waiter or a handler thread. Its
home's drop then waits for the staging submission that placed the records. When the
host has not seen that submission complete, the wait calls vkWaitSemaphores, which
the exit guard requires to run inside a section on the runtime's threads.

The test holds the staging submissions on a test timeline
(Device::hold_staging_submissions), places a Private buffer's records through a
compute encoder's useResource, commits, lets go of the buffer, then signals the
timeline. The command buffer completes only after the placing submission, and
nothing waits for it on the host before the drop. A test-only count in Home::drop
(RUNTIME_PLACING_WAITS) records a wait for an unseen placing submission on a
runtime thread, so a pass on a placing device is not vacuous. A device that keeps
records in the host's memory says so and passes.

This commit has the test alone. On a placing device, without the section the next
commit adds, the drop's call ends the process (exit_guard::check): the XTX abort of
runtime_lane::resource_ids::an_indirect_command_buffer_s_id_is_held_as_metal_holds_it
at pin 94.

Why: on the RX 7900 XTX at pin 94 (m3-max-30428), runtime_lane::resource_ids::an_indirect_command_buffer_s_id_is_held_as_metal_holds_it
aborted in a debug build: "the runtime's thread metal2vulkan-queue-wait-0 reached the device outside an
exit-guard section". The queue waiter's completion dropped the last Arc of an indirect command buffer, and
Home::drop's wait for the staging submission that placed the records (vkWaitSemaphores) ran with no section.

Verified (lane devlegs, msi m3-max-30615): clippy -D warnings, runtime crate, plain and --cfg m2v_gpu 0;
the m2v_gpu archive at the fix built. Landed (main) at once: the 5080 negative control (test without the
fix aborts, with it passes) and the 3090 run follow on development.
RUNTIME 2321: an exiting process's last drop no longer waits for a placing it cannot guard.
2026-11-14 17:06:15 -08:00
..