From f95f42b44a481a30cde63ef6dcfe690f08ab9399 Mon Sep 17 00:00:00 2001 From: andriyDev Date: Wed, 2 Jul 2025 07:56:18 -0700 Subject: [PATCH] Allow calling `add_render_graph_node` on `World`. (#19912) # Objective - This unblocks some work I am doing for #19887. ## Solution - Rename `RenderGraphApp` to `RenderGraphExt`. - Implement `RenderGraphExt` for `World`. - Change `SubApp` and `App` to call the `World` impl. --- .../src/contrast_adaptive_sharpening/mod.rs | 2 +- crates/bevy_anti_aliasing/src/fxaa/mod.rs | 2 +- crates/bevy_anti_aliasing/src/smaa/mod.rs | 2 +- crates/bevy_anti_aliasing/src/taa/mod.rs | 2 +- .../src/auto_exposure/mod.rs | 2 +- crates/bevy_core_pipeline/src/bloom/mod.rs | 2 +- crates/bevy_core_pipeline/src/core_2d/mod.rs | 2 +- crates/bevy_core_pipeline/src/core_3d/mod.rs | 2 +- crates/bevy_core_pipeline/src/dof/mod.rs | 2 +- .../src/experimental/mip_generation/mod.rs | 2 +- .../bevy_core_pipeline/src/motion_blur/mod.rs | 2 +- .../bevy_core_pipeline/src/msaa_writeback.rs | 2 +- crates/bevy_core_pipeline/src/oit/mod.rs | 2 +- .../src/post_process/mod.rs | 2 +- crates/bevy_pbr/src/atmosphere/mod.rs | 2 +- crates/bevy_pbr/src/deferred/mod.rs | 2 +- crates/bevy_pbr/src/meshlet/mod.rs | 2 +- crates/bevy_pbr/src/render/gpu_preprocess.rs | 2 +- crates/bevy_pbr/src/ssao/mod.rs | 2 +- crates/bevy_pbr/src/ssr/mod.rs | 2 +- crates/bevy_pbr/src/volumetric_fog/mod.rs | 2 +- crates/bevy_pbr/src/wireframe.rs | 2 +- crates/bevy_render/src/render_graph/app.rs | 61 +++++++++++++++---- crates/bevy_solari/src/pathtracer/mod.rs | 2 +- crates/bevy_solari/src/realtime/mod.rs | 2 +- crates/bevy_sprite/src/mesh2d/wireframe2d.rs | 2 +- examples/3d/occlusion_culling.rs | 2 +- examples/shader/custom_post_processing.rs | 2 +- examples/shader/custom_render_phase.rs | 2 +- .../render_graph_app_to_ext.md | 7 +++ 30 files changed, 83 insertions(+), 41 deletions(-) create mode 100644 release-content/migration-guides/render_graph_app_to_ext.md diff --git a/crates/bevy_anti_aliasing/src/contrast_adaptive_sharpening/mod.rs b/crates/bevy_anti_aliasing/src/contrast_adaptive_sharpening/mod.rs index d1de3f4cea..8ff94fba65 100644 --- a/crates/bevy_anti_aliasing/src/contrast_adaptive_sharpening/mod.rs +++ b/crates/bevy_anti_aliasing/src/contrast_adaptive_sharpening/mod.rs @@ -11,7 +11,7 @@ use bevy_reflect::{std_traits::ReflectDefault, Reflect}; use bevy_render::{ extract_component::{ExtractComponent, ExtractComponentPlugin, UniformComponentPlugin}, prelude::Camera, - render_graph::RenderGraphApp, + render_graph::RenderGraphExt, render_resource::{ binding_types::{sampler, texture_2d, uniform_buffer}, *, diff --git a/crates/bevy_anti_aliasing/src/fxaa/mod.rs b/crates/bevy_anti_aliasing/src/fxaa/mod.rs index adc2a3d5a2..065f6ebec1 100644 --- a/crates/bevy_anti_aliasing/src/fxaa/mod.rs +++ b/crates/bevy_anti_aliasing/src/fxaa/mod.rs @@ -11,7 +11,7 @@ use bevy_reflect::{std_traits::ReflectDefault, Reflect}; use bevy_render::{ extract_component::{ExtractComponent, ExtractComponentPlugin}, prelude::Camera, - render_graph::{RenderGraphApp, ViewNodeRunner}, + render_graph::{RenderGraphExt, ViewNodeRunner}, render_resource::{ binding_types::{sampler, texture_2d}, *, diff --git a/crates/bevy_anti_aliasing/src/smaa/mod.rs b/crates/bevy_anti_aliasing/src/smaa/mod.rs index bc6feca267..ea191cd28b 100644 --- a/crates/bevy_anti_aliasing/src/smaa/mod.rs +++ b/crates/bevy_anti_aliasing/src/smaa/mod.rs @@ -58,7 +58,7 @@ use bevy_render::{ extract_component::{ExtractComponent, ExtractComponentPlugin}, render_asset::RenderAssets, render_graph::{ - NodeRunError, RenderGraphApp as _, RenderGraphContext, ViewNode, ViewNodeRunner, + NodeRunError, RenderGraphContext, RenderGraphExt as _, ViewNode, ViewNodeRunner, }, render_resource::{ binding_types::{sampler, texture_2d, uniform_buffer}, diff --git a/crates/bevy_anti_aliasing/src/taa/mod.rs b/crates/bevy_anti_aliasing/src/taa/mod.rs index 442a268e2a..ee1af46d39 100644 --- a/crates/bevy_anti_aliasing/src/taa/mod.rs +++ b/crates/bevy_anti_aliasing/src/taa/mod.rs @@ -21,7 +21,7 @@ use bevy_reflect::{std_traits::ReflectDefault, Reflect}; use bevy_render::{ camera::{ExtractedCamera, MipBias, TemporalJitter}, prelude::{Camera, Projection}, - render_graph::{NodeRunError, RenderGraphApp, RenderGraphContext, ViewNode, ViewNodeRunner}, + render_graph::{NodeRunError, RenderGraphContext, RenderGraphExt, ViewNode, ViewNodeRunner}, render_resource::{ binding_types::{sampler, texture_2d, texture_depth_2d}, BindGroupEntries, BindGroupLayout, BindGroupLayoutEntries, CachedRenderPipelineId, diff --git a/crates/bevy_core_pipeline/src/auto_exposure/mod.rs b/crates/bevy_core_pipeline/src/auto_exposure/mod.rs index 172de3c393..7a33df99d8 100644 --- a/crates/bevy_core_pipeline/src/auto_exposure/mod.rs +++ b/crates/bevy_core_pipeline/src/auto_exposure/mod.rs @@ -4,7 +4,7 @@ use bevy_ecs::prelude::*; use bevy_render::{ extract_component::ExtractComponentPlugin, render_asset::RenderAssetPlugin, - render_graph::RenderGraphApp, + render_graph::RenderGraphExt, render_resource::{ Buffer, BufferDescriptor, BufferUsages, PipelineCache, SpecializedComputePipelines, }, diff --git a/crates/bevy_core_pipeline/src/bloom/mod.rs b/crates/bevy_core_pipeline/src/bloom/mod.rs index 901275e01c..d57af1cd01 100644 --- a/crates/bevy_core_pipeline/src/bloom/mod.rs +++ b/crates/bevy_core_pipeline/src/bloom/mod.rs @@ -20,7 +20,7 @@ use bevy_render::{ extract_component::{ ComponentUniforms, DynamicUniformIndex, ExtractComponentPlugin, UniformComponentPlugin, }, - render_graph::{NodeRunError, RenderGraphApp, RenderGraphContext, ViewNode, ViewNodeRunner}, + render_graph::{NodeRunError, RenderGraphContext, RenderGraphExt, ViewNode, ViewNodeRunner}, render_resource::*, renderer::{RenderContext, RenderDevice}, texture::{CachedTexture, TextureCache}, diff --git a/crates/bevy_core_pipeline/src/core_2d/mod.rs b/crates/bevy_core_pipeline/src/core_2d/mod.rs index 94232fbb05..f50d3e5984 100644 --- a/crates/bevy_core_pipeline/src/core_2d/mod.rs +++ b/crates/bevy_core_pipeline/src/core_2d/mod.rs @@ -52,7 +52,7 @@ use bevy_math::FloatOrd; use bevy_render::{ camera::{Camera, ExtractedCamera}, extract_component::ExtractComponentPlugin, - render_graph::{EmptyNode, RenderGraphApp, ViewNodeRunner}, + render_graph::{EmptyNode, RenderGraphExt, ViewNodeRunner}, render_phase::{ sort_phase_system, BinnedPhaseItem, CachedRenderPipelinePhaseItem, DrawFunctionId, DrawFunctions, PhaseItem, PhaseItemExtraIndex, SortedPhaseItem, ViewBinnedRenderPhases, diff --git a/crates/bevy_core_pipeline/src/core_3d/mod.rs b/crates/bevy_core_pipeline/src/core_3d/mod.rs index 2fc7e80a5e..3a127631cc 100644 --- a/crates/bevy_core_pipeline/src/core_3d/mod.rs +++ b/crates/bevy_core_pipeline/src/core_3d/mod.rs @@ -92,7 +92,7 @@ use bevy_render::{ camera::{Camera, ExtractedCamera}, extract_component::ExtractComponentPlugin, prelude::Msaa, - render_graph::{EmptyNode, RenderGraphApp, ViewNodeRunner}, + render_graph::{EmptyNode, RenderGraphExt, ViewNodeRunner}, render_phase::{ sort_phase_system, BinnedPhaseItem, CachedRenderPipelinePhaseItem, DrawFunctionId, DrawFunctions, PhaseItem, PhaseItemExtraIndex, SortedPhaseItem, ViewBinnedRenderPhases, diff --git a/crates/bevy_core_pipeline/src/dof/mod.rs b/crates/bevy_core_pipeline/src/dof/mod.rs index 7e2f52e3fc..b47ba61eb0 100644 --- a/crates/bevy_core_pipeline/src/dof/mod.rs +++ b/crates/bevy_core_pipeline/src/dof/mod.rs @@ -34,7 +34,7 @@ use bevy_render::{ camera::{PhysicalCameraParameters, Projection}, extract_component::{ComponentUniforms, DynamicUniformIndex, UniformComponentPlugin}, render_graph::{ - NodeRunError, RenderGraphApp as _, RenderGraphContext, ViewNode, ViewNodeRunner, + NodeRunError, RenderGraphContext, RenderGraphExt as _, ViewNode, ViewNodeRunner, }, render_resource::{ binding_types::{ diff --git a/crates/bevy_core_pipeline/src/experimental/mip_generation/mod.rs b/crates/bevy_core_pipeline/src/experimental/mip_generation/mod.rs index 8bd7d92393..e420438d9a 100644 --- a/crates/bevy_core_pipeline/src/experimental/mip_generation/mod.rs +++ b/crates/bevy_core_pipeline/src/experimental/mip_generation/mod.rs @@ -30,7 +30,7 @@ use bevy_render::{ experimental::occlusion_culling::{ OcclusionCulling, OcclusionCullingSubview, OcclusionCullingSubviewEntities, }, - render_graph::{Node, NodeRunError, RenderGraphApp, RenderGraphContext}, + render_graph::{Node, NodeRunError, RenderGraphContext, RenderGraphExt}, render_resource::{ binding_types::{sampler, texture_2d, texture_2d_multisampled, texture_storage_2d}, BindGroup, BindGroupEntries, BindGroupLayout, BindGroupLayoutEntries, diff --git a/crates/bevy_core_pipeline/src/motion_blur/mod.rs b/crates/bevy_core_pipeline/src/motion_blur/mod.rs index ecf6432c9f..a2b44704f6 100644 --- a/crates/bevy_core_pipeline/src/motion_blur/mod.rs +++ b/crates/bevy_core_pipeline/src/motion_blur/mod.rs @@ -18,7 +18,7 @@ use bevy_reflect::{std_traits::ReflectDefault, Reflect}; use bevy_render::{ camera::Camera, extract_component::{ExtractComponent, ExtractComponentPlugin, UniformComponentPlugin}, - render_graph::{RenderGraphApp, ViewNodeRunner}, + render_graph::{RenderGraphExt, ViewNodeRunner}, render_resource::{ShaderType, SpecializedRenderPipelines}, Render, RenderApp, RenderSystems, }; diff --git a/crates/bevy_core_pipeline/src/msaa_writeback.rs b/crates/bevy_core_pipeline/src/msaa_writeback.rs index 5f82e10599..93116dc9fd 100644 --- a/crates/bevy_core_pipeline/src/msaa_writeback.rs +++ b/crates/bevy_core_pipeline/src/msaa_writeback.rs @@ -8,7 +8,7 @@ use bevy_color::LinearRgba; use bevy_ecs::{prelude::*, query::QueryItem}; use bevy_render::{ camera::ExtractedCamera, - render_graph::{NodeRunError, RenderGraphApp, RenderGraphContext, ViewNode, ViewNodeRunner}, + render_graph::{NodeRunError, RenderGraphContext, RenderGraphExt, ViewNode, ViewNodeRunner}, render_resource::*, renderer::RenderContext, view::{Msaa, ViewTarget}, diff --git a/crates/bevy_core_pipeline/src/oit/mod.rs b/crates/bevy_core_pipeline/src/oit/mod.rs index 5b5d038fa0..088d491c75 100644 --- a/crates/bevy_core_pipeline/src/oit/mod.rs +++ b/crates/bevy_core_pipeline/src/oit/mod.rs @@ -10,7 +10,7 @@ use bevy_render::{ camera::{Camera, ExtractedCamera}, extract_component::{ExtractComponent, ExtractComponentPlugin}, load_shader_library, - render_graph::{RenderGraphApp, ViewNodeRunner}, + render_graph::{RenderGraphExt, ViewNodeRunner}, render_resource::{BufferUsages, BufferVec, DynamicUniformBuffer, ShaderType, TextureUsages}, renderer::{RenderDevice, RenderQueue}, view::Msaa, diff --git a/crates/bevy_core_pipeline/src/post_process/mod.rs b/crates/bevy_core_pipeline/src/post_process/mod.rs index 350ee1cfdd..b76af1b935 100644 --- a/crates/bevy_core_pipeline/src/post_process/mod.rs +++ b/crates/bevy_core_pipeline/src/post_process/mod.rs @@ -23,7 +23,7 @@ use bevy_render::{ load_shader_library, render_asset::{RenderAssetUsages, RenderAssets}, render_graph::{ - NodeRunError, RenderGraphApp as _, RenderGraphContext, ViewNode, ViewNodeRunner, + NodeRunError, RenderGraphContext, RenderGraphExt as _, ViewNode, ViewNodeRunner, }, render_resource::{ binding_types::{sampler, texture_2d, uniform_buffer}, diff --git a/crates/bevy_pbr/src/atmosphere/mod.rs b/crates/bevy_pbr/src/atmosphere/mod.rs index a55403630a..ed4dabdf96 100644 --- a/crates/bevy_pbr/src/atmosphere/mod.rs +++ b/crates/bevy_pbr/src/atmosphere/mod.rs @@ -55,7 +55,7 @@ use bevy_render::{ }; use bevy_render::{ extract_component::{ExtractComponent, ExtractComponentPlugin}, - render_graph::{RenderGraphApp, ViewNodeRunner}, + render_graph::{RenderGraphExt, ViewNodeRunner}, render_resource::{TextureFormat, TextureUsages}, renderer::RenderAdapter, Render, RenderApp, RenderSystems, diff --git a/crates/bevy_pbr/src/deferred/mod.rs b/crates/bevy_pbr/src/deferred/mod.rs index b8f3a660c0..d021dc5d7e 100644 --- a/crates/bevy_pbr/src/deferred/mod.rs +++ b/crates/bevy_pbr/src/deferred/mod.rs @@ -25,7 +25,7 @@ use bevy_render::{ extract_component::{ ComponentUniforms, ExtractComponent, ExtractComponentPlugin, UniformComponentPlugin, }, - render_graph::{NodeRunError, RenderGraphApp, RenderGraphContext, ViewNode, ViewNodeRunner}, + render_graph::{NodeRunError, RenderGraphContext, RenderGraphExt, ViewNode, ViewNodeRunner}, render_resource::{binding_types::uniform_buffer, *}, renderer::{RenderContext, RenderDevice}, view::{ExtractedView, ViewTarget, ViewUniformOffset}, diff --git a/crates/bevy_pbr/src/meshlet/mod.rs b/crates/bevy_pbr/src/meshlet/mod.rs index 237ff9aa1b..94b623a280 100644 --- a/crates/bevy_pbr/src/meshlet/mod.rs +++ b/crates/bevy_pbr/src/meshlet/mod.rs @@ -75,7 +75,7 @@ use bevy_ecs::{ use bevy_reflect::{std_traits::ReflectDefault, Reflect}; use bevy_render::{ load_shader_library, - render_graph::{RenderGraphApp, ViewNodeRunner}, + render_graph::{RenderGraphExt, ViewNodeRunner}, renderer::RenderDevice, settings::WgpuFeatures, view::{self, prepare_view_targets, Msaa, Visibility, VisibilityClass}, diff --git a/crates/bevy_pbr/src/render/gpu_preprocess.rs b/crates/bevy_pbr/src/render/gpu_preprocess.rs index eaa7e857b7..ae3e322164 100644 --- a/crates/bevy_pbr/src/render/gpu_preprocess.rs +++ b/crates/bevy_pbr/src/render/gpu_preprocess.rs @@ -38,7 +38,7 @@ use bevy_render::{ UntypedPhaseBatchedInstanceBuffers, }, experimental::occlusion_culling::OcclusionCulling, - render_graph::{Node, NodeRunError, RenderGraphApp, RenderGraphContext}, + render_graph::{Node, NodeRunError, RenderGraphContext, RenderGraphExt}, render_resource::{ binding_types::{storage_buffer, storage_buffer_read_only, texture_2d, uniform_buffer}, BindGroup, BindGroupEntries, BindGroupLayout, BindingResource, Buffer, BufferBinding, diff --git a/crates/bevy_pbr/src/ssao/mod.rs b/crates/bevy_pbr/src/ssao/mod.rs index 7d56495605..a6a974d5cc 100644 --- a/crates/bevy_pbr/src/ssao/mod.rs +++ b/crates/bevy_pbr/src/ssao/mod.rs @@ -23,7 +23,7 @@ use bevy_render::{ globals::{GlobalsBuffer, GlobalsUniform}, load_shader_library, prelude::Camera, - render_graph::{NodeRunError, RenderGraphApp, RenderGraphContext, ViewNode, ViewNodeRunner}, + render_graph::{NodeRunError, RenderGraphContext, RenderGraphExt, ViewNode, ViewNodeRunner}, render_resource::{ binding_types::{ sampler, texture_2d, texture_depth_2d, texture_storage_2d, uniform_buffer, diff --git a/crates/bevy_pbr/src/ssr/mod.rs b/crates/bevy_pbr/src/ssr/mod.rs index f3d876ffde..7ddbe33919 100644 --- a/crates/bevy_pbr/src/ssr/mod.rs +++ b/crates/bevy_pbr/src/ssr/mod.rs @@ -25,7 +25,7 @@ use bevy_image::BevyDefault as _; use bevy_reflect::{std_traits::ReflectDefault, Reflect}; use bevy_render::{ extract_component::{ExtractComponent, ExtractComponentPlugin}, - render_graph::{NodeRunError, RenderGraphApp, RenderGraphContext, ViewNode, ViewNodeRunner}, + render_graph::{NodeRunError, RenderGraphContext, RenderGraphExt, ViewNode, ViewNodeRunner}, render_resource::{ binding_types, AddressMode, BindGroupEntries, BindGroupLayout, BindGroupLayoutEntries, CachedRenderPipelineId, ColorTargetState, ColorWrites, DynamicUniformBuffer, FilterMode, diff --git a/crates/bevy_pbr/src/volumetric_fog/mod.rs b/crates/bevy_pbr/src/volumetric_fog/mod.rs index efc3c5370a..c9f1f230c6 100644 --- a/crates/bevy_pbr/src/volumetric_fog/mod.rs +++ b/crates/bevy_pbr/src/volumetric_fog/mod.rs @@ -47,7 +47,7 @@ use bevy_math::{ use bevy_reflect::{std_traits::ReflectDefault, Reflect}; use bevy_render::{ mesh::{Mesh, Meshable}, - render_graph::{RenderGraphApp, ViewNodeRunner}, + render_graph::{RenderGraphExt, ViewNodeRunner}, render_resource::SpecializedRenderPipelines, sync_component::SyncComponentPlugin, view::Visibility, diff --git a/crates/bevy_pbr/src/wireframe.rs b/crates/bevy_pbr/src/wireframe.rs index f7c193161d..9cf3bc08dd 100644 --- a/crates/bevy_pbr/src/wireframe.rs +++ b/crates/bevy_pbr/src/wireframe.rs @@ -38,7 +38,7 @@ use bevy_render::{ render_asset::{ prepare_assets, PrepareAssetError, RenderAsset, RenderAssetPlugin, RenderAssets, }, - render_graph::{NodeRunError, RenderGraphApp, RenderGraphContext, ViewNode, ViewNodeRunner}, + render_graph::{NodeRunError, RenderGraphContext, RenderGraphExt, ViewNode, ViewNodeRunner}, render_phase::{ AddRenderCommand, BinnedPhaseItem, BinnedRenderPhasePlugin, BinnedRenderPhaseType, CachedRenderPipelinePhaseItem, DrawFunctionId, DrawFunctions, PhaseItem, diff --git a/crates/bevy_render/src/render_graph/app.rs b/crates/bevy_render/src/render_graph/app.rs index 338ae75d7a..fce6a13ad3 100644 --- a/crates/bevy_render/src/render_graph/app.rs +++ b/crates/bevy_render/src/render_graph/app.rs @@ -1,11 +1,11 @@ use bevy_app::{App, SubApp}; -use bevy_ecs::world::FromWorld; +use bevy_ecs::world::{FromWorld, World}; use tracing::warn; use super::{IntoRenderNodeArray, Node, RenderGraph, RenderLabel, RenderSubGraph}; /// Adds common [`RenderGraph`] operations to [`SubApp`] (and [`App`]). -pub trait RenderGraphApp { +pub trait RenderGraphExt { // Add a sub graph to the [`RenderGraph`] fn add_render_sub_graph(&mut self, sub_graph: impl RenderSubGraph) -> &mut Self; /// Add a [`Node`] to the [`RenderGraph`]: @@ -32,15 +32,15 @@ pub trait RenderGraphApp { ) -> &mut Self; } -impl RenderGraphApp for SubApp { +impl RenderGraphExt for World { fn add_render_graph_node( &mut self, sub_graph: impl RenderSubGraph, node_label: impl RenderLabel, ) -> &mut Self { let sub_graph = sub_graph.intern(); - let node = T::from_world(self.world_mut()); - let mut render_graph = self.world_mut().get_resource_mut::().expect( + let node = T::from_world(self); + let mut render_graph = self.get_resource_mut::().expect( "RenderGraph not found. Make sure you are using add_render_graph_node on the RenderApp", ); if let Some(graph) = render_graph.get_sub_graph_mut(sub_graph) { @@ -59,7 +59,7 @@ impl RenderGraphApp for SubApp { edges: impl IntoRenderNodeArray, ) -> &mut Self { let sub_graph = sub_graph.intern(); - let mut render_graph = self.world_mut().get_resource_mut::().expect( + let mut render_graph = self.get_resource_mut::().expect( "RenderGraph not found. Make sure you are using add_render_graph_edges on the RenderApp", ); if let Some(graph) = render_graph.get_sub_graph_mut(sub_graph) { @@ -79,7 +79,7 @@ impl RenderGraphApp for SubApp { input_node: impl RenderLabel, ) -> &mut Self { let sub_graph = sub_graph.intern(); - let mut render_graph = self.world_mut().get_resource_mut::().expect( + let mut render_graph = self.get_resource_mut::().expect( "RenderGraph not found. Make sure you are using add_render_graph_edge on the RenderApp", ); if let Some(graph) = render_graph.get_sub_graph_mut(sub_graph) { @@ -93,7 +93,7 @@ impl RenderGraphApp for SubApp { } fn add_render_sub_graph(&mut self, sub_graph: impl RenderSubGraph) -> &mut Self { - let mut render_graph = self.world_mut().get_resource_mut::().expect( + let mut render_graph = self.get_resource_mut::().expect( "RenderGraph not found. Make sure you are using add_render_sub_graph on the RenderApp", ); render_graph.add_sub_graph(sub_graph, RenderGraph::default()); @@ -101,13 +101,13 @@ impl RenderGraphApp for SubApp { } } -impl RenderGraphApp for App { +impl RenderGraphExt for SubApp { fn add_render_graph_node( &mut self, sub_graph: impl RenderSubGraph, node_label: impl RenderLabel, ) -> &mut Self { - SubApp::add_render_graph_node::(self.main_mut(), sub_graph, node_label); + World::add_render_graph_node::(self.world_mut(), sub_graph, node_label); self } @@ -117,7 +117,7 @@ impl RenderGraphApp for App { output_node: impl RenderLabel, input_node: impl RenderLabel, ) -> &mut Self { - SubApp::add_render_graph_edge(self.main_mut(), sub_graph, output_node, input_node); + World::add_render_graph_edge(self.world_mut(), sub_graph, output_node, input_node); self } @@ -126,12 +126,47 @@ impl RenderGraphApp for App { sub_graph: impl RenderSubGraph, edges: impl IntoRenderNodeArray, ) -> &mut Self { - SubApp::add_render_graph_edges(self.main_mut(), sub_graph, edges); + World::add_render_graph_edges(self.world_mut(), sub_graph, edges); self } fn add_render_sub_graph(&mut self, sub_graph: impl RenderSubGraph) -> &mut Self { - SubApp::add_render_sub_graph(self.main_mut(), sub_graph); + World::add_render_sub_graph(self.world_mut(), sub_graph); + self + } +} + +impl RenderGraphExt for App { + fn add_render_graph_node( + &mut self, + sub_graph: impl RenderSubGraph, + node_label: impl RenderLabel, + ) -> &mut Self { + World::add_render_graph_node::(self.world_mut(), sub_graph, node_label); + self + } + + fn add_render_graph_edge( + &mut self, + sub_graph: impl RenderSubGraph, + output_node: impl RenderLabel, + input_node: impl RenderLabel, + ) -> &mut Self { + World::add_render_graph_edge(self.world_mut(), sub_graph, output_node, input_node); + self + } + + fn add_render_graph_edges( + &mut self, + sub_graph: impl RenderSubGraph, + edges: impl IntoRenderNodeArray, + ) -> &mut Self { + World::add_render_graph_edges(self.world_mut(), sub_graph, edges); + self + } + + fn add_render_sub_graph(&mut self, sub_graph: impl RenderSubGraph) -> &mut Self { + World::add_render_sub_graph(self.world_mut(), sub_graph); self } } diff --git a/crates/bevy_solari/src/pathtracer/mod.rs b/crates/bevy_solari/src/pathtracer/mod.rs index 1e2cd95ed8..30cc15ba10 100644 --- a/crates/bevy_solari/src/pathtracer/mod.rs +++ b/crates/bevy_solari/src/pathtracer/mod.rs @@ -9,7 +9,7 @@ use bevy_core_pipeline::core_3d::graph::{Core3d, Node3d}; use bevy_ecs::{component::Component, reflect::ReflectComponent, schedule::IntoScheduleConfigs}; use bevy_reflect::{std_traits::ReflectDefault, Reflect}; use bevy_render::{ - render_graph::{RenderGraphApp, ViewNodeRunner}, + render_graph::{RenderGraphExt, ViewNodeRunner}, renderer::RenderDevice, view::Hdr, ExtractSchedule, Render, RenderApp, RenderSystems, diff --git a/crates/bevy_solari/src/realtime/mod.rs b/crates/bevy_solari/src/realtime/mod.rs index b6a8f27a31..a8d6235f30 100644 --- a/crates/bevy_solari/src/realtime/mod.rs +++ b/crates/bevy_solari/src/realtime/mod.rs @@ -13,7 +13,7 @@ use bevy_ecs::{component::Component, reflect::ReflectComponent, schedule::IntoSc use bevy_pbr::DefaultOpaqueRendererMethod; use bevy_reflect::{std_traits::ReflectDefault, Reflect}; use bevy_render::{ - render_graph::{RenderGraphApp, ViewNodeRunner}, + render_graph::{RenderGraphExt, ViewNodeRunner}, renderer::RenderDevice, view::Hdr, ExtractSchedule, Render, RenderApp, RenderSystems, diff --git a/crates/bevy_sprite/src/mesh2d/wireframe2d.rs b/crates/bevy_sprite/src/mesh2d/wireframe2d.rs index e30c5b1f6c..f71d8c63f7 100644 --- a/crates/bevy_sprite/src/mesh2d/wireframe2d.rs +++ b/crates/bevy_sprite/src/mesh2d/wireframe2d.rs @@ -36,7 +36,7 @@ use bevy_render::{ render_asset::{ prepare_assets, PrepareAssetError, RenderAsset, RenderAssetPlugin, RenderAssets, }, - render_graph::{NodeRunError, RenderGraphApp, RenderGraphContext, ViewNode, ViewNodeRunner}, + render_graph::{NodeRunError, RenderGraphContext, RenderGraphExt, ViewNode, ViewNodeRunner}, render_phase::{ AddRenderCommand, BinnedPhaseItem, BinnedRenderPhasePlugin, BinnedRenderPhaseType, CachedRenderPipelinePhaseItem, DrawFunctionId, DrawFunctions, InputUniformIndex, PhaseItem, diff --git a/examples/3d/occlusion_culling.rs b/examples/3d/occlusion_culling.rs index f0cdbffa2a..0783a28948 100644 --- a/examples/3d/occlusion_culling.rs +++ b/examples/3d/occlusion_culling.rs @@ -30,7 +30,7 @@ use bevy::{ IndirectParametersIndexed, }, experimental::occlusion_culling::OcclusionCulling, - render_graph::{self, NodeRunError, RenderGraphApp, RenderGraphContext, RenderLabel}, + render_graph::{self, NodeRunError, RenderGraphContext, RenderGraphExt, RenderLabel}, render_resource::{Buffer, BufferDescriptor, BufferUsages, MapMode}, renderer::{RenderContext, RenderDevice}, settings::WgpuFeatures, diff --git a/examples/shader/custom_post_processing.rs b/examples/shader/custom_post_processing.rs index a075dfbdc1..ea9fbed656 100644 --- a/examples/shader/custom_post_processing.rs +++ b/examples/shader/custom_post_processing.rs @@ -19,7 +19,7 @@ use bevy::{ UniformComponentPlugin, }, render_graph::{ - NodeRunError, RenderGraphApp, RenderGraphContext, RenderLabel, ViewNode, ViewNodeRunner, + NodeRunError, RenderGraphContext, RenderGraphExt, RenderLabel, ViewNode, ViewNodeRunner, }, render_resource::{ binding_types::{sampler, texture_2d, uniform_buffer}, diff --git a/examples/shader/custom_render_phase.rs b/examples/shader/custom_render_phase.rs index 30ef057429..b2b35b86c4 100644 --- a/examples/shader/custom_render_phase.rs +++ b/examples/shader/custom_render_phase.rs @@ -39,7 +39,7 @@ use bevy::{ mesh::{allocator::MeshAllocator, MeshVertexBufferLayoutRef, RenderMesh}, render_asset::RenderAssets, render_graph::{ - NodeRunError, RenderGraphApp, RenderGraphContext, RenderLabel, ViewNode, ViewNodeRunner, + NodeRunError, RenderGraphContext, RenderGraphExt, RenderLabel, ViewNode, ViewNodeRunner, }, render_phase::{ sort_phase_system, AddRenderCommand, CachedRenderPipelinePhaseItem, DrawFunctionId, diff --git a/release-content/migration-guides/render_graph_app_to_ext.md b/release-content/migration-guides/render_graph_app_to_ext.md new file mode 100644 index 0000000000..511e60ce05 --- /dev/null +++ b/release-content/migration-guides/render_graph_app_to_ext.md @@ -0,0 +1,7 @@ +--- +title: `RenderGraphApp` renamed to `RenderGraphExt`. +pull_requests: [19912] +--- + +`RenderGraphApp` has been renamed to `RenderGraphExt`. Rename this for cases where you are +explicitly importing this trait.