From db64f09129ba126a86d7ad52d9726d7ff8435416 Mon Sep 17 00:00:00 2001 From: 66OJ66 Date: Fri, 14 Jul 2023 16:59:39 +0000 Subject: [PATCH 1/4] Move ImageTextureLoader initialisation from ImagePlugin::build() to ImagePlugin::finish() --- crates/bevy_render/src/texture/mod.rs | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/crates/bevy_render/src/texture/mod.rs b/crates/bevy_render/src/texture/mod.rs index 6d4fd23bb6c75..44030c9622340 100644 --- a/crates/bevy_render/src/texture/mod.rs +++ b/crates/bevy_render/src/texture/mod.rs @@ -70,19 +70,6 @@ impl ImagePlugin { impl Plugin for ImagePlugin { fn build(&self, app: &mut App) { - #[cfg(any( - feature = "png", - feature = "dds", - feature = "tga", - feature = "jpeg", - feature = "bmp", - feature = "basis-universal", - feature = "ktx2", - ))] - { - app.init_asset_loader::(); - } - #[cfg(feature = "exr")] { app.init_asset_loader::(); @@ -112,6 +99,19 @@ impl Plugin for ImagePlugin { } fn finish(&self, app: &mut App) { + #[cfg(any( + feature = "png", + feature = "dds", + feature = "tga", + feature = "jpeg", + feature = "bmp", + feature = "basis-universal", + feature = "ktx2", + ))] + { + app.init_asset_loader::(); + } + if let Ok(render_app) = app.get_sub_app_mut(RenderApp) { let default_sampler = { let device = render_app.world.resource::(); From b1739799a0513487c8ca7936f06116e55c95309b Mon Sep 17 00:00:00 2001 From: 66OJ66 Date: Fri, 14 Jul 2023 17:02:08 +0000 Subject: [PATCH 2/4] If RenderDevice is absent, don't support any compressed formats --- crates/bevy_render/src/texture/image_texture_loader.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/bevy_render/src/texture/image_texture_loader.rs b/crates/bevy_render/src/texture/image_texture_loader.rs index 080198beee5df..247d65e5a279f 100644 --- a/crates/bevy_render/src/texture/image_texture_loader.rs +++ b/crates/bevy_render/src/texture/image_texture_loader.rs @@ -82,7 +82,7 @@ impl FromWorld for ImageTextureLoader { let supported_compressed_formats = match world.get_resource::() { Some(render_device) => CompressedImageFormats::from_features(render_device.features()), - None => CompressedImageFormats::all(), + None => CompressedImageFormats::NONE, }; Self { supported_compressed_formats, From 747de38b51086a7c5a1951e1e0b301bffc46587c Mon Sep 17 00:00:00 2001 From: 66OJ66 Date: Fri, 14 Jul 2023 17:36:28 +0000 Subject: [PATCH 3/4] cargo fmt --- crates/bevy_render/src/texture/mod.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/crates/bevy_render/src/texture/mod.rs b/crates/bevy_render/src/texture/mod.rs index 44030c9622340..25a65e5198a6f 100644 --- a/crates/bevy_render/src/texture/mod.rs +++ b/crates/bevy_render/src/texture/mod.rs @@ -100,13 +100,13 @@ impl Plugin for ImagePlugin { fn finish(&self, app: &mut App) { #[cfg(any( - feature = "png", - feature = "dds", - feature = "tga", - feature = "jpeg", - feature = "bmp", - feature = "basis-universal", - feature = "ktx2", + feature = "png", + feature = "dds", + feature = "tga", + feature = "jpeg", + feature = "bmp", + feature = "basis-universal", + feature = "ktx2", ))] { app.init_asset_loader::(); From 56d49e72b09f95a2ccd04581a3df8a24685b6cba Mon Sep 17 00:00:00 2001 From: 66OJ66 Date: Fri, 14 Jul 2023 20:23:00 +0000 Subject: [PATCH 4/4] Apply similar change to GltfPlugin --- crates/bevy_gltf/src/lib.rs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/crates/bevy_gltf/src/lib.rs b/crates/bevy_gltf/src/lib.rs index 7277a906269f5..fc022bf94ff20 100644 --- a/crates/bevy_gltf/src/lib.rs +++ b/crates/bevy_gltf/src/lib.rs @@ -40,20 +40,23 @@ impl GltfPlugin { impl Plugin for GltfPlugin { fn build(&self, app: &mut App) { + app.register_type::() + .add_asset::() + .add_asset::() + .add_asset::() + .add_asset::(); + } + + fn finish(&self, app: &mut App) { let supported_compressed_formats = match app.world.get_resource::() { Some(render_device) => CompressedImageFormats::from_features(render_device.features()), - None => CompressedImageFormats::all(), + None => CompressedImageFormats::NONE, }; app.add_asset_loader::(GltfLoader { supported_compressed_formats, custom_vertex_attributes: self.custom_vertex_attributes.clone(), - }) - .register_type::() - .add_asset::() - .add_asset::() - .add_asset::() - .add_asset::(); + }); } }