Skip to content

init_gpu_resource#23350

Open
atlv24 wants to merge 2 commits intobevyengine:mainfrom
atlv24:ad/rr-gpu-res
Open

init_gpu_resource#23350
atlv24 wants to merge 2 commits intobevyengine:mainfrom
atlv24:ad/rr-gpu-res

Conversation

@atlv24
Copy link
Contributor

@atlv24 atlv24 commented Mar 13, 2026

Objective

Solution

  • Add an extension trait to insert resources on RenderStartup using from_world
  • replace almost every usage of init_resource that holds anything derived from a RenderDevice with init_gpu_resource so that it may be reinitialized on recovery
  • Note: "almost every" because there is a handful of slightly more involved cases I will leave to a follow ups.

Testing

  • render recovery example still crashes, i have a branch with it working that i am just pulling out reviewable bits from
  • we should also verify that this doesnt break examples, as it does slightly modify behavior: gpu resources are initialized slightly later than they used to be, because they wait until RenderStartup instead of doing it immediately.
  • i mostly want to get the largest part of the change out of the way first

@IQuick143 IQuick143 added A-Rendering Drawing game state to the screen D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Needs-Review Needs reviewer attention (from anyone!) to move forward S-Needs-Testing Testing must be done before this is safe to merge labels Mar 13, 2026
@github-project-automation github-project-automation bot moved this to Needs SME Triage in Rendering Mar 13, 2026
@IQuick143 IQuick143 self-requested a review March 13, 2026 08:47

impl FromWorld for DiagnosticsRecorder {
fn from_world(world: &mut World) -> Self {
DiagnosticsRecorder::new(world.resource(), world.resource(), world.resource())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this get called and fail?

/// ```ignore
/// app.add_systems(RenderStartup, init_gpu_resource::<T>);
/// ```
fn init_gpu_resource<T: Resource + FromWorld>(&mut self) -> &mut Self;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a usage-driven docstring might be helpful?
Something like copying in "Use this for initializing render resources in a render-recovery-aware way."

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 D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Needs-Review Needs reviewer attention (from anyone!) to move forward S-Needs-Testing Testing must be done before this is safe to merge

Projects

Status: Needs SME Triage

Development

Successfully merging this pull request may close these issues.

2 participants