Skip to content

Commit

Permalink
Move specialize_* to QueueMeshes. (#17719)
Browse files Browse the repository at this point in the history
# Objective

Things were breaking post-cs.

## Solution

`specialize_mesh_materials` must run after
`collect_meshes_for_gpu_building`. Therefore, its placement in the
`PrepareAssets` set didn't make sense (also more generally). To fix, we
put this class of system in ~`PrepareResources`~ `QueueMeshes`, although
it potentially could use a more descriptive location. We may want to
review the placement of `check_views_need_specialization` which is also
currently in `PrepareAssets`.
  • Loading branch information
tychedelia authored Feb 9, 2025
1 parent 2d62026 commit af6629c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
7 changes: 4 additions & 3 deletions crates/bevy_pbr/src/material.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,9 +314,10 @@ where
Render,
(
specialize_material_meshes::<M>
.in_set(RenderSet::PrepareAssets)
.in_set(RenderSet::PrepareMeshes)
.after(prepare_assets::<PreparedMaterial<M>>)
.after(prepare_assets::<RenderMesh>),
.after(prepare_assets::<RenderMesh>)
.after(collect_meshes_for_gpu_building),
queue_material_meshes::<M>
.in_set(RenderSet::QueueMeshes)
.after(prepare_assets::<PreparedMaterial<M>>),
Expand All @@ -339,7 +340,7 @@ where
(
check_views_lights_need_specialization.in_set(RenderSet::PrepareAssets),
specialize_shadows::<M>
.in_set(RenderSet::PrepareAssets)
.in_set(RenderSet::PrepareMeshes)
.after(prepare_assets::<PreparedMaterial<M>>),
queue_shadows::<M>
.in_set(RenderSet::QueueMeshes)
Expand Down
21 changes: 11 additions & 10 deletions crates/bevy_pbr/src/prepass/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ mod prepass_bindings;

use crate::{
alpha_mode_pipeline_key, binding_arrays_are_usable, buffer_layout,
material_bind_groups::MaterialBindGroupAllocator, queue_material_meshes,
setup_morph_and_skinning_defs, skin, DrawMesh, EntitySpecializationTicks, Material,
MaterialPipeline, MaterialPipelineKey, MeshLayouts, MeshPipeline, MeshPipelineKey,
OpaqueRendererMethod, PreparedMaterial, RenderLightmaps, RenderMaterialInstances,
RenderMeshInstanceFlags, RenderMeshInstances, RenderPhaseType, SetMaterialBindGroup,
SetMeshBindGroup, ShadowView, StandardMaterial,
collect_meshes_for_gpu_building, material_bind_groups::MaterialBindGroupAllocator,
queue_material_meshes, setup_morph_and_skinning_defs, skin, DrawMesh,
EntitySpecializationTicks, Material, MaterialPipeline, MaterialPipelineKey, MeshLayouts,
MeshPipeline, MeshPipelineKey, OpaqueRendererMethod, PreparedMaterial, RenderLightmaps,
RenderMaterialInstances, RenderMeshInstanceFlags, RenderMeshInstances, RenderPhaseType,
SetMaterialBindGroup, SetMeshBindGroup, ShadowView, StandardMaterial,
};
use bevy_app::{App, Plugin, PreUpdate};
use bevy_render::{
Expand Down Expand Up @@ -61,7 +61,7 @@ use bevy_ecs::system::SystemChangeTick;
use bevy_platform_support::collections::HashMap;
use bevy_render::sync_world::{MainEntity, MainEntityHashMap};
use bevy_render::view::RenderVisibleEntities;
use bevy_render::RenderSet::PrepareAssets;
use bevy_render::RenderSet::{PrepareAssets, PrepareResources};
use core::{hash::Hash, marker::PhantomData};

pub const PREPASS_SHADER_HANDLE: Handle<Shader> =
Expand Down Expand Up @@ -190,7 +190,7 @@ where
.add_systems(ExtractSchedule, extract_camera_previous_view_data)
.add_systems(
Render,
prepare_previous_view_uniforms.in_set(RenderSet::PrepareResources),
prepare_previous_view_uniforms.in_set(PrepareResources),
);
}

Expand All @@ -207,9 +207,10 @@ where
(
check_prepass_views_need_specialization.in_set(PrepareAssets),
specialize_prepass_material_meshes::<M>
.in_set(PrepareAssets)
.in_set(RenderSet::PrepareMeshes)
.after(prepare_assets::<PreparedMaterial<M>>)
.after(prepare_assets::<RenderMesh>),
.after(prepare_assets::<RenderMesh>)
.after(collect_meshes_for_gpu_building),
queue_prepass_material_meshes::<M>
.in_set(RenderSet::QueueMeshes)
.after(prepare_assets::<PreparedMaterial<M>>)
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_sprite/src/mesh2d/material.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ where
Render,
(
specialize_material2d_meshes::<M>
.in_set(RenderSet::PrepareAssets)
.in_set(RenderSet::PrepareMeshes)
.after(prepare_assets::<PreparedMaterial2d<M>>)
.after(prepare_assets::<RenderMesh>),
queue_material2d_meshes::<M>
Expand Down

0 comments on commit af6629c

Please sign in to comment.