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}
32
33#[derive(Debug)]
34pub(crate) struct CachedPipeline {
35 pub(crate) bind_group_layout: wgpu::BindGroupLayout,
36 pub(crate) pipeline: wgpu::RenderPipeline,
37}
38
39#[derive(Debug)]
40pub(crate) struct CachedYuvPipeline {
41 pub(crate) bind_group_layout: wgpu::BindGroupLayout,
42 pub(crate) pipeline: wgpu::RenderPipeline,
43 pub(crate) sampler: wgpu::Sampler,
44}
45
46#[derive(Debug)]
47pub(crate) struct CachedSampledPipeline {
48 pub(crate) bind_group_layout: wgpu::BindGroupLayout,
49 pub(crate) pipeline: wgpu::RenderPipeline,
50 pub(crate) sampler: wgpu::Sampler,
51}
52
53#[derive(Debug)]
54pub(crate) struct CachedCompositePipeline {
55 pub(crate) bind_group_layout: wgpu::BindGroupLayout,
56 pub(crate) sampler: wgpu::Sampler,
57 pub(crate) shader: wgpu::ShaderModule,
58 pub(crate) programs: [std::sync::OnceLock<wgpu::RenderPipeline>; 2],
63}
64
65#[derive(Debug)]
66pub(crate) struct CachedYuvReadbackPipeline {
67 pub(crate) bind_group_layout: wgpu::BindGroupLayout,
68 pub(crate) y_pipeline: wgpu::RenderPipeline,
69 pub(crate) uv_pipeline: wgpu::RenderPipeline,
70 pub(crate) uv_nv12_pipeline: wgpu::RenderPipeline,
73}
74
75#[derive(Debug)]
77pub(crate) struct CachedYuvRepackPipeline {
78 pub(crate) bind_group_layout: wgpu::BindGroupLayout,
79 pub(crate) luma: wgpu::RenderPipeline,
81 pub(crate) interleaved_chroma: wgpu::RenderPipeline,
83 pub(crate) planar_chroma: wgpu::RenderPipeline,
85}
86
87impl PipelineCache {
88 pub(crate) fn builtin_count(&self) -> usize {
89 usize::from(self.composite.get().is_some())
90 + [&self.quad]
91 .into_iter()
92 .filter(|pipeline| pipeline.get().is_some())
93 .count()
94 + usize::from(self.yuv.get().is_some())
95 + usize::from(self.yuv16.get().is_some())
96 + usize::from(self.rgba_present.get().is_some())
97 + usize::from(self.readback_pack.get().is_some())
98 + usize::from(self.yuv_readback.get().is_some())
99 + usize::from(self.yuv_repack.get().is_some())
100 }
101}