diff --git a/crates/bevy_render/src/render_graph/context.rs b/crates/bevy_render/src/render_graph/context.rs index f1926f4acf..1ba2009244 100644 --- a/crates/bevy_render/src/render_graph/context.rs +++ b/crates/bevy_render/src/render_graph/context.rs @@ -17,7 +17,7 @@ pub struct RunSubGraph { } /// The context with all graph information required to run a [`Node`](super::Node). -/// This context is created for each node by the `RenderGraphRunner`. +/// This context is created for each node by the [`RenderGraphRunner`](crate::renderer::graph_runner::RenderGraphRunner). /// /// The slot input can be read from here and the outputs must be written back to the context for /// passing them onto the next node. diff --git a/crates/bevy_render/src/render_graph/graph.rs b/crates/bevy_render/src/render_graph/graph.rs index a919ba4930..178c5a4cbb 100644 --- a/crates/bevy_render/src/render_graph/graph.rs +++ b/crates/bevy_render/src/render_graph/graph.rs @@ -22,11 +22,12 @@ define_label!( /// A shorthand for `Interned`. pub type InternedRenderSubGraph = Interned; -/// The render graph configures the modular, parallel and re-usable render logic. +/// The render graph configures the modular and re-usable render logic. /// It is a retained and stateless (nodes themselves may have their own internal state) structure, /// which can not be modified while it is executed by the graph runner. /// -/// The `RenderGraphRunner` is responsible for executing the entire graph each frame. +/// The [`RenderGraphRunner`](crate::renderer::graph_runner::RenderGraphRunner) is responsible for executing the entire graph each frame. +/// It will execute each node in the graph in the correct order, based on the edges between the nodes. /// /// It consists of three main components: [`Nodes`](Node), [`Edges`](Edge) /// and [`Slots`](super::SlotType). diff --git a/crates/bevy_render/src/renderer/graph_runner.rs b/crates/bevy_render/src/renderer/graph_runner.rs index 2023ab326e..1a50f70572 100644 --- a/crates/bevy_render/src/renderer/graph_runner.rs +++ b/crates/bevy_render/src/renderer/graph_runner.rs @@ -16,6 +16,17 @@ use crate::{ renderer::{RenderContext, RenderDevice}, }; +/// The [`RenderGraphRunner`] is responsible for executing a [`RenderGraph`]. +/// +/// It will run all nodes in the graph sequentially in the correct order (defined by the edges). +/// Each [`Node`](crate::render_graph::node::Node) can run any arbitrary code, but will generally +/// either send directly a [`CommandBuffer`] or a task that will asynchronously generate a [`CommandBuffer`] +/// +/// After running the graph, the [`RenderGraphRunner`] will execute in parallel all the tasks to get +/// an ordered list of [`CommandBuffer`]s to execute. These [`CommandBuffer`] will be submitted to the GPU +/// sequentially in the order that the tasks were submitted. (which is the order of the [`RenderGraph`]) +/// +/// [`CommandBuffer`]: wgpu::CommandBuffer pub(crate) struct RenderGraphRunner; #[derive(Error, Debug)] @@ -90,6 +101,8 @@ impl RenderGraphRunner { Ok(diagnostics_recorder) } + /// Runs the [`RenderGraph`] and all its sub-graphs sequentially, making sure that all nodes are + /// run in the correct order. (a node only runs when all its dependencies have finished running) fn run_graph<'w>( graph: &RenderGraph, sub_graph: Option, diff --git a/crates/bevy_render/src/renderer/mod.rs b/crates/bevy_render/src/renderer/mod.rs index 23ad14c136..e4ed46f9b8 100644 --- a/crates/bevy_render/src/renderer/mod.rs +++ b/crates/bevy_render/src/renderer/mod.rs @@ -458,6 +458,8 @@ impl<'w> RenderContext<'w> { /// /// This function will wait until all command buffer generation tasks are complete /// by running them in parallel (where supported). + /// + /// The [`CommandBuffer`]s will be returned in the order that they were added. pub fn finish( mut self, ) -> (