1use crate::{
2 assets::plugin::AssetPlugin,
3 ecs::{
4 plugin::Plugin,
5 system::{ENGINE_READY_PRIORITY, SystemStage},
6 system_param::IntoSystemConfig,
7 },
8 graphics::{
9 pipeline::{
10 compute::Compute,
11 cubemap::Cubemap,
12 instance::{ComputeInstance, MaterialInstance},
13 layout::GlobalLayoutPool,
14 material::Material,
15 mesh::Mesh,
16 mipmap::init_mipmap_generator,
17 samplers::init_global_samplers,
18 texture_array::TextureArray,
19 textures::Texture,
20 },
21 render::{Backend, BackendPlugin},
22 types::flags::DeviceFeatures,
23 window::{WindowConfig, WindowPlugin},
24 },
25};
26
27pub mod pipeline;
28pub mod render;
29pub mod types;
30pub mod window;
31
32pub struct GraphicsPlugin {
37 features: DeviceFeatures,
38 window: WindowConfig,
39}
40
41impl GraphicsPlugin {
42 pub fn new() -> Self {
43 Self {
44 features: DeviceFeatures::empty(),
45 window: WindowConfig::default(),
46 }
47 }
48
49 pub fn with_features(features: DeviceFeatures) -> Self {
50 Self {
51 features,
52 window: WindowConfig::default(),
53 }
54 }
55
56 pub fn with_window(mut self, window: WindowConfig) -> Self {
60 self.window = window;
61 self
62 }
63}
64
65impl Plugin for GraphicsPlugin {
66 fn build(self, app: crate::app::App) -> crate::app::App {
67 app.add_plugin(WindowPlugin::new(self.window))
68 .add_plugin(BackendPlugin::with_features(self.features))
69 .add_plugin(BuiltinAssetsPlugin)
70 }
71}
72
73pub struct BuiltinAssetsPlugin;
77impl Plugin for BuiltinAssetsPlugin {
78 fn build(self, app: crate::app::App) -> crate::app::App {
79 app.insert_resource(GlobalLayoutPool::default())
80 .add_system(SystemStage::Ready, init_global_samplers.priority(ENGINE_READY_PRIORITY))
81 .add_system(SystemStage::AssetSync, init_mipmap_generator)
82 .add_plugin(AssetPlugin::<Backend, Mesh>::new())
83 .add_plugin(AssetPlugin::<Backend, Texture>::new())
84 .add_plugin(AssetPlugin::<Backend, TextureArray>::new())
85 .add_plugin(AssetPlugin::<Backend, Cubemap>::new())
86 .add_plugin(AssetPlugin::<Backend, Material>::new())
87 .add_plugin(AssetPlugin::<Backend, Compute>::new())
88 .add_plugin(AssetPlugin::<Backend, MaterialInstance>::new())
89 .add_plugin(AssetPlugin::<Backend, ComputeInstance>::new())
90 }
91}
92
93#[cfg(test)]
94mod test {}