alpha2_render/
pipeline.rs1use std::sync::OnceLock;
2
3#[derive(Copy, Clone, Debug, Default, Eq, PartialEq)]
5pub struct PipelineCacheStats {
6 pub runtime_effects: usize,
8 pub builtins: usize,
10}
11
12#[derive(Copy, Clone, Debug, Default, Eq, PartialEq)]
14pub struct WarmupReport {
15 pub runtime_effects: usize,
17 pub builtins: usize,
19}
20
21#[derive(Debug, Default)]
22pub(crate) struct PipelineCache {
23 pub(crate) composite: OnceLock<CachedCompositePipeline>,
24 pub(crate) quad: OnceLock<CachedPipeline>,
25 pub(crate) readback_pack: OnceLock<CachedPipeline>,
26 pub(crate) rgba_present: OnceLock<CachedSampledPipeline>,
27 pub(crate) yuv_readback: OnceLock<CachedYuvReadbackPipeline>,
28 pub(crate) yuv: OnceLock<CachedYuvPipeline>,
29 pub(crate) yuv16: OnceLock<CachedYuvPipeline>,
30 pub(crate) yuv_repack: OnceLock<CachedYuvRepackPipeline>,
31 pub(crate) vector: OnceLock<crate::vector::CachedVectorPipeline>,
32}
33
34#[derive(Debug)]
35pub(crate) struct CachedPipeline {
36 pub(crate) bind_group_layout: wgpu::BindGroupLayout,
37 pub(crate) pipeline: wgpu::RenderPipeline,
38}
39
40#[derive(Debug)]
41pub(crate) struct CachedYuvPipeline {
42 pub(crate) bind_group_layout: wgpu::BindGroupLayout,
43 pub(crate) pipeline: wgpu::RenderPipeline,
44 pub(crate) sampler: wgpu::Sampler,
45}
46
47#[derive(Debug)]
48pub(crate) struct CachedSampledPipeline {
49 pub(crate) bind_group_layout: wgpu::BindGroupLayout,
50 pub(crate) pipeline: wgpu::RenderPipeline,
51 pub(crate) sampler: wgpu::Sampler,
52}
53
54#[derive(Debug)]
55pub(crate) struct CachedCompositePipeline {
56 pub(crate) bind_group_layout: wgpu::BindGroupLayout,
57 pub(crate) sampler: wgpu::Sampler,
58 pub(crate) shader: wgpu::ShaderModule,
59 pub(crate) programs: [std::sync::OnceLock<wgpu::RenderPipeline>; 2],
64}
65
66#[derive(Debug)]
67pub(crate) struct CachedYuvReadbackPipeline {
68 pub(crate) bind_group_layout: wgpu::BindGroupLayout,
69 pub(crate) y_pipeline: wgpu::RenderPipeline,
70 pub(crate) uv_pipeline: wgpu::RenderPipeline,
71 pub(crate) uv_nv12_pipeline: wgpu::RenderPipeline,
74}
75
76#[derive(Debug)]
78pub(crate) struct CachedYuvRepackPipeline {
79 pub(crate) bind_group_layout: wgpu::BindGroupLayout,
80 pub(crate) luma: wgpu::RenderPipeline,
82 pub(crate) interleaved_chroma: wgpu::RenderPipeline,
84 pub(crate) planar_chroma: wgpu::RenderPipeline,
86}
87
88impl PipelineCache {
89 pub(crate) fn builtin_count(&self) -> usize {
90 usize::from(self.composite.get().is_some())
91 + [&self.quad]
92 .into_iter()
93 .filter(|pipeline| pipeline.get().is_some())
94 .count()
95 + usize::from(self.yuv.get().is_some())
96 + usize::from(self.yuv16.get().is_some())
97 + usize::from(self.rgba_present.get().is_some())
98 + usize::from(self.readback_pack.get().is_some())
99 + usize::from(self.yuv_readback.get().is_some())
100 + usize::from(self.yuv_repack.get().is_some())
101 + self
102 .vector
103 .get()
104 .map_or(0, crate::vector::CachedVectorPipeline::pipeline_count)
105 }
106}