Commit 84bb9f0
committed
fix(renderer): correctly handle lost/outdated surface errors
Previously, minimizing and then restoring the window would cause a `SurfaceError::Lost` panic. This was because the render loop attempted to rebuild render targets without first reconfiguring the underlying `wgpu::Surface`, which becomes invalid after being lost.
This commit fixes the issue by:
1. Introducing a new `WgpuApp::resize_surface()` method that properly reconfigures the surface with the device and then rebuilds all dependent render targets (pass targets, MSAA textures, etc.).
2. Updating the main render loop in `renderer.rs` to call this new method upon receiving a `SurfaceError::Lost` or `SurfaceError::Outdated`, ensuring a full recovery.
3. Refactoring the existing `resize_if_needed` logic to use the new centralized `resize_surface` method for consistency.1 parent bc0ede9 commit 84bb9f0
2 files changed
+53
-37
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
723 | 723 | | |
724 | 724 | | |
725 | 725 | | |
726 | | - | |
727 | | - | |
728 | | - | |
729 | | - | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
730 | 742 | | |
731 | 743 | | |
732 | 744 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
365 | 365 | | |
366 | 366 | | |
367 | 367 | | |
368 | | - | |
369 | | - | |
370 | | - | |
371 | | - | |
372 | | - | |
373 | | - | |
374 | | - | |
375 | | - | |
376 | | - | |
377 | | - | |
378 | | - | |
379 | | - | |
380 | | - | |
381 | | - | |
382 | | - | |
383 | | - | |
384 | | - | |
385 | | - | |
386 | | - | |
387 | | - | |
388 | | - | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
389 | 376 | | |
390 | | - | |
391 | | - | |
392 | | - | |
393 | | - | |
394 | | - | |
395 | | - | |
396 | | - | |
397 | | - | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
398 | 401 | | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
399 | 406 | | |
400 | 407 | | |
401 | 408 | | |
402 | 409 | | |
403 | 410 | | |
404 | 411 | | |
405 | 412 | | |
406 | | - | |
407 | | - | |
408 | | - | |
409 | | - | |
| 413 | + | |
410 | 414 | | |
411 | 415 | | |
412 | 416 | | |
| |||
0 commit comments