From 203bc97bb9d2edc65e3dc922d92992efb94ef3c4 Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Sat, 14 Nov 2026 22:32:27 -0800 Subject: [PATCH] Test counters of plan walks and twin-use checks: compiled only where their test is What: binding.rs's PLAN_WALKS and plan_walks, and encoder.rs's TWIN_USES_CHECKED and twin_uses_checked, with every increment of them, now take cfg(all(test, debug_assertions, any(m2v_gpu, m2v_cpu_icd))), as kept_resident_checks beside them does. Why: their one reader, tests::resident_uses, compiles only with debug_assertions, so a release test build under --cfg m2v_gpu or m2v_cpu_icd warned that plan_walks and twin_uses_checked are never used (seen in the dlrate lane's release lavapipe build, job m3-max-31435), which fails any release test build under -Dwarnings; debug clippy never sees it. Verified: see the lane's report (a release test build under -Dwarnings and debug clippy). Compiled in m3-max-31462 (msi: release lib test build under --cfg m2v_cpu_icd -Dwarnings; clippy --cfg m2v_gpu debug). Test-only cfg. --- crates/metal2vulkan-runtime/src/binding.rs | 12 ++++++------ crates/metal2vulkan-runtime/src/encoder.rs | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/crates/metal2vulkan-runtime/src/binding.rs b/crates/metal2vulkan-runtime/src/binding.rs index c609f7014..72a379974 100644 --- a/crates/metal2vulkan-runtime/src/binding.rs +++ b/crates/metal2vulkan-runtime/src/binding.rs @@ -301,7 +301,7 @@ impl TwinProofs { /// The slots of `plan` a command of it only reads, each once, in the order of its uses, as /// [`read_only_buffer_slot`] and [`read_only_slot`] prove them under `unproven`. fn proven(plan: &BindingPlan, unproven: bool) -> Vec<(SlotRef, Proven)> { - #[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))] + #[cfg(all(test, debug_assertions, any(m2v_gpu, m2v_cpu_icd)))] PLAN_WALKS.with(|walks| walks.set(walks.get() + plan.uses.len() as u64)); let mut seen: Vec = Vec::new(); let mut proven = Vec::new(); @@ -332,7 +332,7 @@ impl TwinProofs { /// uniform buffer, and every descriptor of the plan that names the slot is its buffer's, none of /// it a vertex buffer. fn read_only_buffer_slot(slot: SlotRef, plan: &BindingPlan, unproven: bool) -> bool { - #[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))] + #[cfg(all(test, debug_assertions, any(m2v_gpu, m2v_cpu_icd)))] PLAN_WALKS.with(|walks| { let walked = plan.uses.len() + plan.descriptors.len(); walks.set(walks.get() + walked as u64) @@ -373,7 +373,7 @@ fn read_only_buffer_slot(slot: SlotRef, plan: &BindingPlan, unproven: bool) -> b /// texture's or a combined image sampler's): the kinds of its bindings, a storage image's and a /// sampled one's ([`TwinKinds`]); else `None`. fn read_only_slot(slot: SlotRef, plan: &BindingPlan, unproven: bool) -> Option { - #[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))] + #[cfg(all(test, debug_assertions, any(m2v_gpu, m2v_cpu_icd)))] PLAN_WALKS.with(|walks| { let walked = plan.uses.len() + plan.descriptors.len(); walks.set(walks.get() + walked as u64) @@ -425,7 +425,7 @@ fn read_only_slot(slot: SlotRef, plan: &BindingPlan, unproven: bool) -> Option u64 { PLAN_WALKS.with(std::cell::Cell::get) } @@ -2652,7 +2652,7 @@ fn read_only_buffer(ty: vk::DescriptorType) -> bool { /// It walks every write of the plan, one for each resource its heap reaches in each heap array, /// so a draw asks its plan's facts (`render/plan_facts.rs`), which hold the answer. pub(super) fn binds_own_zeros(plan: &BindingPlan) -> bool { - #[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))] + #[cfg(all(test, debug_assertions, any(m2v_gpu, m2v_cpu_icd)))] PLAN_WALKS.with(|walks| walks.set(walks.get() + plan.descriptors.len() as u64)); plan.descriptors.iter().any(|write| { let neutral = matches!( diff --git a/crates/metal2vulkan-runtime/src/encoder.rs b/crates/metal2vulkan-runtime/src/encoder.rs index 932949c6e..598ee28bd 100644 --- a/crates/metal2vulkan-runtime/src/encoder.rs +++ b/crates/metal2vulkan-runtime/src/encoder.rs @@ -4280,12 +4280,12 @@ pub(super) fn count_shadow_copies(counts: &Counters, copies: &[ShadowCopy]) { /// Whether one of `uses` writes a read twin's key (`EncoderCore::refuses_twin_write`). fn writes_twin(uses: &[Use]) -> bool { - #[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))] + #[cfg(all(test, debug_assertions, any(m2v_gpu, m2v_cpu_icd)))] TWIN_USES_CHECKED.with(|checked| checked.set(checked.get() + uses.len() as u64)); (uses.iter()).any(|used| used.key.is_read_twin() && !used.write.is_empty()) } -#[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))] +#[cfg(all(test, debug_assertions, any(m2v_gpu, m2v_cpu_icd)))] thread_local! { /// The uses this thread's encoders checked for a write of a read twin ([`writes_twin`]), in /// the device tests that read it (`tests::resident_uses`). @@ -4293,7 +4293,7 @@ thread_local! { } /// How many uses this thread's encoders checked so far for a write of a read twin. -#[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))] +#[cfg(all(test, debug_assertions, any(m2v_gpu, m2v_cpu_icd)))] pub(crate) fn twin_uses_checked() -> u64 { TWIN_USES_CHECKED.with(std::cell::Cell::get) }