Merge branch 'master' into beacon
This commit is contained in:
commit
ebfcb65841
41 changed files with 805 additions and 589 deletions
|
|
@ -8,46 +8,17 @@ use iced::{
|
|||
Color, Element, Font, Length, Pixels, Point, Rectangle, Size, Theme,
|
||||
};
|
||||
use iced_wgpu::Renderer;
|
||||
use iced_wgpu::wgpu;
|
||||
|
||||
criterion_main!(benches);
|
||||
criterion_group!(benches, wgpu_benchmark);
|
||||
|
||||
#[allow(unused_results)]
|
||||
pub fn wgpu_benchmark(c: &mut Criterion) {
|
||||
c.bench_function("wgpu — canvas (light)", |b| {
|
||||
benchmark(b, |_| scene(10));
|
||||
});
|
||||
c.bench_function("wgpu — canvas (heavy)", |b| {
|
||||
benchmark(b, |_| scene(1_000));
|
||||
});
|
||||
|
||||
c.bench_function("wgpu - layered text (light)", |b| {
|
||||
benchmark(b, |_| layered_text(10));
|
||||
});
|
||||
c.bench_function("wgpu - layered text (heavy)", |b| {
|
||||
benchmark(b, |_| layered_text(1_000));
|
||||
});
|
||||
|
||||
c.bench_function("wgpu - dynamic text (light)", |b| {
|
||||
benchmark(b, |i| dynamic_text(1_000, i));
|
||||
});
|
||||
c.bench_function("wgpu - dynamic text (heavy)", |b| {
|
||||
benchmark(b, |i| dynamic_text(100_000, i));
|
||||
});
|
||||
}
|
||||
|
||||
fn benchmark<'a>(
|
||||
bencher: &mut Bencher<'_>,
|
||||
view: impl Fn(usize) -> Element<'a, (), Theme, Renderer>,
|
||||
) {
|
||||
use iced_futures::futures::executor;
|
||||
use iced_wgpu::graphics;
|
||||
use iced_wgpu::graphics::Antialiasing;
|
||||
use iced_wgpu::wgpu;
|
||||
use iced_winit::core;
|
||||
use iced_winit::runtime;
|
||||
|
||||
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
|
||||
let instance = wgpu::Instance::new(&wgpu::InstanceDescriptor {
|
||||
backends: wgpu::Backends::all(),
|
||||
..Default::default()
|
||||
});
|
||||
|
|
@ -72,18 +43,53 @@ fn benchmark<'a>(
|
|||
))
|
||||
.expect("request device");
|
||||
|
||||
c.bench_function("wgpu — canvas (light)", |b| {
|
||||
benchmark(b, &adapter, &device, &queue, |_| scene(10));
|
||||
});
|
||||
c.bench_function("wgpu — canvas (heavy)", |b| {
|
||||
benchmark(b, &adapter, &device, &queue, |_| scene(1_000));
|
||||
});
|
||||
|
||||
c.bench_function("wgpu - layered text (light)", |b| {
|
||||
benchmark(b, &adapter, &device, &queue, |_| layered_text(10));
|
||||
});
|
||||
c.bench_function("wgpu - layered text (heavy)", |b| {
|
||||
benchmark(b, &adapter, &device, &queue, |_| layered_text(1_000));
|
||||
});
|
||||
|
||||
c.bench_function("wgpu - dynamic text (light)", |b| {
|
||||
benchmark(b, &adapter, &device, &queue, |i| dynamic_text(1_000, i));
|
||||
});
|
||||
c.bench_function("wgpu - dynamic text (heavy)", |b| {
|
||||
benchmark(b, &adapter, &device, &queue, |i| dynamic_text(100_000, i));
|
||||
});
|
||||
}
|
||||
|
||||
fn benchmark<'a>(
|
||||
bencher: &mut Bencher<'_>,
|
||||
adapter: &wgpu::Adapter,
|
||||
device: &wgpu::Device,
|
||||
queue: &wgpu::Queue,
|
||||
view: impl Fn(usize) -> Element<'a, (), Theme, Renderer>,
|
||||
) {
|
||||
use iced_wgpu::graphics;
|
||||
use iced_wgpu::graphics::Antialiasing;
|
||||
use iced_wgpu::wgpu;
|
||||
use iced_winit::core;
|
||||
use iced_winit::runtime;
|
||||
|
||||
let format = wgpu::TextureFormat::Bgra8UnormSrgb;
|
||||
|
||||
let mut engine = iced_wgpu::Engine::new(
|
||||
&adapter,
|
||||
&device,
|
||||
&queue,
|
||||
adapter,
|
||||
device,
|
||||
queue,
|
||||
format,
|
||||
Some(Antialiasing::MSAAx4),
|
||||
);
|
||||
|
||||
let mut renderer =
|
||||
Renderer::new(&device, &engine, Font::DEFAULT, Pixels::from(16));
|
||||
Renderer::new(device, &engine, Font::DEFAULT, Pixels::from(16));
|
||||
|
||||
let viewport =
|
||||
graphics::Viewport::with_physical_size(Size::new(3840, 2160), 2.0);
|
||||
|
|
@ -135,8 +141,8 @@ fn benchmark<'a>(
|
|||
|
||||
renderer.present(
|
||||
&mut engine,
|
||||
&device,
|
||||
&queue,
|
||||
device,
|
||||
queue,
|
||||
&mut encoder,
|
||||
Some(Color::BLACK),
|
||||
format,
|
||||
|
|
@ -144,7 +150,7 @@ fn benchmark<'a>(
|
|||
&viewport,
|
||||
);
|
||||
|
||||
let submission = engine.submit(&queue, encoder);
|
||||
let submission = engine.submit(queue, encoder);
|
||||
let _ = device.poll(wgpu::Maintain::WaitForSubmissionIndex(submission));
|
||||
|
||||
i += 1;
|
||||
|
|
@ -184,8 +190,8 @@ fn scene<'a, Message: 'a>(n: usize) -> Element<'a, Message, Theme, Renderer> {
|
|||
size: Pixels::from(16),
|
||||
line_height: text::LineHeight::default(),
|
||||
font: Font::DEFAULT,
|
||||
horizontal_alignment: alignment::Horizontal::Left,
|
||||
vertical_alignment: alignment::Vertical::Top,
|
||||
align_x: alignment::Horizontal::Left,
|
||||
align_y: alignment::Vertical::Top,
|
||||
shaping: text::Shaping::Basic,
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue