diff options
Diffstat (limited to 'benches')
-rw-r--r-- | benches/wgpu.rs | 59 |
1 files changed, 27 insertions, 32 deletions
diff --git a/benches/wgpu.rs b/benches/wgpu.rs index 2c117858..780c6bc2 100644 --- a/benches/wgpu.rs +++ b/benches/wgpu.rs @@ -12,18 +12,15 @@ use iced_wgpu::Renderer; criterion_main!(benches); criterion_group!(benches, wgpu_benchmark); +#[allow(unused_results)] pub fn wgpu_benchmark(c: &mut Criterion) { - let _ = c - .bench_function("wgpu — canvas (light)", |b| benchmark(b, scene(10))); - - let _ = c.bench_function("wgpu — canvas (heavy)", |b| { - benchmark(b, scene(1_000)) - }); + c.bench_function("wgpu — canvas (light)", |b| benchmark(b, scene(10))); + c.bench_function("wgpu — canvas (heavy)", |b| benchmark(b, scene(1_000))); } -fn benchmark<'a>( +fn benchmark( bencher: &mut Bencher<'_>, - widget: Element<'a, (), Theme, Renderer>, + widget: Element<'_, (), Theme, Renderer>, ) { use iced_futures::futures::executor; use iced_wgpu::graphics; @@ -58,22 +55,25 @@ fn benchmark<'a>( let format = wgpu::TextureFormat::Bgra8UnormSrgb; - let backend = iced_wgpu::Backend::new( + let mut engine = iced_wgpu::Engine::new( &adapter, &device, &queue, + format, + Some(Antialiasing::MSAAx4), + ); + + let mut renderer = Renderer::new( iced_wgpu::Settings { present_mode: wgpu::PresentMode::Immediate, - internal_backend: wgpu::Backends::all(), + backends: wgpu::Backends::all(), default_font: Font::DEFAULT, default_text_size: Pixels::from(16), antialiasing: Some(Antialiasing::MSAAx4), }, - format, + &engine, ); - let mut renderer = Renderer::new(backend, Font::DEFAULT, Pixels::from(16)); - let viewport = graphics::Viewport::with_physical_size(Size::new(3840, 2160), 2.0); @@ -117,25 +117,20 @@ fn benchmark<'a>( label: None, }); - renderer.with_primitives(|backend, primitives| { - backend.present::<&str>( - &device, - &queue, - &mut encoder, - Some(Color::BLACK), - format, - &texture_view, - primitives, - &viewport, - &[], - ); - - let submission = queue.submit(Some(encoder.finish())); - backend.recall(); - - let _ = - device.poll(wgpu::Maintain::WaitForSubmissionIndex(submission)); - }); + renderer.present::<&str>( + &mut engine, + &device, + &queue, + &mut encoder, + Some(Color::BLACK), + format, + &texture_view, + &viewport, + &[], + ); + + let submission = engine.submit(&queue, encoder); + let _ = device.poll(wgpu::Maintain::WaitForSubmissionIndex(submission)); }); } |