From ba11aec17624d9cf07c8282990b964ea10c185b3 Mon Sep 17 00:00:00 2001 From: DingusMcRinkyDinky <127614779+DingusMcRinkyDinky@users.noreply.github.com> Date: Fri, 6 Nov 2026 16:43:26 +0100 Subject: [PATCH] GPU tests: skip the instance stress test without Vulkan; keep the instance in new tests - The threading test makes Vulkan instances, so it is skipped when WGPU_BACKEND leaves Vulkan out: nothing is kept then, and that is how a broken driver is kept out of the tests. - The bounded readback tests from main get their device through NativeContext::request, which makes and drops an instance of its own; they now take the kept instance first, so the Vulkan loader isn't torn down when it goes. The shader cache stress test uses the kept one. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01EZbgszHyuEuWAzxaamteuU --- crates/gpu/tests/it/bounded_readback.rs | 3 +++ crates/gpu/tests/it/pipeline_errors.rs | 2 +- crates/testkit/src/gpu.rs | 7 ++++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/crates/gpu/tests/it/bounded_readback.rs b/crates/gpu/tests/it/bounded_readback.rs index c723a68c3f..8b99c78054 100644 --- a/crates/gpu/tests/it/bounded_readback.rs +++ b/crates/gpu/tests/it/bounded_readback.rs @@ -12,6 +12,9 @@ use crate::GPU_LOCK; fn test_gpu() -> Option<(NativeContext, Compositor, std::sync::MutexGuard<'static, ()>)> { let lock = GPU_LOCK.lock().unwrap_or_else(std::sync::PoisonError::into_inner); + // `NativeContext::request` makes and drops an instance of its own; the kept one keeps the + // Vulkan loader from being torn down when it goes. + let _kept = crate::instance(); let ctx = match NativeContext::request(&NativeContextOptions::default()) { Ok(c) => c, Err(e) => { diff --git a/crates/gpu/tests/it/pipeline_errors.rs b/crates/gpu/tests/it/pipeline_errors.rs index 724ad9fa9d..e4cd97c52b 100644 --- a/crates/gpu/tests/it/pipeline_errors.rs +++ b/crates/gpu/tests/it/pipeline_errors.rs @@ -67,7 +67,7 @@ fn parallel_compositor_builds_leave_the_shader_cache_intact() { let var = |name: &str, default: u32| std::env::var(name).ok().and_then(|v| v.parse::().ok()).filter(|&n| n > 0).unwrap_or(default); let (rounds, builds) = (var("PC_BUILD_ROUNDS", 4), var("PC_BUILDS_PER_DEVICE", 8)); for round in 0..rounds { - let instance = wgpu::Instance::new(wgpu::InstanceDescriptor::new_without_display_handle_from_env()); + let instance = crate::instance(); let Ok(adapter) = pollster::block_on(wgpu::util::initialize_adapter_from_env_or_default(&instance, None)) else { eprintln!("skipping: no adapter"); return; diff --git a/crates/testkit/src/gpu.rs b/crates/testkit/src/gpu.rs index e3113857dd..9fb7f918bb 100644 --- a/crates/testkit/src/gpu.rs +++ b/crates/testkit/src/gpu.rs @@ -63,11 +63,16 @@ mod tests { use super::*; /// Without the kept instance, creating and dropping instances on several threads segfaults in - /// libvulkan within a second, an abort no test can catch. + /// libvulkan within a second, an abort no test can catch. Skipped when `WGPU_BACKEND` leaves + /// Vulkan out: nothing is kept then, and that is how a broken driver is kept out of the tests. #[cfg(target_os = "linux")] #[test] fn instances_can_come_and_go_on_several_threads() { use wgpu::{Backends, Instance, InstanceDescriptor}; + if kept_backends(Backends::from_env()).is_none() { + eprintln!("skipping: WGPU_BACKEND leaves Vulkan out"); + return; + } drop(gpu_lock()); let threads: Vec<_> = (0..8) .map(|_| {