Skip to content

Commit e838d1a

Browse files
authored
Make sure to init fallback resources in bevy_sprite_render (#25574)
# Objective - bevy_sprite_render is not adding the fallback resources which can cause a crash when only 2d features are enabled. ## Solution - Add init_fallback_resources to the RenderStartup of the MaterialBindGroupPlugin so it's always initialized ## Testing - I tested a separate empty project with only the 2d feature enabled and it stopped crashing after this change Closes #25572 Closes #25570
1 parent b771c53 commit e838d1a

2 files changed

Lines changed: 5 additions & 11 deletions

File tree

crates/bevy_pbr/src/lib.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,7 @@ pub mod contact_shadows;
3030
#[cfg(feature = "bevy_gltf")]
3131
pub mod gltf;
3232
use bevy_light::cluster::GlobalClusterSettings;
33-
use bevy_render::{
34-
material_bind_groups::init_fallback_resources, sync_component::SyncComponent,
35-
view::RenderShadowLodOrigin,
36-
};
33+
use bevy_render::{sync_component::SyncComponent, view::RenderShadowLodOrigin};
3734
pub use contact_shadows::{
3835
ContactShadows, ContactShadowsBuffer, ContactShadowsPlugin, ContactShadowsUniform,
3936
ViewContactShadowsUniformOffset,
@@ -364,11 +361,7 @@ impl Plugin for PbrPlugin {
364361
render_app
365362
.add_systems(
366363
RenderStartup,
367-
(
368-
init_shadow_samplers,
369-
init_global_clusterable_object_meta,
370-
init_fallback_resources,
371-
),
364+
(init_shadow_samplers, init_global_clusterable_object_meta),
372365
)
373366
.add_systems(
374367
ExtractSchedule,

crates/bevy_render/src/material_bind_groups.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use crate::{
2929
OwnedBindingResource, PipelineCache, UnpreparedBindingResource, UnpreparedBindingResources,
3030
},
3131
storage::ShaderBuffer,
32-
GpuResourceAppExt as _, Render, RenderApp, RenderSystems,
32+
GpuResourceAppExt as _, Render, RenderApp, RenderStartup, RenderSystems,
3333
};
3434
use crate::{
3535
render_resource::{
@@ -536,6 +536,7 @@ impl Plugin for MaterialBindGroupPlugin {
536536
.allow_ambiguous_resource::<MaterialBindGroupAllocators>()
537537
.init_gpu_resource::<RenderMaterialBindings>()
538538
.allow_ambiguous_resource::<RenderMaterialBindings>()
539+
.add_systems(RenderStartup, init_fallback_resources)
539540
.add_systems(
540541
Render,
541542
(
@@ -2328,7 +2329,7 @@ impl MaterialBindlessSlab {
23282329
}
23292330

23302331
/// Creates and inserts the [`FallbackBindlessResources`] and [`FallbackBuffer`].
2331-
pub fn init_fallback_resources(mut commands: Commands, render_device: Res<RenderDevice>) {
2332+
fn init_fallback_resources(mut commands: Commands, render_device: Res<RenderDevice>) {
23322333
// Create the `FallbackBindlessResources`.
23332334
commands.insert_resource(FallbackBindlessResources {
23342335
filtering_sampler: render_device.create_sampler(&SamplerDescriptor {

0 commit comments

Comments
 (0)