Skip to content

Commit 58b2f07

Browse files
authored
Make Surface::present() errors non-fatal. (#2)
* Make Surface::present() errors non-fatal. * Remove code used for testing. * clippy
1 parent d11b074 commit 58b2f07

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

wgpu/src/backend/wgpu_core.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,7 @@ pub struct CoreTlas {
589589
pub struct CoreSurfaceOutputDetail {
590590
context: ContextWgpuCore,
591591
surface_id: wgc::id::SurfaceId,
592+
error_sink: ErrorSink,
592593
}
593594

594595
type ErrorSink = Arc<Mutex<ErrorSinkRaw>>;
@@ -3443,9 +3444,16 @@ impl dispatch::SurfaceInterface for CoreSurface {
34433444
crate::SurfaceStatus,
34443445
dispatch::DispatchSurfaceOutputDetail,
34453446
) {
3447+
let error_sink = if let Some(error_sink) = self.error_sink.lock().as_ref() {
3448+
error_sink.clone()
3449+
} else {
3450+
Arc::new(Mutex::new(ErrorSinkRaw::new()))
3451+
};
3452+
34463453
let output_detail = CoreSurfaceOutputDetail {
34473454
context: self.context.clone(),
34483455
surface_id: self.id,
3456+
error_sink: error_sink.clone(),
34493457
}
34503458
.into();
34513459

@@ -3455,7 +3463,7 @@ impl dispatch::SurfaceInterface for CoreSurface {
34553463
.map(|id| CoreTexture {
34563464
context: self.context.clone(),
34573465
id,
3458-
error_sink: Arc::new(Mutex::new(ErrorSinkRaw::new())),
3466+
error_sink,
34593467
})
34603468
.map(Into::into);
34613469

@@ -3491,7 +3499,10 @@ impl dispatch::SurfaceOutputDetailInterface for CoreSurfaceOutputDetail {
34913499
fn present(&self) {
34923500
match self.context.0.surface_present(self.surface_id) {
34933501
Ok(_status) => (),
3494-
Err(err) => self.context.handle_error_fatal(err, "Surface::present"),
3502+
Err(err) => {
3503+
self.context
3504+
.handle_error_nolabel(&self.error_sink, err, "Surface::present");
3505+
}
34953506
}
34963507
}
34973508

0 commit comments

Comments
 (0)