Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

Merge remote-tracking branch 'origin/main' into perf/gpui-camera-blur-and-loader

Richie McIlroyfef10dcc70b8
diff --cc apps/desktop-gpui/src/camera_blur_portable.rs
index 8c3857ca3,5143d6ce0..d8e2ca620
--- a/apps/desktop-gpui/src/camera_blur_portable.rs
+++ b/apps/desktop-gpui/src/camera_blur_portable.rs
@@@ -105,11 -80,15 +105,15 @@@ impl PortableCameraBlur
trace: wgpu::Trace::Off,
})
.await
- .map_err(|error| anyhow!("camera blur device: {error}"))
+ .map_err(|error| anyhow!("camera blur device: {error}"))?;
+ anyhow::Ok((format, device, queue))
})?;
- let mut processor = cap_camera_effects::BlurProcessor::new(&device, format)
- .context("camera blur processor")?;
+ device.push_error_scope(wgpu::ErrorFilter::Validation);
- let processor =
- cap_camera_effects::BlurProcessor::new(&device, wgpu::TextureFormat::Rgba8Unorm);
++ let processor = cap_camera_effects::BlurProcessor::new(&device, format);
+ if let Some(error) = runtime.block_on(device.pop_error_scope()) {
+ anyhow::bail!("camera blur GPU validation: {error}");
+ }
+ let mut processor = processor.context("camera blur processor")?;
processor.set_inference_interval(INFERENCE_INTERVAL);
Ok(Self {
@@@ -334,36 -298,19 +338,49 @@@ mod tests
);
}
+ fn test_frame(width: u32, height: u32, seed: u32) -> gpui::RenderImage {
+ let image = image::RgbaImage::from_fn(width, height, |x, y| {
+ let inside = (x + seed * 7) % width < width / 3 && (y + seed * 3) % height < height / 2;
+ image::Rgba([
+ (x * 255 / width) as u8,
+ (y * 255 / height) as u8,
+ if inside { 230 } else { (seed * 40) as u8 },
+ 255,
+ ])
+ });
+ gpui::RenderImage::new(smallvec::smallvec![image::Frame::new(image)])
+ }
+
+ fn deterministic_blur(allow_bgra: bool) -> Option<PortableCameraBlur> {
+ #[cfg(not(target_os = "macos"))]
+ if std::env::var_os("CAP_GPUI_TEST_PORTABLE_BLUR").is_none() {
+ return None;
+ }
+ match PortableCameraBlur::with_bgra(allow_bgra) {
+ Ok(mut blur) => {
+ blur.processor.set_frame_synchronous(true);
+ Some(blur)
+ }
+ Err(error) => {
+ eprintln!("skipping: portable camera blur unavailable: {error:#}");
+ None
+ }
+ }
+ }
+
+ #[test]
+ fn unsupported_gpu_returns_an_error_without_panicking() {
+ if std::env::var_os("CAP_GPUI_TEST_UNSUPPORTED_BLUR_GPU").is_none() {
+ return;
+ }
+
+ cap_camera_effects::initialize_onnx_runtime().expect("ONNX Runtime available");
+ let error = PortableCameraBlur::new()
+ .err()
+ .expect("unsupported GPU rejected");
+ assert!(error.to_string().contains("camera blur GPU validation"));
+ }
+
#[test]
fn portable_blur_processes_bgra_frames_without_changing_dimensions() {
#[cfg(not(target_os = "macos"))]