alpha2_render/
shader_inventory.rs1use alpha2_shaders::{
7 CANVAS_PRESENT_WGSL, COMPOSITE_WGSL, FULLSCREEN_TEXTURE_QUAD_WGSL, LAYOUT_PACK_WGSL,
8 READBACK_PACK_WGSL, RGB_TO_YUV420_WGSL, RGBA_PRESENT_WGSL, YUV_REPACK_WGSL, YUV_TO_LINEAR_WGSL,
9 YUV16_TO_LINEAR_WGSL,
10};
11
12use crate::EffectDef;
13use crate::registry::build_shader;
14
15#[must_use]
17pub fn effect_wgsl(definition: &EffectDef) -> String {
18 build_shader(definition)
19}
20
21#[must_use]
24pub fn builtin_wgsl_modules() -> Vec<(String, String)> {
25 let mut modules = [
26 ("canvas-present", CANVAS_PRESENT_WGSL),
28 ("fullscreen-quad", FULLSCREEN_TEXTURE_QUAD_WGSL),
29 ("composite", COMPOSITE_WGSL),
30 ("layout-pack", LAYOUT_PACK_WGSL),
31 ("readback-pack", READBACK_PACK_WGSL),
32 ("rgba-present", RGBA_PRESENT_WGSL),
33 ("rgb-to-yuv420", RGB_TO_YUV420_WGSL),
34 ("yuv-repack", YUV_REPACK_WGSL),
35 ("yuv-to-linear", YUV_TO_LINEAR_WGSL),
36 ("yuv16-to-linear", YUV16_TO_LINEAR_WGSL),
37 ]
38 .map(|(label, source)| (label.to_owned(), source.to_owned()))
39 .to_vec();
40 modules.push(("vector".to_owned(), crate::vector::vector_wgsl()));
41 let mut definitions = crate::builtins::internal_effect_definitions();
42 definitions.extend(crate::builtin_effect_definitions());
43 definitions.extend(crate::builtin_transition_definitions());
44 modules.extend(
45 definitions
46 .iter()
47 .map(|definition| (definition.id.clone(), effect_wgsl(definition))),
48 );
49 modules
50}
51
52#[cfg(test)]
53#[path = "shader_inventory_tests.rs"]
54mod tests;