This repository was archived by the owner on Jun 18, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +17
-9
lines changed
Expand file tree Collapse file tree 3 files changed +17
-9
lines changed Original file line number Diff line number Diff line change @@ -162,7 +162,8 @@ pub fn run<E: Example>(title: &str) {
162162 }
163163 } ,
164164 event:: Event :: EventsCleared => {
165- let frame = swap_chain. get_next_texture ( ) ;
165+ let frame = swap_chain. get_next_texture ( )
166+ . expect ( "Timeout when acquiring next swap chain texture" ) ;
166167 let command_buf = example. render ( & frame, & device) ;
167168 queue. submit ( & [ command_buf] ) ;
168169 }
Original file line number Diff line number Diff line change @@ -133,7 +133,8 @@ fn main() {
133133 _ => { }
134134 } ,
135135 event:: Event :: EventsCleared => {
136- let frame = swap_chain. get_next_texture ( ) ;
136+ let frame = swap_chain. get_next_texture ( )
137+ . expect ( "Timeout when acquiring next swap chain texture" ) ;
137138 let mut encoder =
138139 device. create_command_encoder ( & wgpu:: CommandEncoderDescriptor { todo : 0 } ) ;
139140 {
Original file line number Diff line number Diff line change @@ -1351,14 +1351,20 @@ impl SwapChain {
13511351 ///
13521352 /// When the [`SwapChainOutput`] returned by this method is dropped, the swapchain will present
13531353 /// the texture to the associated [`Surface`].
1354- pub fn get_next_texture ( & mut self ) -> SwapChainOutput {
1354+ ///
1355+ /// Returns an `Err` if the GPU timed out when attempting to acquire the next texture.
1356+ pub fn get_next_texture ( & mut self ) -> Result < SwapChainOutput , ( ) > {
13551357 let output = wgn:: wgpu_swap_chain_get_next_texture ( self . id ) ;
1356- SwapChainOutput {
1357- view : TextureView {
1358- id : output. view_id ,
1359- owned : false ,
1360- } ,
1361- swap_chain_id : & self . id ,
1358+ if output. view_id == wgn:: Id :: ERROR {
1359+ Err ( ( ) )
1360+ } else {
1361+ Ok ( SwapChainOutput {
1362+ view : TextureView {
1363+ id : output. view_id ,
1364+ owned : false ,
1365+ } ,
1366+ swap_chain_id : & self . id ,
1367+ } )
13621368 }
13631369 }
13641370}
You can’t perform that action at this time.
0 commit comments