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.
This commit is contained in:
Anees Iqbal committed 2026-11-14 22:32:27 -08:00
1 parent 86f02a00fa
commit 203bc97bb9
2 files changed
+9 -9

No files matched your search

+6 -6
View File
@@ -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<SlotRef> = 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<TwinKinds> {
#[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<T
(read && (kinds.storage || kinds.sampled)).then_some(kinds)
}
#[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))]
#[cfg(all(test, debug_assertions, any(m2v_gpu, m2v_cpu_icd)))]
thread_local! {
/// The uses and descriptor writes of plans this thread walked for facts of a plan alone
/// ([`binds_own_zeros`], [`TwinProofs`]), in the device tests that read it
@@ -435,7 +435,7 @@ thread_local! {
/// How many uses and descriptor writes of plans this thread walked so far for facts of a plan
/// alone ([`binds_own_zeros`], [`TwinProofs`]).
#[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))]
#[cfg(all(test, debug_assertions, any(m2v_gpu, m2v_cpu_icd)))]
pub(crate) fn plan_walks() -> 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!(
+3 -3
View File
@@ -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<ResourceKey>]) -> 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)
}