From 32083f9c4f2d62f85b700dc1fac1c173a6594228 Mon Sep 17 00:00:00 2001 From: JMS55 <47158642+JMS55@users.noreply.github.com> Date: Mon, 23 Oct 2023 23:44:51 -0700 Subject: [PATCH] Further material WIP --- crates/bevy_pbr/src/material.rs | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/crates/bevy_pbr/src/material.rs b/crates/bevy_pbr/src/material.rs index fc96de07d2d34..a7c4ec0b20a06 100644 --- a/crates/bevy_pbr/src/material.rs +++ b/crates/bevy_pbr/src/material.rs @@ -29,8 +29,8 @@ use bevy_render::{ }, render_resource::{ AsBindGroup, AsBindGroupError, BindGroup, BindGroupId, BindGroupLayout, - OwnedBindingResource, PipelineCache, RenderPipelineDescriptor, Shader, ShaderRef, - SpecializedMeshPipeline, SpecializedMeshPipelineError, SpecializedMeshPipelines, + OwnedBindingResource, PipelineCache, RenderPipelineDescriptor, Shader, ShaderDefVal, + ShaderRef, SpecializedMeshPipeline, SpecializedMeshPipelineError, SpecializedMeshPipelines, }, renderer::RenderDevice, texture::FallbackImage, @@ -326,21 +326,30 @@ where layout: &MeshVertexBufferLayout, ) -> Result { let mut descriptor = self.mesh_pipeline.specialize(key.mesh_key, layout)?; + if let Some(vertex_shader) = &self.vertex_shader { descriptor.vertex.shader = vertex_shader.clone(); } - if let Some(fragment_shader) = &self.fragment_shader { descriptor.fragment.as_mut().unwrap().shader = fragment_shader.clone(); } - descriptor.layout.insert(1, self.material_layout.clone()); - if key.for_meshlet_mesh { descriptor.vertex.shader = todo!(); descriptor.vertex.entry_point = "meshlet_vertex".into(); descriptor.vertex.buffers = Vec::new(); - descriptor.layout = todo!(); + + let _mesh_bind_group = descriptor.layout.pop().unwrap(); + descriptor.layout.extend_from_slice(&[ + todo!("MesletGpuScene::draw_bind_group_layout()"), + self.material_layout.clone(), + ]); + + let sd = ShaderDefVal::UInt("MESHLET_BIND_GROUP".into(), 1); + descriptor.vertex.shader_defs.push(sd); + descriptor.fragment.as_mut().map(|f| f.shader_defs.push(sd)); + } else { + descriptor.layout.insert(1, self.material_layout.clone()); } M::specialize(self, &mut descriptor, layout, key)?;