diff --git a/crates/bevy_pbr/src/material.rs b/crates/bevy_pbr/src/material.rs index a7c4ec0b20a06..723c315344d3d 100644 --- a/crates/bevy_pbr/src/material.rs +++ b/crates/bevy_pbr/src/material.rs @@ -1,7 +1,8 @@ use crate::{ - render, AlphaMode, DrawMesh, DrawPrepass, EnvironmentMapLight, MeshPipeline, MeshPipelineKey, - PrepassPipelinePlugin, PrepassPlugin, RenderMeshInstances, ScreenSpaceAmbientOcclusionSettings, - SetMeshBindGroup, SetMeshViewBindGroup, Shadow, ShadowFilteringMethod, + meshlet::MeshletGpuScene, render, AlphaMode, DrawMesh, DrawPrepass, EnvironmentMapLight, + MeshPipeline, MeshPipelineKey, PrepassPipelinePlugin, PrepassPlugin, RenderMeshInstances, + ScreenSpaceAmbientOcclusionSettings, SetMeshBindGroup, SetMeshViewBindGroup, Shadow, + ShadowFilteringMethod, }; use bevy_app::{App, Plugin}; use bevy_asset::{Asset, AssetApp, AssetEvent, AssetId, AssetServer, Assets, Handle}; @@ -297,6 +298,7 @@ where pub struct MaterialPipeline { pub mesh_pipeline: MeshPipeline, pub material_layout: BindGroupLayout, + pub meshlet_layout: Option, pub vertex_shader: Option>, pub fragment_shader: Option>, pub marker: PhantomData, @@ -307,6 +309,7 @@ impl Clone for MaterialPipeline { Self { mesh_pipeline: self.mesh_pipeline.clone(), material_layout: self.material_layout.clone(), + meshlet_layout: self.meshlet_layout.clone(), vertex_shader: self.vertex_shader.clone(), fragment_shader: self.fragment_shader.clone(), marker: PhantomData, @@ -341,7 +344,7 @@ where let _mesh_bind_group = descriptor.layout.pop().unwrap(); descriptor.layout.extend_from_slice(&[ - todo!("MesletGpuScene::draw_bind_group_layout()"), + self.meshlet_layout.expect("TODO"), self.material_layout.clone(), ]); @@ -365,6 +368,9 @@ impl FromWorld for MaterialPipeline { MaterialPipeline { mesh_pipeline: world.resource::().clone(), material_layout: M::bind_group_layout(render_device), + meshlet_layout: world + .get_resource::() + .map(|gpu_scene| gpu_scene.draw_bind_group_layout().clone()), vertex_shader: match M::vertex_shader() { ShaderRef::Default => None, ShaderRef::Handle(handle) => Some(handle), diff --git a/crates/bevy_pbr/src/meshlet/mod.rs b/crates/bevy_pbr/src/meshlet/mod.rs index d42b00bf987dd..5125410c22dfc 100644 --- a/crates/bevy_pbr/src/meshlet/mod.rs +++ b/crates/bevy_pbr/src/meshlet/mod.rs @@ -7,6 +7,7 @@ mod persistent_buffer; mod psb_impls; mod test_material; +pub(crate) use self::gpu_scene::MeshletGpuScene; pub use self::{ asset::{Meshlet, MeshletBoundingSphere, MeshletMesh}, from_mesh::MeshToMeshletMeshConversionError, @@ -19,7 +20,6 @@ use self::{ gpu_scene::{ extract_meshlet_meshes, perform_pending_meshlet_mesh_writes, prepare_meshlet_per_frame_bind_groups, prepare_meshlet_per_frame_resources, - MeshletGpuScene, }, test_material::{MeshletTestMaterial, MESHLET_TEST_MATERIAL_SHADER_HANDLE}, };