Skip to content
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
1 change: 1 addition & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions sparse_strips/vello_bench/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ vello_common = { workspace = true }
vello_cpu = { workspace = true }
vello_dev_macros = { workspace = true }
criterion = { workspace = true }
image = { workspace = true, features = ["jpeg"] }
parley = { version = "0.5.0", default-features = true }
rand = { workspace = true }
smallvec = { workspace = true }
Expand Down
6 changes: 4 additions & 2 deletions sparse_strips/vello_bench/benches/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#![allow(dead_code, reason = "Might be unused on platforms not supporting SIMD")]

use criterion::{criterion_group, criterion_main};
use vello_bench::{fine, flatten, glyph, strip, tile};
use vello_bench::{fine, flatten, glyph, integration, strip, tile};

criterion_group!(fine_solid, fine::fill);
criterion_group!(fine_strip, fine::strip);
Expand All @@ -19,6 +19,7 @@ criterion_group!(flatten, flatten::flatten);
criterion_group!(strokes, flatten::strokes);
criterion_group!(render_strips, strip::render_strips);
criterion_group!(glyph, glyph::glyph);
criterion_group!(integration_bench, integration::images);
criterion_main!(
tile,
render_strips,
Expand All @@ -31,5 +32,6 @@ criterion_main!(
fine_gradient,
fine_rounded_blurred_rect,
fine_blend,
fine_image
fine_image,
integration_bench
);
92 changes: 92 additions & 0 deletions sparse_strips/vello_bench/src/integration.rs
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm wondering whether integration (similar as in integration tests) would be a better name? But not sure, up to you.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think you made a good point, “integration” is a more descriptive name here. Thank you!

Fixed.

Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
// Copyright 2025 the Vello Authors
// SPDX-License-Identifier: Apache-2.0 OR MIT

//! Integration benchmarks for full rendering pipelines.

use std::sync::Arc;

use criterion::Criterion;
use vello_common::kurbo::{Affine, Rect};
use vello_common::paint::{Image, ImageSource};
use vello_common::peniko::ImageSampler;
use vello_common::peniko::{Extend, ImageQuality};
use vello_common::pixmap::Pixmap;
use vello_cpu::RenderContext;
use vello_cpu::color::AlphaColor;

/// Image scene rendering benchmark.
pub fn images(c: &mut Criterion) {
let mut g = c.benchmark_group("images");

let flower_image = load_flower_image();

const VIEWPORT_WIDTH: u16 = 1280;
const VIEWPORT_HEIGHT: u16 = 960;

let ImageSource::Pixmap(ref image_pixmap) = flower_image else {
panic!("Expected Pixmap");
};
let original_width = f64::from(image_pixmap.width());
let original_height = f64::from(image_pixmap.height());
let image_count = VIEWPORT_WIDTH / 256;

g.bench_function("overlapping", |b| {
let mut renderer = RenderContext::new(VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
let mut pixmap = Pixmap::new(VIEWPORT_WIDTH, VIEWPORT_HEIGHT);

b.iter(|| {
renderer.reset();

for i in (1..=image_count).rev() {
let width = 256.0 * i as f64;
let scale = width / original_width;
let height = original_height * scale;

renderer.set_paint_transform(Affine::scale(scale));
renderer.set_paint(Image {
image: flower_image.clone(),
sampler: ImageSampler {
x_extend: Extend::Pad,
y_extend: Extend::Pad,
quality: ImageQuality::Low,
alpha: 1.0,
},
});
renderer.fill_rect(&Rect::new(0.0, 0.0, width, height));
}

renderer.flush();
renderer.render_to_pixmap(&mut pixmap);
std::hint::black_box(&pixmap);
});
});

g.finish();
}

fn load_flower_image() -> ImageSource {
let image_data = include_bytes!("../../../examples/assets/splash-flower.jpg");
let image = image::load_from_memory(image_data).expect("Failed to decode image");
let width = image.width();
let height = image.height();
let rgba_data = image.into_rgba8().into_vec();

#[expect(
clippy::cast_possible_truncation,
reason = "Image dimensions fit in u16"
)]
let pixmap = Pixmap::from_parts(
rgba_data
.chunks_exact(4)
.map(|rgba| {
AlphaColor::from_rgba8(rgba[0], rgba[1], rgba[2], rgba[3])
.premultiply()
.to_rgba8()
})
.collect(),
width as u16,
height as u16,
);

ImageSource::Pixmap(Arc::new(pixmap))
}
1 change: 1 addition & 0 deletions sparse_strips/vello_bench/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ pub mod data;
pub mod fine;
pub mod flatten;
pub mod glyph;
pub mod integration;
pub mod strip;
pub mod tile;

Expand Down
Loading