mirror of
https://github.com/storytold/photocraft.git
synced 2026-12-02 06:20:48 +01:00
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 <[email protected]> Claude-Session: https://claude.ai/code/session_01EZbgszHyuEuWAzxaamteuU
This commit is contained in:
1 parent
e532df3895
commit
ba11aec176
3 files changed
+10
-2
No files matched your search
@@ -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) => {
|
||||
|
||||
@@ -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::<u32>().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;
|
||||
|
||||
@@ -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(|_| {
|
||||
|
||||
Reference in new issue
Block a user