fix(bridge): age spare blocks inside an exit guard section

Bridge patch 0033. The room thread's timed pass frees the spare image blocks
whose time is up, a Vulkan call of a runtime thread outside any section of
the exit guard: the exit hook does not wait for it, and a bridge built with
debug assertions ends the process at the first such pass ("the runtime's
thread metal2vulkan-room reached the device outside an exit-guard section",
250 ms after the first room request). The pass now runs in a section, as the
requested pass does.

The build must list bridge patch 0033 after 0032 in
scripts/build-adreno-metal-bridge.py. Found and checked with a debug build
of the bridge on the host. Not run on hardware.
This commit is contained in:
rponeawa
2026-11-11 00:00:00 +08:00
Unverified
parent 7f6b40244e
commit d365f3aadd
@@ -0,0 +1,15 @@
diff --git a/crates/metal2vulkan-runtime/src/device/room.rs b/crates/metal2vulkan-runtime/src/device/room.rs
index e970e1da49c94da1ae6acc527a233aeb6ffa4ada..0bd3beae740946b54655fd6e28d229a10ae9d56e 100644
--- a/crates/metal2vulkan-runtime/src/device/room.rs
+++ b/crates/metal2vulkan-runtime/src/device/room.rs
@@ -123,7 +123,9 @@ fn run(shared: &Shared, weak: &WeakDevice) {
};
if requested {
keep(&device);
- } else {
+ } else if let Some(_busy) = exit_guard::enter() {
+ // In a section of the exit guard, as every Vulkan call of a thread of the runtime's is:
+ // a spare whose time is up is freed here.
let parts = device.shared();
crate::memory::age_spares(&parts.memory, parts.vk());
}