From dc17f6a483125b14929dfab84a93007d36977022 Mon Sep 17 00:00:00 2001 From: Gino Valente Date: Mon, 21 Nov 2022 19:42:55 -0800 Subject: [PATCH 1/4] Register missing reflected types for bevy_render --- crates/bevy_render/src/lib.rs | 35 ++++++++++++++----- crates/bevy_render/src/view/visibility/mod.rs | 2 +- 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/crates/bevy_render/src/lib.rs b/crates/bevy_render/src/lib.rs index 7c3091322155d..69fd9a17f2415 100644 --- a/crates/bevy_render/src/lib.rs +++ b/crates/bevy_render/src/lib.rs @@ -37,13 +37,10 @@ pub mod prelude { use globals::GlobalsPlugin; pub use once_cell; -use prelude::ComputedVisibility; use crate::{ camera::CameraPlugin, - color::Color, mesh::MeshPlugin, - primitives::{CubemapFrusta, Frustum}, render_graph::RenderGraph, render_resource::{PipelineCache, Shader, ShaderLoader}, renderer::{render_system, RenderInstance}, @@ -137,8 +134,7 @@ impl Plugin for RenderPlugin { app.add_asset::() .add_debug_asset::() .init_asset_loader::() - .init_debug_asset_loader::() - .register_type::(); + .init_debug_asset_loader::(); if let Some(backends) = options.backends { let windows = app.world.resource_mut::(); @@ -166,9 +162,7 @@ impl Plugin for RenderPlugin { .insert_resource(queue.clone()) .insert_resource(adapter_info.clone()) .insert_resource(render_adapter.clone()) - .init_resource::() - .register_type::() - .register_type::(); + .init_resource::(); let pipeline_cache = PipelineCache::new(device.clone()); let asset_server = app.world.resource::().clone(); @@ -327,12 +321,35 @@ impl Plugin for RenderPlugin { }); } - app.add_plugin(ValidParentCheckPlugin::::default()) + app.add_plugin(ValidParentCheckPlugin::::default()) .add_plugin(WindowRenderPlugin) .add_plugin(CameraPlugin) .add_plugin(ViewPlugin) .add_plugin(MeshPlugin) .add_plugin(GlobalsPlugin); + + app.register_type::() + .register_type::() + .register_type::() + .register_type::() + .register_type::() + .register_type::() + .register_type::() + .register_type::() + .register_type::() + .register_type::() + .register_type::() + .register_type::() + .register_type::() + .register_type::() + .register_type::() + .register_type::() + .register_type::() + .register_type::() + .register_type::() + .register_type::() + .register_type::() + .register_type::(); } } diff --git a/crates/bevy_render/src/view/visibility/mod.rs b/crates/bevy_render/src/view/visibility/mod.rs index c08df608985d1..cbacd4e9d2f3e 100644 --- a/crates/bevy_render/src/view/visibility/mod.rs +++ b/crates/bevy_render/src/view/visibility/mod.rs @@ -56,7 +56,7 @@ impl Visibility { bitflags::bitflags! { #[derive(Reflect)] - struct ComputedVisibilityFlags: u8 { + pub(crate) struct ComputedVisibilityFlags: u8 { const VISIBLE_IN_VIEW = 1 << 0; const VISIBLE_IN_HIERARCHY = 1 << 1; } From edd32d52d8ea2010b780befadc93676a76778da7 Mon Sep 17 00:00:00 2001 From: Gino Valente Date: Mon, 21 Nov 2022 19:54:17 -0800 Subject: [PATCH 2/4] Register dependent types --- crates/bevy_render/src/lib.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/crates/bevy_render/src/lib.rs b/crates/bevy_render/src/lib.rs index 69fd9a17f2415..b8b9cbbab30f8 100644 --- a/crates/bevy_render/src/lib.rs +++ b/crates/bevy_render/src/lib.rs @@ -49,7 +49,9 @@ use crate::{ use bevy_app::{App, AppLabel, Plugin}; use bevy_asset::{AddAsset, AssetServer}; use bevy_ecs::prelude::*; +use bevy_reflect::{ReflectDeserialize, ReflectSerialize}; use bevy_utils::tracing::debug; +use std::ops::Range; use std::{ any::TypeId, ops::{Deref, DerefMut}, @@ -336,10 +338,15 @@ impl Plugin for RenderPlugin { .register_type::() .register_type::() .register_type::() + .register_type::>() + .register_type::>() + .register_type_data::, ReflectSerialize>() + .register_type_data::, ReflectDeserialize>() .register_type::() .register_type::() .register_type::() .register_type::() + .register_type::>() .register_type::() .register_type::() .register_type::() From 03619537aaf8d0a1c99fc57309fca849d83ba398 Mon Sep 17 00:00:00 2001 From: Gino Valente Date: Tue, 22 Nov 2022 08:41:45 -0800 Subject: [PATCH 3/4] Move registrations to their respective plugins --- crates/bevy_render/src/camera/mod.rs | 18 ++++------- crates/bevy_render/src/globals.rs | 1 + crates/bevy_render/src/lib.rs | 32 ++----------------- crates/bevy_render/src/mesh/mod.rs | 2 ++ crates/bevy_render/src/texture/mod.rs | 1 + crates/bevy_render/src/view/mod.rs | 7 +++- crates/bevy_render/src/view/visibility/mod.rs | 2 +- 7 files changed, 21 insertions(+), 42 deletions(-) diff --git a/crates/bevy_render/src/camera/mod.rs b/crates/bevy_render/src/camera/mod.rs index daf1f6cb56561..77e2e5109c3c2 100644 --- a/crates/bevy_render/src/camera/mod.rs +++ b/crates/bevy_render/src/camera/mod.rs @@ -6,14 +6,11 @@ mod projection; pub use camera::*; pub use camera_driver_node::*; pub use projection::*; +use std::ops::Range; -use crate::{ - primitives::Aabb, - render_graph::RenderGraph, - view::{ComputedVisibility, RenderLayers, Visibility, VisibleEntities}, - RenderApp, RenderStage, -}; +use crate::{render_graph::RenderGraph, RenderApp, RenderStage}; use bevy_app::{App, Plugin}; +use bevy_reflect::{ReflectDeserialize, ReflectSerialize}; #[derive(Default)] pub struct CameraPlugin; @@ -23,14 +20,13 @@ impl Plugin for CameraPlugin { app.register_type::() .register_type::() .register_type::>() - .register_type::() - .register_type::() - .register_type::() + .register_type::>() + .register_type_data::, ReflectSerialize>() + .register_type_data::, ReflectDeserialize>() .register_type::() .register_type::() - .register_type::() .register_type::() - .register_type::() + .register_type::() .add_plugin(CameraProjectionPlugin::::default()) .add_plugin(CameraProjectionPlugin::::default()) .add_plugin(CameraProjectionPlugin::::default()); diff --git a/crates/bevy_render/src/globals.rs b/crates/bevy_render/src/globals.rs index 993545302ba0b..a0b160dd4b27d 100644 --- a/crates/bevy_render/src/globals.rs +++ b/crates/bevy_render/src/globals.rs @@ -14,6 +14,7 @@ pub struct GlobalsPlugin; impl Plugin for GlobalsPlugin { fn build(&self, app: &mut App) { + app.register_type::(); if let Ok(render_app) = app.get_sub_app_mut(RenderApp) { render_app .init_resource::() diff --git a/crates/bevy_render/src/lib.rs b/crates/bevy_render/src/lib.rs index b8b9cbbab30f8..7b6916a7535a8 100644 --- a/crates/bevy_render/src/lib.rs +++ b/crates/bevy_render/src/lib.rs @@ -41,7 +41,6 @@ pub use once_cell; use crate::{ camera::CameraPlugin, mesh::MeshPlugin, - render_graph::RenderGraph, render_resource::{PipelineCache, Shader, ShaderLoader}, renderer::{render_system, RenderInstance}, view::{ViewPlugin, WindowRenderPlugin}, @@ -49,9 +48,7 @@ use crate::{ use bevy_app::{App, AppLabel, Plugin}; use bevy_asset::{AddAsset, AssetServer}; use bevy_ecs::prelude::*; -use bevy_reflect::{ReflectDeserialize, ReflectSerialize}; use bevy_utils::tracing::debug; -use std::ops::Range; use std::{ any::TypeId, ops::{Deref, DerefMut}, @@ -199,7 +196,7 @@ impl Plugin for RenderPlugin { .with_system(render_system.at_end()), ) .add_stage(RenderStage::Cleanup, SystemStage::parallel()) - .init_resource::() + .init_resource::() .insert_resource(RenderInstance(instance)) .insert_resource(device) .insert_resource(queue) @@ -330,33 +327,10 @@ impl Plugin for RenderPlugin { .add_plugin(MeshPlugin) .add_plugin(GlobalsPlugin); - app.register_type::() - .register_type::() - .register_type::() - .register_type::() - .register_type::() - .register_type::() - .register_type::() - .register_type::() - .register_type::>() - .register_type::>() - .register_type_data::, ReflectSerialize>() - .register_type_data::, ReflectDeserialize>() - .register_type::() - .register_type::() - .register_type::() - .register_type::() - .register_type::>() + app.register_type::() .register_type::() .register_type::() - .register_type::() - .register_type::() - .register_type::() - .register_type::() - .register_type::() - .register_type::() - .register_type::() - .register_type::(); + .register_type::(); } } diff --git a/crates/bevy_render/src/mesh/mod.rs b/crates/bevy_render/src/mesh/mod.rs index 156e44de8da64..790d4531b2456 100644 --- a/crates/bevy_render/src/mesh/mod.rs +++ b/crates/bevy_render/src/mesh/mod.rs @@ -8,6 +8,7 @@ pub use mesh::*; use crate::render_asset::RenderAssetPlugin; use bevy_app::{App, Plugin}; use bevy_asset::AddAsset; +use bevy_ecs::entity::Entity; /// Adds the [`Mesh`] as an asset and makes sure that they are extracted and prepared for the GPU. pub struct MeshPlugin; @@ -17,6 +18,7 @@ impl Plugin for MeshPlugin { app.add_asset::() .add_asset::() .register_type::() + .register_type::>() .add_plugin(RenderAssetPlugin::::default()); } } diff --git a/crates/bevy_render/src/texture/mod.rs b/crates/bevy_render/src/texture/mod.rs index 596b586f44cba..89637d730b2fc 100644 --- a/crates/bevy_render/src/texture/mod.rs +++ b/crates/bevy_render/src/texture/mod.rs @@ -86,6 +86,7 @@ impl Plugin for ImagePlugin { app.add_plugin(RenderAssetPlugin::::with_prepare_asset_label( PrepareAssetLabel::PreAssetPrepare, )) + .register_type::() .add_asset::() .register_asset_reflect::(); app.world diff --git a/crates/bevy_render/src/view/mod.rs b/crates/bevy_render/src/view/mod.rs index 843b0c638cb36..bc0c12b023135 100644 --- a/crates/bevy_render/src/view/mod.rs +++ b/crates/bevy_render/src/view/mod.rs @@ -31,7 +31,12 @@ pub struct ViewPlugin; impl Plugin for ViewPlugin { fn build(&self, app: &mut App) { - app.register_type::() + app.register_type::() + .register_type::() + .register_type::() + .register_type::() + .register_type::() + .register_type::() .init_resource::() // NOTE: windows.is_changed() handles cases where a window was resized .add_plugin(ExtractResourcePlugin::::default()) diff --git a/crates/bevy_render/src/view/visibility/mod.rs b/crates/bevy_render/src/view/visibility/mod.rs index cbacd4e9d2f3e..cfa85157a6270 100644 --- a/crates/bevy_render/src/view/visibility/mod.rs +++ b/crates/bevy_render/src/view/visibility/mod.rs @@ -56,7 +56,7 @@ impl Visibility { bitflags::bitflags! { #[derive(Reflect)] - pub(crate) struct ComputedVisibilityFlags: u8 { + pub(super) struct ComputedVisibilityFlags: u8 { const VISIBLE_IN_VIEW = 1 << 0; const VISIBLE_IN_HIERARCHY = 1 << 1; } From d8ee25406c47266f3e6cf12d66b65c803dfdb93c Mon Sep 17 00:00:00 2001 From: Gino Valente Date: Tue, 22 Nov 2022 11:20:49 -0800 Subject: [PATCH 4/4] Remove unnecessary registrations --- crates/bevy_render/src/camera/mod.rs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/crates/bevy_render/src/camera/mod.rs b/crates/bevy_render/src/camera/mod.rs index 77e2e5109c3c2..df81b87b261c8 100644 --- a/crates/bevy_render/src/camera/mod.rs +++ b/crates/bevy_render/src/camera/mod.rs @@ -6,11 +6,9 @@ mod projection; pub use camera::*; pub use camera_driver_node::*; pub use projection::*; -use std::ops::Range; use crate::{render_graph::RenderGraph, RenderApp, RenderStage}; use bevy_app::{App, Plugin}; -use bevy_reflect::{ReflectDeserialize, ReflectSerialize}; #[derive(Default)] pub struct CameraPlugin; @@ -20,9 +18,6 @@ impl Plugin for CameraPlugin { app.register_type::() .register_type::() .register_type::>() - .register_type::>() - .register_type_data::, ReflectSerialize>() - .register_type_data::, ReflectDeserialize>() .register_type::() .register_type::() .register_type::()