66use rendy:: {
77 command:: { DrawIndexedCommand , QueueId , RenderPassEncoder } ,
88 factory:: { Config , Factory , ImageState } ,
9- graph:: { present:: PresentNode , render:: * , GraphBuilder , NodeBuffer , NodeImage , GraphContext } ,
9+ graph:: { present:: PresentNode , render:: * , GraphBuilder , GraphContext , NodeBuffer , NodeImage } ,
1010 hal:: { pso:: DescriptorPool , Device } ,
1111 memory:: MemoryUsageValue ,
1212 mesh:: { AsVertex , Mesh , PosNormTex , Transform } ,
@@ -16,25 +16,23 @@ use rendy::{
1616} ;
1717
1818use rendy:: {
19- command:: { Families } ,
20- graph:: {
21- render:: * , Graph
22- } ,
19+ command:: Families ,
20+ graph:: { render:: * , Graph } ,
2321 memory:: Dynamic ,
24- mesh:: { PosColor } ,
25- resource:: { BufferInfo , DescriptorSetLayout , Escape , Handle }
22+ mesh:: PosColor ,
23+ resource:: { BufferInfo , DescriptorSetLayout , Escape , Handle } ,
2624} ;
2725
28- use std:: { mem:: size_of, time} ;
29- use std:: marker:: PhantomData ;
3026use genmesh:: {
3127 generators:: { IndexedPolygon , SharedVertex } ,
3228 Triangulate ,
3329} ;
30+ use std:: marker:: PhantomData ;
31+ use std:: { mem:: size_of, time} ;
3432
3533use rand:: distributions:: { Distribution , Uniform } ;
3634
37- use winit:: { EventsLoop , WindowBuilder , Event , WindowEvent } ;
35+ use winit:: { Event , EventsLoop , WindowBuilder , WindowEvent } ;
3836
3937#[ cfg( feature = "dx12" ) ]
4038type Backend = rendy:: dx12:: Backend ;
@@ -123,7 +121,7 @@ struct MeshRenderPipeline<B: gfx_hal::Backend> {
123121
124122impl < B > SimpleGraphicsPipelineDesc < B , Aux < B > > for MeshRenderPipelineDesc
125123where
126- B : gfx_hal:: Backend
124+ B : gfx_hal:: Backend ,
127125{
128126 type Pipeline = MeshRenderPipeline < B > ;
129127
@@ -243,14 +241,15 @@ where
243241 let buffer = factory
244242 . create_buffer (
245243 BufferInfo {
246- size : buffer_frame_size ( aux. align ) * frames as u64 ,
247- usage : gfx_hal:: buffer:: Usage :: VERTEX | gfx_hal:: buffer:: Usage :: UNIFORM | gfx_hal:: buffer:: Usage :: INDIRECT ,
244+ size : buffer_frame_size ( aux. align ) * frames as u64 ,
245+ usage : gfx_hal:: buffer:: Usage :: VERTEX
246+ | gfx_hal:: buffer:: Usage :: UNIFORM
247+ | gfx_hal:: buffer:: Usage :: INDIRECT ,
248248 } ,
249249 Dynamic ,
250250 )
251251 . unwrap ( ) ;
252252
253-
254253 let cube = genmesh:: generators:: Cube :: new ( ) ;
255254 let cube_indices: Vec < _ > =
256255 genmesh:: Vertices :: vertices ( cube. indexed_polygon_iter ( ) . triangulate ( ) )
@@ -308,7 +307,7 @@ where
308307 queue,
309308 stage : gfx_hal:: pso:: PipelineStage :: FRAGMENT_SHADER ,
310309 access : gfx_hal:: image:: Access :: SHADER_READ ,
311- layout : gfx_hal:: image:: Layout :: ShaderReadOnlyOptimal
310+ layout : gfx_hal:: image:: Layout :: ShaderReadOnlyOptimal ,
312311 } ,
313312 factory,
314313 )
@@ -326,7 +325,8 @@ where
326325 array_offset: 0 ,
327326 descriptors: Some ( gfx_hal:: pso:: Descriptor :: Buffer (
328327 buffer. raw( ) ,
329- Some ( uniform_offset( index, aux. align) ) ..Some ( uniform_offset( index, aux. align) + UNIFORM_SIZE ) ,
328+ Some ( uniform_offset( index, aux. align) )
329+ ..Some ( uniform_offset( index, aux. align) + UNIFORM_SIZE ) ,
330330 ) ) ,
331331 } ,
332332 gfx_hal:: pso:: DescriptorSetWrite {
@@ -363,7 +363,7 @@ where
363363
364364impl < B > SimpleGraphicsPipeline < B , Aux < B > > for MeshRenderPipeline < B >
365365where
366- B : gfx_hal:: Backend
366+ B : gfx_hal:: Backend ,
367367{
368368 type Desc = MeshRenderPipelineDesc ;
369369
@@ -452,8 +452,7 @@ where
452452
453453 fn dispose ( mut self , factory : & mut Factory < B > , _aux : & Aux < B > ) {
454454 unsafe {
455- self . descriptor_pool
456- . free_sets ( self . sets . into_iter ( ) ) ;
455+ self . descriptor_pool . free_sets ( self . sets . into_iter ( ) ) ;
457456 factory. destroy_descriptor_pool ( self . descriptor_pool ) ;
458457 }
459458 }
@@ -512,8 +511,8 @@ fn main() {
512511 . into_pass ( ) ,
513512 ) ;
514513
515- let present_builder = PresentNode :: builder ( surface , factory . physical ( ) , color )
516- . with_dependency ( pass) ;
514+ let present_builder =
515+ PresentNode :: builder ( surface , factory . physical ( ) , color ) . with_dependency ( pass) ;
517516
518517 let frames = present_builder. image_count ( ) as usize ;
519518
@@ -555,7 +554,10 @@ fn main() {
555554 for _ in & mut frames {
556555 factory. maintain ( & mut families) ;
557556 event_loop. poll_events ( |event| match event {
558- Event :: WindowEvent { event : WindowEvent :: CloseRequested , .. } => should_close = true ,
557+ Event :: WindowEvent {
558+ event : WindowEvent :: CloseRequested ,
559+ ..
560+ } => should_close = true ,
559561 _ => ( ) ,
560562 } ) ;
561563 graph. run ( & mut factory, & mut families, & mut aux) ;
@@ -574,10 +576,16 @@ fn main() {
574576 } )
575577 }
576578
577- if should_close || elapsed > std:: time:: Duration :: new ( 5 , 0 ) || aux. scene . objects . len ( ) == MAX_OBJECTS {
579+ if should_close
580+ || elapsed > std:: time:: Duration :: new ( 5 , 0 )
581+ || aux. scene . objects . len ( ) == MAX_OBJECTS
582+ {
578583 let frames = frames. start - start;
579584 let nanos = elapsed. as_secs ( ) * 1_000_000_000 + elapsed. subsec_nanos ( ) as u64 ;
580- fpss. push ( ( frames * 1_000_000_000 / nanos, from..aux. scene . objects . len ( ) ) ) ;
585+ fpss. push ( (
586+ frames * 1_000_000_000 / nanos,
587+ from..aux. scene . objects . len ( ) ,
588+ ) ) ;
581589 checkpoint += elapsed;
582590 break ;
583591 }
0 commit comments