@@ -12,18 +12,15 @@ use iced_wgpu::Renderer;
1212criterion_main ! ( benches) ;
1313criterion_group ! ( benches, wgpu_benchmark) ;
1414
15+ #[ allow( unused_results) ]
1516pub fn wgpu_benchmark ( c : & mut Criterion ) {
16- let _ = c
17- . bench_function ( "wgpu — canvas (light)" , |b| benchmark ( b, scene ( 10 ) ) ) ;
18-
19- let _ = c. bench_function ( "wgpu — canvas (heavy)" , |b| {
20- benchmark ( b, scene ( 1_000 ) )
21- } ) ;
17+ c. bench_function ( "wgpu — canvas (light)" , |b| benchmark ( b, scene ( 10 ) ) ) ;
18+ c. bench_function ( "wgpu — canvas (heavy)" , |b| benchmark ( b, scene ( 1_000 ) ) ) ;
2219}
2320
24- fn benchmark < ' a > (
21+ fn benchmark (
2522 bencher : & mut Bencher < ' _ > ,
26- widget : Element < ' a , ( ) , Theme , Renderer > ,
23+ widget : Element < ' _ , ( ) , Theme , Renderer > ,
2724) {
2825 use iced_futures:: futures:: executor;
2926 use iced_wgpu:: graphics;
@@ -58,21 +55,15 @@ fn benchmark<'a>(
5855
5956 let format = wgpu:: TextureFormat :: Bgra8UnormSrgb ;
6057
61- let backend = iced_wgpu:: Backend :: new (
58+ let mut engine = iced_wgpu:: Engine :: new (
6259 & adapter,
6360 & device,
6461 & queue,
65- iced_wgpu:: Settings {
66- present_mode : wgpu:: PresentMode :: Immediate ,
67- internal_backend : wgpu:: Backends :: all ( ) ,
68- default_font : Font :: DEFAULT ,
69- default_text_size : Pixels :: from ( 16 ) ,
70- antialiasing : Some ( Antialiasing :: MSAAx4 ) ,
71- } ,
7262 format,
63+ Some ( Antialiasing :: MSAAx4 ) ,
7364 ) ;
7465
75- let mut renderer = Renderer :: new ( backend , Font :: DEFAULT , Pixels :: from ( 16 ) ) ;
66+ let mut renderer = Renderer :: new ( & engine , Font :: DEFAULT , Pixels :: from ( 16 ) ) ;
7667
7768 let viewport =
7869 graphics:: Viewport :: with_physical_size ( Size :: new ( 3840 , 2160 ) , 2.0 ) ;
@@ -117,25 +108,20 @@ fn benchmark<'a>(
117108 label : None ,
118109 } ) ;
119110
120- renderer. with_primitives ( |backend, primitives| {
121- backend. present :: < & str > (
122- & device,
123- & queue,
124- & mut encoder,
125- Some ( Color :: BLACK ) ,
126- format,
127- & texture_view,
128- primitives,
129- & viewport,
130- & [ ] ,
131- ) ;
132-
133- let submission = queue. submit ( Some ( encoder. finish ( ) ) ) ;
134- backend. recall ( ) ;
135-
136- let _ =
137- device. poll ( wgpu:: Maintain :: WaitForSubmissionIndex ( submission) ) ;
138- } ) ;
111+ renderer. present :: < & str > (
112+ & mut engine,
113+ & device,
114+ & queue,
115+ & mut encoder,
116+ Some ( Color :: BLACK ) ,
117+ format,
118+ & texture_view,
119+ & viewport,
120+ & [ ] ,
121+ ) ;
122+
123+ let submission = engine. submit ( & queue, encoder) ;
124+ let _ = device. poll ( wgpu:: Maintain :: WaitForSubmissionIndex ( submission) ) ;
139125 } ) ;
140126}
141127
0 commit comments