From 680d18df329729148dbefc1f0bdf05d7db2b7963 Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Sat, 7 Nov 2026 04:51:12 -0800 Subject: [PATCH] Rebind making-wait tests: wait for a held making until it is made, not 4.5 s after the commit tests::tile_rebind_making_wait::{a_rebind_does_not_make_a_tile_region_pipeline_on_the_programs_thread, a_rebind_does_not_wait_for_a_tile_making_another_encoder_began} failed once each late in a full runtime suite on lavapipe (homelab-um870-1, 6.5 s each), at "the command buffer completed though the making its pass records is held", and passed alone. Each leg commits its command buffer behind a host-signalled event first, then makes 33 further region keys to crowd the memo, then holds the pool, rebinds and signals: its pass records only after all that. The test device took the default PipelineWaitPolicy::Bounded, under which a recording whose making is still in flight past its command buffer's commit plus pipeline_commit_wait (4.5 s) drops the dispatch (DispatchDroppedStillMaking) and the command buffer completes: a loaded host that stretches the leg past 4.5 s from that commit completes it while the making is still held, as the runtime is meant to. Nothing in the failure was the runtime's ordering. blit_holds::exact_waits_device makes the device the cfg selects under PipelineWaitPolicy::Exact, whose recordings wait for a making until it is made, and both legs' devices of tile_rebind_making_wait and of its compute twin rebind_making_wait, which watches the same non-completion under the same hold, take it; the modules' docs say why. (cherry picked from commit 093c5484f22434806dd3461c5d08205ee08a5e01) --- .../src/tests/blit_holds.rs | 23 ++++++++++++++++--- .../src/tests/rebind_making_wait.rs | 16 ++++++++----- .../src/tests/tile_rebind_making_wait.rs | 13 +++++++---- 3 files changed, 38 insertions(+), 14 deletions(-) diff --git a/crates/metal2vulkan-runtime/src/tests/blit_holds.rs b/crates/metal2vulkan-runtime/src/tests/blit_holds.rs index 32adacec8..efdbf451a 100644 --- a/crates/metal2vulkan-runtime/src/tests/blit_holds.rs +++ b/crates/metal2vulkan-runtime/src/tests/blit_holds.rs @@ -23,6 +23,7 @@ use crate::{ Device, DeviceKind, DeviceOptions, Error, HostMemory, Origin, PurgeableState, ResourceOptions, ShaderCacheOptions, Size, Texture, TextureDescriptor, }; +use metal2vulkan::device::PipelineWaitPolicy; use metal2vulkan::metal::{PixelFormat, TextureType, TextureUsage}; use std::alloc::Layout; use std::path::{Path, PathBuf}; @@ -133,7 +134,24 @@ impl Drop for Host { /// The device the cfg selects: a CPU device under `m2v_cpu_icd`, else a GPU, its shader cache /// in `cache`. pub(super) fn device(cache: &Path) -> Device { - let options = DeviceOptions { + Device::system_default_with(&options(cache)).unwrap() +} + +/// As [`device`], its recordings waiting for a pipeline still being made until it is made +/// (`PipelineWaitPolicy::Exact`): for a test that holds a making in the device's pool and watches +/// the command buffer that awaits it not complete. Under the default `Bounded` wait, a recording +/// whose bound passed (its command buffer's commit plus `pipeline_commit_wait`, 4.5 s) drops the +/// draw or dispatch (`render/pending.rs`, `pending_dispatch.rs`) and its command buffer completes, +/// which a loaded host reaches while such a test still holds the making. +pub(super) fn exact_waits_device(cache: &Path) -> Device { + let mut options = options(cache); + options.policy.pipeline_waits = PipelineWaitPolicy::Exact; + Device::system_default_with(&options).unwrap() +} + +/// The options of [`device`]. +fn options(cache: &Path) -> DeviceOptions { + DeviceOptions { kinds: match cfg!(m2v_cpu_icd) { true => vec![DeviceKind::Cpu], false => vec![ @@ -147,8 +165,7 @@ pub(super) fn device(cache: &Path) -> Device { ..ShaderCacheOptions::default() }, ..DeviceOptions::default() - }; - Device::system_default_with(&options).unwrap() + } } /// A no-copy buffer over `host`, whose deallocator counts its runs in `runs`; `None`, printed, diff --git a/crates/metal2vulkan-runtime/src/tests/rebind_making_wait.rs b/crates/metal2vulkan-runtime/src/tests/rebind_making_wait.rs index 554fcd10a..755060978 100644 --- a/crates/metal2vulkan-runtime/src/tests/rebind_making_wait.rs +++ b/crates/metal2vulkan-runtime/src/tests/rebind_making_wait.rs @@ -28,11 +28,15 @@ //! over its four keep-alive configurations. //! //! A device test: compiled only under the validation crate's GPU safety cfgs (`m2v_gpu`, -//! `m2v_cpu_icd`), on the kind of device the cfg selects. The kernel is `scale_and_offset` of the -//! owned fixture `validation/fixtures/public/examples/runtime_examples.ll` -//! (`output[i] = input[i] * scale + i`), as `rebind_behind_a_wait.rs` runs it. +//! `m2v_cpu_icd`), on the kind of device the cfg selects, whose recordings wait for a making until +//! it is made (`PipelineWaitPolicy::Exact`, `blit_holds::exact_waits_device`): under the default +//! bound, a pass whose making is still held 4.5 s after its commit runs nothing and its command +//! buffer completes, which a loaded host reaches while a leg holds the making. The kernel is +//! `scale_and_offset` of the owned fixture +//! `validation/fixtures/public/examples/runtime_examples.ll` (`output[i] = input[i] * scale + i`), +//! as `rebind_behind_a_wait.rs` runs it. -use super::blit_holds::{device, Scratch, WAIT}; +use super::blit_holds::{exact_waits_device, Scratch, WAIT}; use super::dispatch_pending::state; use super::rebind_behind_a_wait::{dispatch, Page, BYTES, COUNT, SCALE}; use crate::pipeline::pool::held; @@ -65,7 +69,7 @@ fn leg(warm: Warm) { Warm::Made => "rebind-making-wait-made", Warm::Making => "rebind-making-wait-making", }); - let device: Device = device(&scratch.0); + let device: Device = exact_waits_device(&scratch.0); let state = state(&device); let queue = device.new_command_queue().unwrap(); let bytes: Vec = (0..COUNT).flat_map(|i| (i as f32).to_le_bytes()).collect(); @@ -224,7 +228,7 @@ fn a_dispatch_the_encoding_again_left_as_a_segment_records_once_its_making_lands // Declared before the device, so dropped after it. let pages = [Page::new(), Page::new()]; let scratch = Scratch::new("rebind-making-segment"); - let device: Device = device(&scratch.0); + let device: Device = exact_waits_device(&scratch.0); let state = state(&device); let queue = device.new_command_queue().unwrap(); let bytes: Vec = (0..COUNT).flat_map(|i| (i as f32).to_le_bytes()).collect(); diff --git a/crates/metal2vulkan-runtime/src/tests/tile_rebind_making_wait.rs b/crates/metal2vulkan-runtime/src/tests/tile_rebind_making_wait.rs index 014e3d1dc..07c740312 100644 --- a/crates/metal2vulkan-runtime/src/tests/tile_rebind_making_wait.rs +++ b/crates/metal2vulkan-runtime/src/tests/tile_rebind_making_wait.rs @@ -38,11 +38,14 @@ //! pages the dispatch was encoded over stay untouched. //! //! A device test: compiled only under the validation crate's GPU safety cfgs (`m2v_gpu`, -//! `m2v_cpu_icd`), on the kind of device the cfg selects. The tile function is the owned fixture -//! `validation/fixtures/public/engine/k10ts_tile_grid.ll`, as `tile_pending.rs` runs it, over one -//! 16x16 tile so that its records fit in one page ([`Page`]). +//! `m2v_cpu_icd`), on the kind of device the cfg selects, whose recordings wait for a making until +//! it is made (`PipelineWaitPolicy::Exact`, `blit_holds::exact_waits_device`): under the default +//! bound, a pass whose making is still held 4.5 s after its commit runs nothing and its command +//! buffer completes, which a loaded host reaches while a leg holds the making. The tile function is +//! the owned fixture `validation/fixtures/public/engine/k10ts_tile_grid.ll`, as `tile_pending.rs` +//! runs it, over one 16x16 tile so that its records fit in one page ([`Page`]). -use super::blit_holds::{device, over_host, Host, Scratch, WAIT}; +use super::blit_holds::{exact_waits_device, over_host, Host, Scratch, WAIT}; use super::layer_claim::Watched; use super::pending_rebind::device as watched_device; use super::rebind_behind_a_wait::{Page, BYTES}; @@ -227,7 +230,7 @@ fn leg(memo: Memo) { Memo::LetGo => "tile-rebind-memo-let-go", Memo::InFlight => "tile-rebind-memo-in-flight", }); - let device: Device = device(&scratch.0); + let device: Device = exact_waits_device(&scratch.0); let state = tile_state(&device); let colors = attachments(&device); let crowd_colors = attachments(&device);