Update render graph docs (#13495)

# Objective

I'm reading some of the rendering code for the first time; and using
this opportunity to flesh out some docs for the parts that I did not
understand.
rather than a questionable design choice is not a breaking change.

---------

Co-authored-by: BD103 <59022059+BD103@users.noreply.github.com>
This commit is contained in:
Periwink 2024-05-24 17:57:08 -04:00 committed by GitHub
parent b2b356f462
commit d87505899f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 19 additions and 3 deletions

View File

@ -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.

View File

@ -22,11 +22,12 @@ define_label!(
/// A shorthand for `Interned<dyn RenderSubGraph>`.
pub type InternedRenderSubGraph = Interned<dyn RenderSubGraph>;
/// 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).

View File

@ -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<InternedRenderSubGraph>,

View File

@ -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,
) -> (