Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add regression test for watertightness #698

Merged
merged 3 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions vello_tests/snapshots/rounded_rectangle_watertight.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 5 additions & 3 deletions vello_tests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use vello::wgpu::{
self, BufferDescriptor, BufferUsages, CommandEncoderDescriptor, Extent3d, ImageCopyBuffer,
TextureDescriptor, TextureFormat, TextureUsages,
};
use vello::{block_on_wgpu, util::RenderContext, RendererOptions, Scene};
use vello::{block_on_wgpu, util::RenderContext, AaConfig, RendererOptions, Scene};

mod compare;
mod snapshot;
Expand All @@ -32,6 +32,7 @@ pub struct TestParams {
pub base_colour: Option<Color>,
pub use_cpu: bool,
pub name: String,
pub anti_aliasing: AaConfig,
}

impl TestParams {
Expand All @@ -42,6 +43,7 @@ impl TestParams {
base_colour: None,
use_cpu: false,
name: name.into(),
anti_aliasing: AaConfig::Area,
}
}
}
Expand Down Expand Up @@ -87,7 +89,7 @@ pub async fn get_scene_image(params: &TestParams, scene: &Scene) -> Result<Image
surface_format: None,
use_cpu: params.use_cpu,
num_init_threads: NonZeroUsize::new(1),
antialiasing_support: vello::AaSupport::area_only(),
antialiasing_support: std::iter::once(params.anti_aliasing).collect(),
},
)
.or_else(|_| bail!("Got non-Send/Sync error from creating renderer"))?;
Expand All @@ -97,7 +99,7 @@ pub async fn get_scene_image(params: &TestParams, scene: &Scene) -> Result<Image
base_color: params.base_colour.unwrap_or(Color::BLACK),
width,
height,
antialiasing_method: vello::AaConfig::Area,
antialiasing_method: params.anti_aliasing,
debug: vello::DebugLayers::none(),
};
let size = Extent3d {
Expand Down
23 changes: 23 additions & 0 deletions vello_tests/tests/regression.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright 2024 the Vello Authors
// SPDX-License-Identifier: Apache-2.0 OR MIT

use vello::{
kurbo::{Affine, RoundedRect, Stroke},
peniko::Color,
AaConfig, Scene,
};
use vello_tests::{snapshot_test_sync, TestParams};

#[test]
#[cfg_attr(skip_gpu_tests, ignore)]
fn rounded_rectangle_watertight() {
let mut scene = Scene::new();
let rect = RoundedRect::new(60.0, 10.0, 80.0, 30.0, 10.0);
let stroke = Stroke::new(2.0);
scene.stroke(&stroke, Affine::IDENTITY, Color::WHITE, None, &rect);
let mut params = TestParams::new("rounded_rectangle_watertight", 70, 30);
params.anti_aliasing = AaConfig::Msaa16;
snapshot_test_sync(scene, &params)
.unwrap()
.assert_mean_less_than(0.001);
}