Skip to content

cleanup bevy_render/lib.rs#16481

Merged
mockersf merged 2 commits intobevyengine:mainfrom
atlv24:ad/cleanup-render
Nov 22, 2024
Merged

cleanup bevy_render/lib.rs#16481
mockersf merged 2 commits intobevyengine:mainfrom
atlv24:ad/cleanup-render

Conversation

@atlv24
Copy link
Copy Markdown
Contributor

@atlv24 atlv24 commented Nov 22, 2024

Objective

  • Refactor

Solution

  • Refactor

Testing

  • Ran 3d_scene

Migration Guide

RenderCreation::Manual variant fields are now wrapped in a struct called RenderResources

@atlv24 atlv24 added A-Rendering Drawing game state to the screen C-Code-Quality A section of code that is hard to understand or change D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Nov 22, 2024
@alice-i-cecile alice-i-cecile added the M-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide label Nov 22, 2024
@alice-i-cecile alice-i-cecile modified the milestones: 0.15, 0.16 Nov 22, 2024
@BenjaminBrienen BenjaminBrienen added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Nov 22, 2024
@mockersf mockersf added this pull request to the merge queue Nov 22, 2024
Merged via the queue into bevyengine:main with commit 636e99c Nov 22, 2024
ecoskey pushed a commit to ecoskey/bevy that referenced this pull request Dec 2, 2024
# Objective

- Refactor

## Solution

- Refactor

## Testing

- Ran 3d_scene

---

## Migration Guide

`RenderCreation::Manual` variant fields are now wrapped in a struct
called `RenderResources`
ecoskey pushed a commit to ecoskey/bevy that referenced this pull request Jan 6, 2025
# Objective

- Refactor

## Solution

- Refactor

## Testing

- Ran 3d_scene

---

## Migration Guide

`RenderCreation::Manual` variant fields are now wrapped in a struct
called `RenderResources`
@atlv24 atlv24 deleted the ad/cleanup-render branch July 23, 2025 23:46
github-merge-queue bot pushed a commit that referenced this pull request Jan 30, 2026
# Objective

- Another step towards render recovery after #22714 and #16481
- We need RenderResource unpacking to be reusable from a non-app context

## Solution

- Make it take main and render worlds as input
- Use subapp destructure to get mutable access to both worlds
simultaneously
- Move it to live next to the struct def
- Document
- Also move shader library loads up to build because theres no reason
for them to be in finish

## Testing

- 3d_scene runs

Note: reviewing commit by commit is easier, when a large block moves its
just copy paste
@atlv24 atlv24 mentioned this pull request Feb 1, 2026
github-merge-queue bot pushed a commit that referenced this pull request Feb 5, 2026
# Objective

- Recover from rendering errors.
- Another step towards render recovery after #22714 #22759 and #16481 

## Solution

- Use `wgpu::Device::set_device_lost_callback` and
`wgpu::Device::on_uncaptured_error` to listen for errors.
- Add a state machine for the renderer
- Update it on error
- Add a `RenderErrorHandler` to let users specify behavior on error by
returning a specific `RenderErrorPolicy`
- This lets us for example ignore validation errors, delete responsible
entities, or reload the renderer if the device was lost.

## Testing

- #22757 with any of
```rs
    .insert_resource(bevy_render::error_handler::RenderErrorHandler(|_, _, _| {
        bevy_render::error_handler::RenderErrorPolicy::StopRendering
    }))
```
```rs
    .insert_resource(bevy_render::error_handler::RenderErrorHandler(|_, _, _| {
        bevy_render::error_handler::RenderErrorPolicy::Recover(default())
    }))
```

Note: no release note yet, as recovery does not exactly work well: this
PR gets us to the point of being able to care about it, but we currently
instantly crash on recover due to gpu resources not existing anymore. We
need to build more resilience before publicizing imo.

---------

Co-authored-by: Kristoffer Søholm <k.soeholm@gmail.com>
github-merge-queue bot pushed a commit that referenced this pull request Mar 23, 2026
# Objective

- Completes goal and closes #23029
- Culmination of #22761, #23350, #23349, #23433, #23458, #23444, #23459,
#23461, #23463, #22714, #22759, #16481

## Solution

- Add a release note.
- Re-export a wgpu type that you need to match on to handle errors.

## Testing

- cargo run --example render_recovery with all the other PRs merged in.
Press 5 and then V, the app will not crash. Note that D for "destroy
device" will still crash: this is a WGPU problem resolved by
gfx-rs/wgpu#9281.

# Note

I opted not to change the default recovery behavior yet. I believe we
need testing in user projects and just general trodding of this code
path before committing to a new default. It works in a simple example,
it might not work in a complex project. We need to field test this and
likely iterate to really call this ready IMO.
splo pushed a commit to splo/bevy that referenced this pull request Mar 31, 2026
# Objective

- Completes goal and closes bevyengine#23029
- Culmination of bevyengine#22761, bevyengine#23350, bevyengine#23349, bevyengine#23433, bevyengine#23458, bevyengine#23444, bevyengine#23459,
bevyengine#23461, bevyengine#23463, bevyengine#22714, bevyengine#22759, bevyengine#16481

## Solution

- Add a release note.
- Re-export a wgpu type that you need to match on to handle errors.

## Testing

- cargo run --example render_recovery with all the other PRs merged in.
Press 5 and then V, the app will not crash. Note that D for "destroy
device" will still crash: this is a WGPU problem resolved by
gfx-rs/wgpu#9281.

# Note

I opted not to change the default recovery behavior yet. I believe we
need testing in user projects and just general trodding of this code
path before committing to a new default. It works in a simple example,
it might not work in a complex project. We need to field test this and
likely iterate to really call this ready IMO.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Rendering Drawing game state to the screen C-Code-Quality A section of code that is hard to understand or change D-Straightforward Simple bug fixes and API improvements, docs, test and examples M-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants