add empty bind group layout

This commit is contained in:
Emerson Coskey 2025-07-14 12:08:26 -07:00
parent 8fd69182e4
commit d787a0fc1f
No known key found for this signature in database
2 changed files with 22 additions and 1 deletions

View File

@ -96,6 +96,7 @@ use render_asset::{
extract_render_asset_bytes_per_frame, reset_render_asset_bytes_per_frame,
RenderAssetBytesPerFrame, RenderAssetBytesPerFrameLimiter,
};
use render_resource::init_empty_bind_group_layout;
use renderer::{RenderAdapter, RenderDevice, RenderQueue};
use settings::RenderResources;
use sync_world::{
@ -465,6 +466,8 @@ impl Plugin for RenderPlugin {
Render,
reset_render_asset_bytes_per_frame.in_set(RenderSystems::Cleanup),
);
render_app.add_systems(RenderStartup, init_empty_bind_group_layout);
}
app.register_type::<alpha::AlphaMode>()

View File

@ -1,4 +1,6 @@
use crate::define_atomic_id;
use crate::{define_atomic_id, renderer::RenderDevice};
use bevy_ecs::system::Res;
use bevy_platform::sync::OnceLock;
use bevy_utils::WgpuWrapper;
use core::ops::Deref;
@ -62,3 +64,19 @@ impl Deref for BindGroupLayout {
&self.value
}
}
static EMPTY_BIND_GROUP_LAYOUT: OnceLock<BindGroupLayout> = OnceLock::new();
pub(crate) fn init_empty_bind_group_layout(render_device: Res<RenderDevice>) {
let layout = render_device.create_bind_group_layout(Some("empty_bind_group_layout"), &[]);
EMPTY_BIND_GROUP_LAYOUT
.set(layout)
.expect("init_empty_bind_group_layout was called more than once");
}
pub fn empty_bind_group_layout() -> BindGroupLayout {
EMPTY_BIND_GROUP_LAYOUT
.get()
.expect("init_empty_bind_group_layout was not called")
.clone()
}