From 2c003dd6ac4bde876cd6c24cadc479ffcfa8e039 Mon Sep 17 00:00:00 2001 From: Kalmarv <59708937+Kalmarv@users.noreply.github.com> Date: Sat, 28 Nov 2026 16:24:24 -0500 Subject: [PATCH] Tests: serialise the pipeline tests that store into the library builder shaders::pipeline_library keeps one process-wide builder: while it is begun, every pipeline Pipelines::make* creates is stored into it (make_required -> pipeline_library::store). The library tests hold BUILD_TEST while they begin, store and finish, but three tests that make pipelines through Pipelines did not. When one of them ran beside builder_deduplicates_names_and_atomically_replaces_output, its pipelines landed in that test's library, and finish() counted 3 or 4 entries against the 2 the test stored (pipeline_library.rs:414). The panic poisoned BUILD_TEST, so the three tests waiting on it failed as well. On CI (WARP, --test-threads=4) this happened on main beeb81be, right after split_compute_program_prebuilds_and_caches_chain_pieces finished, and passed on the same tree in another run. stale_blob_cannot_bypass_the_offline_pipeline_cap, split_compute_program_prebuilds_and_caches_chain_pieces and pso_measurement_compiles_an_exact_synthetic_record now hold BUILD_TEST as well, and every BUILD_TEST holder takes the lock even when it is poisoned, so a test that panics while it holds it fails alone instead of failing every test queued behind it. Co-Authored-By: Claude Opus 5.5 --- crates/xcl/src/shaders.rs | 4 ++++ crates/xcl/src/shaders/pipeline_library.rs | 6 +++--- crates/xcl/src/shaders/warm_library.rs | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/crates/xcl/src/shaders.rs b/crates/xcl/src/shaders.rs index 427de54058..f0ab2a1d46 100644 --- a/crates/xcl/src/shaders.rs +++ b/crates/xcl/src/shaders.rs @@ -1947,6 +1947,8 @@ mod pipeline_cap_tests { fn stale_blob_cannot_bypass_the_offline_pipeline_cap() { use super::{Pipelines, recomp, Ordering}; use std::time::{Instant, SystemTime, UNIX_EPOCH}; + // Pipelines::make* stores into the process-wide library builder that the library tests begin. + let _serial = crate::shaders::pipeline_library::BUILD_TEST.lock().unwrap_or_else(|e| e.into_inner()); struct Scratch(std::path::PathBuf); impl Drop for Scratch { @@ -1992,6 +1994,7 @@ mod pipeline_cap_tests { use std::sync::Arc; use std::time::{SystemTime, UNIX_EPOCH}; use windows::Win32::Graphics::Direct3D12::*; + let _serial = crate::shaders::pipeline_library::BUILD_TEST.lock().unwrap_or_else(|e| e.into_inner()); struct Scratch(std::path::PathBuf); impl Drop for Scratch { @@ -4386,6 +4389,7 @@ mod tests { recomp::runner::skip_test(&e); return; } + let _serial = crate::shaders::pipeline_library::BUILD_TEST.lock().unwrap_or_else(|e| e.into_inner()); struct Temp(std::path::PathBuf); impl Drop for Temp { fn drop(&mut self) { diff --git a/crates/xcl/src/shaders/pipeline_library.rs b/crates/xcl/src/shaders/pipeline_library.rs index 470de7fde0..1defc75600 100644 --- a/crates/xcl/src/shaders/pipeline_library.rs +++ b/crates/xcl/src/shaders/pipeline_library.rs @@ -384,7 +384,7 @@ void main() {{ output.Store(0, {n}); }} #[test] fn builder_deduplicates_names_and_atomically_replaces_output() { - let _serial = BUILD_TEST.lock().unwrap(); + let _serial = BUILD_TEST.lock().unwrap_or_else(|e| e.into_inner()); let Some((pipelines, dxil, root)) = fixture() else { return }; let desc = compute_desc(&dxil, &root); let pso = unsafe { pipelines.dev.CreateComputePipelineState::(&desc) } @@ -426,7 +426,7 @@ void main() {{ output.Store(0, {n}); }} #[test] fn graphics_pipeline_round_trips_through_serialized_library() { - let _serial = BUILD_TEST.lock().unwrap(); + let _serial = BUILD_TEST.lock().unwrap_or_else(|e| e.into_inner()); let Some((pipelines, _, _)) = fixture() else { return }; let source = r#" #define RS "" @@ -490,7 +490,7 @@ struct V { float4 p : SV_Position; }; #[test] fn mesh_pipeline_round_trips_through_serialized_library() { - let _serial = BUILD_TEST.lock().unwrap(); + let _serial = BUILD_TEST.lock().unwrap_or_else(|e| e.into_inner()); let Some((pipelines, _, _)) = fixture() else { return }; let mut options = D3D12_FEATURE_DATA_D3D12_OPTIONS7::default(); if unsafe { diff --git a/crates/xcl/src/shaders/warm_library.rs b/crates/xcl/src/shaders/warm_library.rs index 56c5993de8..de51a59ff4 100644 --- a/crates/xcl/src/shaders/warm_library.rs +++ b/crates/xcl/src/shaders/warm_library.rs @@ -230,7 +230,7 @@ mod tests { ..Default::default() }; let pso = unsafe { pipelines.dev.CreateComputePipelineState::(&desc) }.unwrap(); - let _serial = super::super::pipeline_library::BUILD_TEST.lock().unwrap(); + let _serial = super::super::pipeline_library::BUILD_TEST.lock().unwrap_or_else(|e| e.into_inner()); super::super::pipeline_library::abort(); assert!(super::super::pipeline_library::begin(&pipelines.dev, None).unwrap()); super::super::pipeline_library::store("fixture.pso".into(), &pso).unwrap();