@@ -128,11 +128,16 @@ pub struct SwapChainOutput {
128
128
pub view_id : TextureViewId ,
129
129
}
130
130
131
+ #[ derive( Debug ) ]
132
+ pub enum SwapChainGetNextTextureError {
133
+ GpuProcessingTimeout ,
134
+ }
135
+
131
136
pub fn swap_chain_get_next_texture < B : GfxBackend > (
132
137
global : & Global ,
133
138
swap_chain_id : SwapChainId ,
134
139
view_id_in : Input < TextureViewId > ,
135
- ) -> SwapChainOutput {
140
+ ) -> Result < SwapChainOutput , SwapChainGetNextTextureError > {
136
141
let hub = B :: hub ( global) ;
137
142
let mut token = Token :: root ( ) ;
138
143
@@ -148,7 +153,7 @@ pub fn swap_chain_get_next_texture<B: GfxBackend>(
148
153
match unsafe { suf. acquire_image ( FRAME_TIMEOUT_MS * 1_000_000 ) } {
149
154
Ok ( surface_image) => surface_image,
150
155
Err ( hal:: window:: AcquireError :: Timeout ) => {
151
- panic ! ( "GPU took too much time processing last frames :(" ) ;
156
+ return Err ( SwapChainGetNextTextureError :: GpuProcessingTimeout ) ;
152
157
}
153
158
Err ( e) => {
154
159
log:: warn!( "acquire_image() failed ({:?}), reconfiguring swapchain" , e) ;
@@ -197,13 +202,13 @@ pub fn swap_chain_get_next_texture<B: GfxBackend>(
197
202
ref_count,
198
203
} ) ;
199
204
200
- SwapChainOutput { view_id }
205
+ Ok ( SwapChainOutput { view_id } )
201
206
}
202
207
203
208
#[ cfg( feature = "local" ) ]
204
209
#[ no_mangle]
205
210
pub extern "C" fn wgpu_swap_chain_get_next_texture ( swap_chain_id : SwapChainId ) -> SwapChainOutput {
206
- gfx_select ! ( swap_chain_id => swap_chain_get_next_texture( & * GLOBAL , swap_chain_id, PhantomData ) )
211
+ gfx_select ! ( swap_chain_id => swap_chain_get_next_texture( & * GLOBAL , swap_chain_id, PhantomData ) ) . unwrap ( )
207
212
}
208
213
209
214
pub fn swap_chain_present < B : GfxBackend > ( global : & Global , swap_chain_id : SwapChainId ) {
0 commit comments