tessera_ui/
pipeline_context.rs

1//! Pipeline registration context for renderer initialization
2
3use crate::{
4    CompositeCommand, ComputablePipeline, ComputeCommand, DrawCommand, DrawablePipeline,
5    renderer::{RenderCore, RenderResources, composite::CompositePipeline},
6};
7
8/// Context passed to pipeline initialization functions.
9pub struct PipelineContext<'a> {
10    core: &'a mut RenderCore,
11}
12
13impl<'a> PipelineContext<'a> {
14    /// Creates a new pipeline context for the given renderer app.
15    pub(crate) fn new(core: &'a mut RenderCore) -> Self {
16        Self { core }
17    }
18
19    /// Returns shared GPU resources used for pipeline creation.
20    pub fn resources(&self) -> RenderResources<'_> {
21        self.core.resources()
22    }
23
24    /// Registers a draw pipeline for a specific command type.
25    pub fn register_draw_pipeline<T, P>(&mut self, pipeline: P)
26    where
27        T: DrawCommand + 'static,
28        P: DrawablePipeline<T> + 'static,
29    {
30        self.core.register_draw_pipeline(pipeline);
31    }
32
33    /// Registers a compute pipeline for a specific command type.
34    pub fn register_compute_pipeline<T, P>(&mut self, pipeline: P)
35    where
36        T: ComputeCommand + 'static,
37        P: ComputablePipeline<T> + 'static,
38    {
39        self.core.register_compute_pipeline(pipeline);
40    }
41
42    /// Registers a composite pipeline for a specific command type.
43    pub fn register_composite_pipeline<T, P>(&mut self, pipeline: P)
44    where
45        T: CompositeCommand + 'static,
46        P: CompositePipeline<T> + 'static,
47    {
48        self.core.register_composite_pipeline(pipeline);
49    }
50}