From d365f3aadd01797fe86984d83f191fa3ed658c21 Mon Sep 17 00:00:00 2001 From: rponeawa Date: Wed, 11 Nov 2026 00:00:00 +0800 Subject: [PATCH] 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. --- ...033-room-thread-ages-spares-in-a-section.patch | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 bridge/patches/0033-room-thread-ages-spares-in-a-section.patch diff --git a/bridge/patches/0033-room-thread-ages-spares-in-a-section.patch b/bridge/patches/0033-room-thread-ages-spares-in-a-section.patch new file mode 100644 index 0000000..27e6d5c --- /dev/null +++ b/bridge/patches/0033-room-thread-ages-spares-in-a-section.patch @@ -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()); + }