Skip to content
Open
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
22 changes: 18 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ env:
# List of packages that can not target Wasm.
# `vello_research_tests` uses `nv-flip`, which doesn't support Wasm.
NO_WASM_PKGS: "--exclude vello_research_tests --exclude xtask"
# See https://github.com/linebender/vello/pull/1958, this value needs to be
# large enough so no single test run exceeds it.
# Keep in sync with the 1200s timeout in `vello_tests/webdriver.json`.
WASM_BINDGEN_TEST_TIMEOUT: "1200"
# The files stored in LFS the tests need to access, in JSON format
LFS_FILES: '["research/vello_research_tests/snapshots/*.png", "vello_tests/snapshots/*.png"]'

Expand Down Expand Up @@ -348,6 +352,14 @@ jobs:
# However, if we do, the tests are designed to be robust against that, if this environment variable is set.
# If we do run out of bandwidth, uncomment the following line and inform @DJMcNab.
# VELLO_SKIP_LFS_SNAPSHOTS: all

- name: run shader compilation tests
if: matrix.os == 'ubuntu-latest'

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Running this on Ubuntu on purpose instead of MacOS, as MacOS runs the whole workspace with all-feature, and that requires unnecessarily recompiling a lot of dependencies because the enabled features change.

run: bash vello_tests/feature_tests/run.sh --features wgpu --release
env:
CARGO_PROFILE_RELEASE_DEBUG_ASSERTIONS: "true"
RUSTFLAGS: ${{ matrix.rustflags }}
VELLO_CI_GPU_SUPPORT: ${{ matrix.gpu }}

- name: Upload test results due to failure
uses: actions/upload-artifact@v4
Expand Down Expand Up @@ -473,10 +485,12 @@ jobs:
working-directory: vello_tests
env:
RUSTFLAGS: ${{ matrix.rustflags }}
# See https://github.com/linebender/vello/pull/1958, this value needs to be
# large enough so no single test run exceeds it.
# Keep in sync with the 1200s timeout in `webdriver.json.
WASM_BINDGEN_TEST_TIMEOUT: "1200"

- name: run shader compilation tests
run: bash vello_tests/feature_tests/run.sh --mode no-install --headless --chrome --features webgl --release
env:
RUSTFLAGS: ${{ matrix.rustflags }}
WASM_BINDGEN_TEST_WEBDRIVER_JSON: ${{ github.workspace }}/vello_tests/webdriver.json

check-stable-wasm-webgl-examples:
name: cargo check (wasm32 webgl examples)
Expand Down
31 changes: 28 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ members = [
"vello_gpu_shaders",
"vello_toy",
"vello_tests",
"vello_tests/feature_tests",
"vello_tests/test_support",
"vello_tests/vello_dev_macros",
"vello_tests/vello_example_scenes",
"glifo",
Expand Down Expand Up @@ -139,10 +141,11 @@ web-sys = "0.3.92"
vello_common = { version = "0.3.0", path = "vello_common", default-features = false }
vello_cpu = { version = "0.3.0", path = "vello_cpu" }
vello_gpu = { version = "0.3.0", path = "vello_gpu", default-features = false }
vello_gpu_shaders = { version = "0.3.0", path = "vello_gpu_shaders" }
vello_gpu_shaders = { version = "0.3.0", path = "vello_gpu_shaders", default-features = false }
glifo = { version = "0.4.0", path = "glifo", default-features = false }
vello_example_scenes = { path = "vello_tests/vello_example_scenes" }
vello_dev_macros = { path = "vello_tests/vello_dev_macros" }
vello_test_support = { path = "vello_tests/test_support" }

# NOTE: The wgpu and naga versions should be kept in sync, and make sure to keep this
# in sync with the version badge in README.md and research/vello_research/README.md
Expand Down
26 changes: 18 additions & 8 deletions fuzz/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added vello_common/assets/probe_blurred_rounded_rect.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions vello_common/assets/probe_blurred_rounded_rect.rgba
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿúøüÿëåòÿåÜíÿåÜíÿåÜíÿåÜíÿëåòÿúøüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿúøüÿʸÛÿi´ÿ€V«ÿ€V«ÿ€V«ÿ€V«ÿi´ÿʸÛÿúøüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿëåòÿi´ÿh6›ÿf3™ÿf3™ÿf3™ÿf3™ÿh6›ÿi´ÿëåòÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿåÜíÿ€V«ÿf3™ÿf3™ÿf3™ÿf3™ÿf3™ÿf3™ÿ€V«ÿåÜíÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿåÜíÿ€V«ÿf3™ÿf3™ÿf3™ÿf3™ÿf3™ÿf3™ÿ€V«ÿåÜíÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿåÜíÿ€V«ÿf3™ÿf3™ÿf3™ÿf3™ÿf3™ÿf3™ÿ€V«ÿåÜíÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿåÜíÿ€V«ÿf3™ÿf3™ÿf3™ÿf3™ÿf3™ÿf3™ÿ€V«ÿåÜíÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿëåòÿi´ÿh6›ÿf3™ÿf3™ÿf3™ÿf3™ÿh6›ÿi´ÿëåòÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿúøüÿʸÛÿi´ÿ€V«ÿ€V«ÿ€V«ÿ€V«ÿi´ÿʸÛÿúøüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿúøüÿëåòÿåÜíÿåÜíÿåÜíÿåÜíÿëåòÿúøüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
Binary file added vello_common/assets/probe_drop_shadow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added vello_common/assets/probe_drop_shadow.rgba
Binary file not shown.
Binary file added vello_common/assets/probe_image_bicubic.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added vello_common/assets/probe_image_bicubic.rgba
Binary file not shown.
Binary file added vello_common/assets/probe_radial_gradient.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added vello_common/assets/probe_radial_gradient.rgba
Binary file not shown.
Binary file added vello_common/assets/probe_sweep_gradient.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added vello_common/assets/probe_sweep_gradient.rgba
Binary file not shown.
85 changes: 79 additions & 6 deletions vello_common/src/probe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::color::{AlphaColor, palette::css};
use crate::filter_effects::{EdgeMode, Filter, FilterPrimitive};
#[cfg(not(feature = "std"))]
use crate::kurbo::common::FloatFuncs as _;
use crate::kurbo::{Affine, BezPath, Circle, Point, Rect, Shape};
use crate::kurbo::{Affine, BezPath, Circle, Point, Rect, Shape, Vec2};
use crate::paint::{Image, ImageSource, PaintType};
use crate::peniko::{
BlendMode, ColorStop, ColorStops, Compose, Extend, Gradient, ImageAlphaType, ImageQuality,
Expand All @@ -35,14 +35,19 @@ const PATH_TOLERANCE: f64 = 0.1;
pub const ALL_PROBE_ELEMENTS: &[ProbeFeature] = &[
ProbeFeature::SolidRect,
ProbeFeature::AlphaBlending,
ProbeFeature::Gradient,
ProbeFeature::LinearGradient,
ProbeFeature::ImageNearest,
ProbeFeature::Filter,
ProbeFeature::ImageBilinear,
ProbeFeature::OpacityLayer,
ProbeFeature::Blending,
ProbeFeature::Transformed,
ProbeFeature::DepthBuffer,
ProbeFeature::DropShadow,
ProbeFeature::BlurredRoundedRect,
ProbeFeature::RadialGradient,
ProbeFeature::SweepGradient,
ProbeFeature::ImageBicubic,
];

/// Per-channel absolute tolerance used when comparing probe pixels.
Expand Down Expand Up @@ -76,7 +81,7 @@ pub enum ProbeFeature {
/// Alpha blending overlapping shapes.
AlphaBlending,
/// Drawing a linear gradient.
Gradient,
LinearGradient,
/// Drawing an image with nearest-neighbor sampling.
ImageNearest,
/// Applying a filter effect.
Expand All @@ -91,6 +96,16 @@ pub enum ProbeFeature {
Transformed,
/// Layering opaque draws and a transparent foreground to exercise depth buffering.
DepthBuffer,
/// Applying an offset, blurred drop shadow to a shape.
DropShadow,
/// Drawing a blurred rounded rectangle.
BlurredRoundedRect,
/// Drawing a radial gradient.
RadialGradient,
/// Drawing a sweep gradient.
SweepGradient,
/// Drawing an image with bicubic sampling.
ImageBicubic,
}

/// Summary of the differences between one expected and actual probe cell.
Expand Down Expand Up @@ -180,6 +195,7 @@ pub trait ProbeRenderer {
fn set_paint(&mut self, paint: PaintType);
fn fill_path(&mut self, path: &BezPath);
fn fill_rect(&mut self, rect: &Rect);
fn fill_blurred_rounded_rect(&mut self, rect: &Rect, radius: f32, std_dev: f32, invert: bool);
fn push_layer(&mut self, blend_mode: Option<BlendMode>, opacity: Option<f32>);
fn push_filter_layer(&mut self, filter: Filter);
fn pop_layer(&mut self);
Expand Down Expand Up @@ -229,14 +245,21 @@ fn reference_data(feature: ProbeFeature) -> &'static [u8; CELL_DATA_LEN] {
match feature {
ProbeFeature::SolidRect => include_bytes!("../assets/probe_solid_rect.rgba"),
ProbeFeature::AlphaBlending => include_bytes!("../assets/probe_alpha_blending.rgba"),
ProbeFeature::Gradient => include_bytes!("../assets/probe_gradient.rgba"),
ProbeFeature::LinearGradient => include_bytes!("../assets/probe_linear_gradient.rgba"),
ProbeFeature::ImageNearest => include_bytes!("../assets/probe_image_nearest.rgba"),
ProbeFeature::Filter => include_bytes!("../assets/probe_filter.rgba"),
ProbeFeature::ImageBilinear => include_bytes!("../assets/probe_image_bilinear.rgba"),
ProbeFeature::OpacityLayer => include_bytes!("../assets/probe_opacity_layer.rgba"),
ProbeFeature::Blending => include_bytes!("../assets/probe_blending.rgba"),
ProbeFeature::Transformed => include_bytes!("../assets/probe_transformed.rgba"),
ProbeFeature::DepthBuffer => include_bytes!("../assets/probe_depth_buffer.rgba"),
ProbeFeature::DropShadow => include_bytes!("../assets/probe_drop_shadow.rgba"),
ProbeFeature::BlurredRoundedRect => {
include_bytes!("../assets/probe_blurred_rounded_rect.rgba")
}
ProbeFeature::RadialGradient => include_bytes!("../assets/probe_radial_gradient.rgba"),
ProbeFeature::SweepGradient => include_bytes!("../assets/probe_sweep_gradient.rgba"),
ProbeFeature::ImageBicubic => include_bytes!("../assets/probe_image_bicubic.rgba"),
}
}

Expand Down Expand Up @@ -327,7 +350,8 @@ fn image_paint(image: ImageSource, quality: ImageQuality) -> PaintType {
pub fn draw_scene<T: ProbeRenderer>(ctx: &mut T, image: ImageSource, elements: &[ProbeFeature]) {
let layout = GridLayout::from_elements(elements);
let image_nearest = image_paint(image.clone(), ImageQuality::Low);
let image_bilinear = image_paint(image, ImageQuality::Medium);
let image_bilinear = image_paint(image.clone(), ImageQuality::Medium);
let image_bicubic = image_paint(image, ImageQuality::High);
ctx.set_transform(Affine::IDENTITY);

for (index, element) in elements.iter().copied().enumerate() {
Expand All @@ -337,6 +361,7 @@ pub fn draw_scene<T: ProbeRenderer>(ctx: &mut T, image: ImageSource, elements: &
element,
&image_nearest,
&image_bilinear,
&image_bicubic,
);
}
}
Expand All @@ -347,6 +372,7 @@ fn draw_probe_element(
element: ProbeFeature,
image_nearest: &PaintType,
image_bilinear: &PaintType,
image_bicubic: &PaintType,
) {
match element {
ProbeFeature::SolidRect => {
Expand Down Expand Up @@ -376,7 +402,7 @@ fn draw_probe_element(
.to_path(PATH_TOLERANCE),
);
}
ProbeFeature::Gradient => {
ProbeFeature::LinearGradient => {
let rect = centered_rect(cell, RECT_SIZE, RECT_SIZE);
ctx.set_paint(linear_gradient(&rect).into());
ctx.fill_rect(&rect);
Expand All @@ -391,6 +417,35 @@ fn draw_probe_element(
}
ProbeFeature::Blending => draw_layered_difference_circles(ctx, cell),
ProbeFeature::DepthBuffer => draw_depth_buffer_rects(ctx, cell),
ProbeFeature::DropShadow => draw_drop_shadow_rect(ctx, cell),
ProbeFeature::BlurredRoundedRect => {
ctx.set_paint(css::REBECCA_PURPLE.into());
ctx.fill_blurred_rounded_rect(&centered_rect(cell, 8.0, 8.0), 2.0, 0.75, false);
}
ProbeFeature::RadialGradient => {
let rect = centered_rect(cell, RECT_SIZE, RECT_SIZE);
let gradient = Gradient::new_radial(rect.center(), (RECT_SIZE * 0.5) as f32)
.with_stops([css::BLUE, css::RED]);
ctx.set_paint(gradient.into());
ctx.fill_rect(&rect);
}
ProbeFeature::SweepGradient => {
let rect = centered_rect(cell, RECT_SIZE, RECT_SIZE);
let gradient = Gradient::new_sweep(rect.center(), 0.0, core::f32::consts::TAU)
.with_stops([css::BLUE, css::RED]);
ctx.set_paint(gradient.into());
ctx.fill_rect(&rect);
}
ProbeFeature::ImageBicubic => {
let rect = centered_rect(cell, RECT_SIZE, RECT_SIZE);
ctx.set_paint(image_bicubic.clone());
ctx.set_paint_transform(
Affine::translate((rect.x0, rect.y0))
* Affine::scale(RECT_SIZE / IMAGE_SOURCE_SIZE),
);
ctx.fill_rect(&rect);
ctx.reset_paint_transform();
}
}
}

Expand Down Expand Up @@ -439,6 +494,24 @@ fn draw_blurred_rect(ctx: &mut impl ProbeRenderer, rect: Rect) {
ctx.pop_layer();
}

fn draw_drop_shadow_rect(ctx: &mut impl ProbeRenderer, cell: Rect) {
let offset = 1.5;
let std_deviation = 0.5;
let centering_offset = f64::from(offset) * 0.5 + f64::from(std_deviation);
let rect = centered_rect(cell, 8.0, 8.0) - Vec2::new(centering_offset, centering_offset);
let shadow = Filter::from_primitive(FilterPrimitive::DropShadow {
dx: offset,
dy: offset,
std_deviation,
color: css::BLACK.with_alpha(0.75),
edge_mode: EdgeMode::None,
});
ctx.push_filter_layer(shadow);
ctx.set_paint(css::BLUE.into());
ctx.fill_rect(&rect);
ctx.pop_layer();
}

fn draw_opacity_layer_rect(ctx: &mut impl ProbeRenderer, rect: Rect) {
ctx.push_layer(None, Some(0.5));
ctx.set_paint(css::ORANGE_RED.into());
Expand Down
Loading
Loading