@@ -204,36 +204,35 @@ where
204204 self . scene . reset ( ) ;
205205 self . scene . append ( fragment, transform) ;
206206 self . counter += 1 ;
207-
208- let surface_texture = self
209- . surface
210- . surface
211- . get_current_texture ( )
212- . expect ( "failed to acquire next swapchain texture" ) ;
213- let dev_id = self . surface . dev_id ;
214- let device = & self . render_cx . devices [ dev_id] . device ;
215- let queue = & self . render_cx . devices [ dev_id] . queue ;
216- let renderer_options = RendererOptions {
217- surface_format : Some ( self . surface . format ) ,
218- use_cpu : false ,
219- antialiasing_support : AaSupport {
220- area : true ,
221- msaa8 : false ,
222- msaa16 : false ,
223- } ,
224- num_init_threads : NonZeroUsize :: new ( 1 ) ,
225- } ;
226- let render_params = RenderParams {
227- base_color : Color :: BLACK ,
228- width,
229- height,
230- antialiasing_method : vello:: AaConfig :: Area ,
231- } ;
232- self . renderer
233- . get_or_insert_with ( || Renderer :: new ( device, renderer_options) . unwrap ( ) )
234- . render_to_surface ( device, queue, & self . scene , & surface_texture, & render_params)
235- . expect ( "failed to render to surface" ) ;
236- surface_texture. present ( ) ;
237- device. poll ( wgpu:: Maintain :: Wait ) ;
207+ loop {
208+ if let Ok ( surface_texture) = self . surface . surface . get_current_texture ( ) {
209+ let dev_id = self . surface . dev_id ;
210+ let device = & self . render_cx . devices [ dev_id] . device ;
211+ let queue = & self . render_cx . devices [ dev_id] . queue ;
212+ let renderer_options = RendererOptions {
213+ surface_format : Some ( self . surface . format ) ,
214+ use_cpu : false ,
215+ antialiasing_support : AaSupport {
216+ area : true ,
217+ msaa8 : false ,
218+ msaa16 : false ,
219+ } ,
220+ num_init_threads : NonZeroUsize :: new ( 1 ) ,
221+ } ;
222+ let render_params = RenderParams {
223+ base_color : Color :: BLACK ,
224+ width,
225+ height,
226+ antialiasing_method : vello:: AaConfig :: Area ,
227+ } ;
228+ self . renderer
229+ . get_or_insert_with ( || Renderer :: new ( device, renderer_options) . unwrap ( ) )
230+ . render_to_surface ( device, queue, & self . scene , & surface_texture, & render_params)
231+ . expect ( "failed to render to surface" ) ;
232+ surface_texture. present ( ) ;
233+ device. poll ( wgpu:: Maintain :: Wait ) ;
234+ break ;
235+ }
236+ }
238237 }
239238}
0 commit comments