tessera_ui/
pipeline_context.rs1use crate::{
4 ComputablePipeline, ComputeCommand, DrawCommand, DrawablePipeline,
5 renderer::{RenderCore, RenderResources},
6};
7
8pub struct PipelineContext<'a> {
10 core: &'a mut RenderCore,
11}
12
13impl<'a> PipelineContext<'a> {
14 pub fn graphics(&self) -> &crate::GraphicsDevice {
16 self.core.resources().graphics
17 }
18 pub(crate) fn new(core: &'a mut RenderCore) -> Self {
20 Self { core }
21 }
22
23 pub fn resources(&self) -> RenderResources<'_> {
25 self.core.resources()
26 }
27
28 pub fn register_draw_pipeline<T, P>(&mut self, pipeline: P)
30 where
31 T: DrawCommand + 'static,
32 P: DrawablePipeline<T> + 'static,
33 {
34 self.core.register_draw_pipeline(pipeline);
35 }
36
37 pub fn register_compute_pipeline<T, P>(&mut self, pipeline: P)
39 where
40 T: ComputeCommand + 'static,
41 P: ComputablePipeline<T> + 'static,
42 {
43 self.core.register_compute_pipeline(pipeline);
44 }
45
46 pub fn register_draw_pipeline_factory<T, P>(
48 &mut self,
49 factory: impl FnOnce(RenderResources<'_>) -> P + Send + 'static,
50 ) where
51 T: DrawCommand + 'static,
52 P: DrawablePipeline<T> + 'static,
53 {
54 self.core.register_draw_pipeline_factory(factory);
55 }
56
57 pub fn register_compute_pipeline_factory<T, P>(
59 &mut self,
60 factory: impl FnOnce(RenderResources<'_>) -> P + Send + 'static,
61 ) where
62 T: ComputeCommand + 'static,
63 P: ComputablePipeline<T> + 'static,
64 {
65 self.core.register_compute_pipeline_factory(factory);
66 }
67}