pub struct RenderGraph { /* private fields */ }Expand description
Linear chain of render nodes executed in insertion order.
The CPU fallback path (process_cpu) is always
available and does not require the wgpu feature. When the wgpu feature
is enabled, process_gpu runs every node on the GPU.
§Construction
// GPU+CPU graph (wgpu feature):
let ctx = Arc::new(RenderContext::init().await?);
let graph = RenderGraph::new(Arc::clone(&ctx))
.push(ColorGradeNode { brightness: 0.1, ..Default::default() });
// CPU-only graph (no wgpu feature needed):
let graph = RenderGraph::new_cpu()
.push_cpu(ColorGradeNode { brightness: 0.1, ..Default::default() });Implementations§
Source§impl RenderGraph
impl RenderGraph
Sourcepub fn new(ctx: Arc<RenderContext>) -> Self
pub fn new(ctx: Arc<RenderContext>) -> Self
Create a GPU+CPU graph.
Nodes added via push run on the GPU and expose a CPU
fallback via RenderNodeCpu. Nodes added via
push_cpu run on the CPU path only.
Sourcepub fn new_cpu() -> Self
pub fn new_cpu() -> Self
Create a CPU-only graph (no GPU context required).
process_gpu returns RenderError::Composite
when called on a CPU-only graph. Use process_cpu
instead.
Sourcepub fn push(self, node: impl RenderNode + 'static) -> Self
pub fn push(self, node: impl RenderNode + 'static) -> Self
Append a GPU+CPU node to the chain.
The node must implement both RenderNode (GPU, wgpu feature only)
and RenderNodeCpu (CPU, always available) — the RenderNode
supertrait bound guarantees this.
Sourcepub fn push_cpu(self, node: impl RenderNodeCpu + 'static) -> Self
pub fn push_cpu(self, node: impl RenderNodeCpu + 'static) -> Self
Append a CPU-only node (available regardless of the wgpu feature).
Sourcepub fn process_gpu(
&self,
rgba: &[u8],
w: u32,
h: u32,
) -> Result<Vec<u8>, RenderError>
pub fn process_gpu( &self, rgba: &[u8], w: u32, h: u32, ) -> Result<Vec<u8>, RenderError>
Run the GPU pipeline: upload rgba → execute all GPU nodes → download result.
Requires the wgpu feature and a GPU context (created via new).
Returns RenderError::Composite if called on a CPU-only graph.
§Errors
Returns an error on GPU device failure or staging-buffer readback failure.