PhotoCraft: An open-source, photo editor written by scratch in pure Rust
camera_raw_scope: serialise the GPU tests with GPU_LOCK (#1856)
Sir Starchd8d2df4fbafb
diff --git a/crates/ui-egui/tests/camera_raw_scope.rs b/crates/ui-egui/tests/camera_raw_scope.rsindex 96def95fc..d96c813b2 100644--- a/crates/ui-egui/tests/camera_raw_scope.rs+++ b/crates/ui-egui/tests/camera_raw_scope.rs@@ -4,6 +4,16 @@ use egui_kittest::{Harness, kittest::Queryable};use photocraft_ui_egui::{PhotocraftApp, camera_raw_ui, control, theme::ThemeKind};use serde_json::{Value, json};+/// Concurrent wgpu instances in one process crash on some drivers (see `canvas_16f.rs`). With the+/// NVIDIA and lavapipe Vulkan drivers both installed, `wgpu::Instance::new` on several test+/// threads segfaults inside libvulkan, so every test that builds a GPU harness holds this lock for+/// its whole run, harness included.+static GPU_LOCK: std::sync::Mutex<()> = std::sync::Mutex::new(());++fn gpu_lock() -> std::sync::MutexGuard<'static, ()> {+ GPU_LOCK.lock().unwrap_or_else(std::sync::PoisonError::into_inner)+}+fn menu(app: &mut PhotocraftApp, ctx: &egui::Context, p: Value) -> Result<Value, String> {camera_raw_ui::menu(app, ctx, "filter.cameraRaw", &p).ok_or("missing handler")?}@@ -406,6 +416,7 @@ fn alt_tone_diagnostics_and_double_click_reset_follow_the_same_proxy_revision()#[test]fn both_clipping_warnings_leave_unclipped_preview_pixels_visible_on_gpu() {+ let _gpu = gpu_lock();let mut h = Harness::builder().with_step_dt(1.0 / 60.0).with_size(vec2(800.0, 600.0)).wgpu().build_eframe(|cc| {PhotocraftApp::setup_context(&cc.egui_ctx, ThemeKind::Pro);let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), Default::default());@@ -573,6 +584,7 @@ fn curve_deletion_reentry_keyboard_limits_and_controller_replacement_share_captu#[test]fn curve_gpu_paints_the_moved_handle_in_every_theme() {+ let _gpu = gpu_lock();for theme in ThemeKind::ALL {let mut h = fixture_render(theme, true);let graph = open_curve(&mut h);@@ -644,6 +656,7 @@ fn pixel_hover_tracks_displayed_rgb_before_after_and_keeps_analysis_cached() {#[test]fn pixel_hover_gpu_badge_single_band_and_crosshair_appear_and_clear_in_all_themes() {+ let _gpu = gpu_lock();for theme in ThemeKind::ALL {let mut h = fixture_render(theme, true);let ctx = h.ctx.clone();