Use RenderStartup
for MaterialPipeline
.
This commit is contained in:
parent
b0c4ba69f5
commit
e7a4f4d2bf
@ -267,6 +267,15 @@ impl Plugin for MaterialsPlugin {
|
||||
.init_resource::<LightKeyCache>()
|
||||
.init_resource::<LightSpecializationTicks>()
|
||||
.init_resource::<SpecializedShadowMaterialPipelineCache>()
|
||||
.init_resource::<DrawFunctions<Shadow>>()
|
||||
.init_resource::<RenderMaterialInstances>()
|
||||
.init_resource::<MaterialBindGroupAllocators>()
|
||||
.add_render_command::<Shadow, DrawPrepass>()
|
||||
.add_render_command::<Transmissive3d, DrawMaterial>()
|
||||
.add_render_command::<Transparent3d, DrawMaterial>()
|
||||
.add_render_command::<Opaque3d, DrawMaterial>()
|
||||
.add_render_command::<AlphaMask3d, DrawMaterial>()
|
||||
.add_systems(RenderStartup, init_material_pipeline)
|
||||
.add_systems(
|
||||
Render,
|
||||
(
|
||||
@ -301,21 +310,6 @@ impl Plugin for MaterialsPlugin {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
fn finish(&self, app: &mut App) {
|
||||
if let Some(render_app) = app.get_sub_app_mut(RenderApp) {
|
||||
render_app
|
||||
.init_resource::<DrawFunctions<Shadow>>()
|
||||
.init_resource::<RenderMaterialInstances>()
|
||||
.init_resource::<MaterialPipeline>()
|
||||
.init_resource::<MaterialBindGroupAllocators>()
|
||||
.add_render_command::<Shadow, DrawPrepass>()
|
||||
.add_render_command::<Transmissive3d, DrawMaterial>()
|
||||
.add_render_command::<Transparent3d, DrawMaterial>()
|
||||
.add_render_command::<Opaque3d, DrawMaterial>()
|
||||
.add_render_command::<AlphaMask3d, DrawMaterial>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Adds the necessary ECS resources and render logic to enable rendering entities using the given [`Material`]
|
||||
@ -485,12 +479,10 @@ impl SpecializedMeshPipeline for MaterialPipelineSpecializer {
|
||||
}
|
||||
}
|
||||
|
||||
impl FromWorld for MaterialPipeline {
|
||||
fn from_world(world: &mut World) -> Self {
|
||||
MaterialPipeline {
|
||||
mesh_pipeline: world.resource::<MeshPipeline>().clone(),
|
||||
}
|
||||
}
|
||||
pub fn init_material_pipeline(mut commands: Commands, mesh_pipeline: Res<MeshPipeline>) {
|
||||
commands.insert_resource(MaterialPipeline {
|
||||
mesh_pipeline: mesh_pipeline.clone(),
|
||||
});
|
||||
}
|
||||
|
||||
pub type DrawMaterial = (
|
||||
|
@ -2,13 +2,13 @@ mod prepass_bindings;
|
||||
|
||||
use crate::{
|
||||
alpha_mode_pipeline_key, binding_arrays_are_usable, buffer_layout,
|
||||
collect_meshes_for_gpu_building, set_mesh_motion_vector_flags, setup_morph_and_skinning_defs,
|
||||
skin, DeferredDrawFunction, DeferredFragmentShader, DeferredVertexShader, DrawMesh,
|
||||
EntitySpecializationTicks, ErasedMaterialPipelineKey, Material, MaterialPipeline,
|
||||
MaterialProperties, MeshLayouts, MeshPipeline, MeshPipelineKey, OpaqueRendererMethod,
|
||||
PreparedMaterial, PrepassDrawFunction, PrepassFragmentShader, PrepassVertexShader,
|
||||
RenderLightmaps, RenderMaterialInstances, RenderMeshInstanceFlags, RenderMeshInstances,
|
||||
RenderPhaseType, SetMaterialBindGroup, SetMeshBindGroup, ShadowView,
|
||||
collect_meshes_for_gpu_building, init_material_pipeline, set_mesh_motion_vector_flags,
|
||||
setup_morph_and_skinning_defs, skin, DeferredDrawFunction, DeferredFragmentShader,
|
||||
DeferredVertexShader, DrawMesh, EntitySpecializationTicks, ErasedMaterialPipelineKey, Material,
|
||||
MaterialPipeline, MaterialProperties, MeshLayouts, MeshPipeline, MeshPipelineKey,
|
||||
OpaqueRendererMethod, PreparedMaterial, PrepassDrawFunction, PrepassFragmentShader,
|
||||
PrepassVertexShader, RenderLightmaps, RenderMaterialInstances, RenderMeshInstanceFlags,
|
||||
RenderMeshInstances, RenderPhaseType, SetMaterialBindGroup, SetMeshBindGroup, ShadowView,
|
||||
};
|
||||
use bevy_app::{App, Plugin, PreUpdate};
|
||||
use bevy_render::{
|
||||
@ -89,7 +89,11 @@ impl Plugin for PrepassPipelinePlugin {
|
||||
render_app
|
||||
.add_systems(
|
||||
RenderStartup,
|
||||
(init_prepass_pipeline, init_prepass_view_bind_group).chain(),
|
||||
(
|
||||
init_prepass_pipeline.after(init_material_pipeline),
|
||||
init_prepass_view_bind_group,
|
||||
)
|
||||
.chain(),
|
||||
)
|
||||
.add_systems(
|
||||
Render,
|
||||
|
Loading…
Reference in New Issue
Block a user