Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

test: compare cursor failures without anisotropic filtering

Richie McIlroyeb7150ce8a9f
diff --git a/crates/rendering/src/layers/cursor.rs b/crates/rendering/src/layers/cursor.rs
index b59a4e910..362a4c20f 100644
--- a/crates/rendering/src/layers/cursor.rs
+++ b/crates/rendering/src/layers/cursor.rs
@@ -206,6 +206,17 @@ impl CursorLayer {
}
}
+ #[cfg(test)]
+ pub(crate) fn use_isotropic_sampler_for_test(&mut self, device: &wgpu::Device) {
+ self.statics.texture_sampler = device.create_sampler(&wgpu::SamplerDescriptor {
+ mag_filter: FilterMode::Linear,
+ min_filter: FilterMode::Linear,
+ mipmap_filter: FilterMode::Linear,
+ anisotropy_clamp: 1,
+ ..Default::default()
+ });
+ }
+
fn create_circle_cursor(constants: &RenderVideoConstants) -> CursorTexture {
let size = CIRCLE_CURSOR_SIZE;
let mut rgba = vec![0u8; (size * size * 4) as usize];
diff --git a/crates/rendering/src/lib.rs b/crates/rendering/src/lib.rs
index b41ceb2f9..2e62dcc47 100644
--- a/crates/rendering/src/lib.rs
+++ b/crates/rendering/src/lib.rs
@@ -7419,7 +7419,13 @@ mod project_uniforms_tests {
}];
}
let overlay = renderer
- .render_immediate(frames.clone(), overlay_uniforms, &events, true, &mut layers)
+ .render_immediate(
+ frames.clone(),
+ overlay_uniforms.clone(),
+ &events,
+ true,
+ &mut layers,
+ )
.await
.unwrap();
let overlay_selected = |pixel: &[u8], x: usize, y: usize| {
@@ -7458,8 +7464,8 @@ mod project_uniforms_tests {
}
let cursor_only = renderer
.render_immediate(
- cursor_only_frames,
- cursor_only_uniforms,
+ cursor_only_frames.clone(),
+ cursor_only_uniforms.clone(),
&events,
false,
&mut layers,
@@ -7481,6 +7487,36 @@ mod project_uniforms_tests {
pixel_selection_mask(&cursor_only, marker_center, |pixel, _, _| pixel[3]
> 12),
);
+ layers
+ .cursor
+ .use_isotropic_sampler_for_test(&constants.device);
+ let isotropic_overlay = renderer
+ .render_immediate(
+ frames.clone(),
+ overlay_uniforms,
+ &events,
+ true,
+ &mut layers,
+ )
+ .await
+ .unwrap();
+ let isotropic_cursor = renderer
+ .render_immediate(
+ cursor_only_frames,
+ cursor_only_uniforms,
+ &events,
+ false,
+ &mut layers,
+ )
+ .await
+ .unwrap();
+ let isotropic_overlay_center =
+ pixel_center(&isotropic_overlay, overlay_selected);
+ let isotropic_cursor_center =
+ pixel_center(&isotropic_cursor, |pixel, _, _| pixel[3] > 12);
+ eprintln!(
+ "isotropic {name}, ripple={ripple_only}: marker {marker_center:?}, overlay {isotropic_overlay_center:?}, cursor-only {isotropic_cursor_center:?}"
+ );
}
assert!(
(marker_center.x - overlay_center.x).abs() < 1.5