First pass at post-merge fixup. Reverted EntitySpecializationTicks
refactoring as it depended on the generic parameter which has been erased in #19667.
This commit is contained in:
parent
7fe39aea1f
commit
ac1ba00100
@ -35,7 +35,7 @@ use bevy_render::erased_render_asset::{
|
||||
ErasedRenderAsset, ErasedRenderAssetPlugin, ErasedRenderAssets, PrepareAssetError,
|
||||
};
|
||||
use bevy_render::mesh::mark_3d_meshes_as_changed_if_their_assets_changed;
|
||||
use bevy_render::render_asset::{prepare_assets, RenderAssets};
|
||||
use bevy_render::render_asset::prepare_assets;
|
||||
use bevy_render::renderer::RenderQueue;
|
||||
use bevy_render::RenderStartup;
|
||||
use bevy_render::{
|
||||
@ -822,6 +822,12 @@ impl<M> Default for EntitiesNeedingSpecialization<M> {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Resource, Deref, DerefMut, Default, Clone, Debug)]
|
||||
pub struct EntitySpecializationTicks {
|
||||
#[deref]
|
||||
pub entities: MainEntityHashMap<Tick>,
|
||||
}
|
||||
|
||||
/// Stores the [`SpecializedMaterialViewPipelineCache`] for each view.
|
||||
#[derive(Resource, Deref, DerefMut, Default)]
|
||||
pub struct SpecializedMaterialPipelineCache {
|
||||
@ -867,7 +873,7 @@ pub fn check_entities_needing_specialization<M>(
|
||||
}
|
||||
|
||||
pub fn specialize_material_meshes(
|
||||
params: SpecializeMeshParams<M, RenderMeshInstances>,
|
||||
params: SpecializeMeshParams<EntitySpecializationTicks, RenderMeshInstances>,
|
||||
render_materials: Res<ErasedRenderAssets<PreparedMaterial>>,
|
||||
render_material_instances: Res<RenderMaterialInstances>,
|
||||
render_lightmaps: Res<RenderLightmaps>,
|
||||
@ -921,7 +927,9 @@ pub fn specialize_material_meshes(
|
||||
else {
|
||||
continue;
|
||||
};
|
||||
let Some(mesh_instance) = render_mesh_instances.render_mesh_queue_data(*visible_entity)
|
||||
let Some(mesh_instance) = params
|
||||
.render_mesh_instances
|
||||
.render_mesh_queue_data(*visible_entity)
|
||||
else {
|
||||
continue;
|
||||
};
|
||||
@ -993,7 +1001,7 @@ pub fn specialize_material_meshes(
|
||||
properties: material.properties.clone(),
|
||||
};
|
||||
let pipeline_id = pipelines.specialize(
|
||||
&pipeline_cache,
|
||||
¶ms.pipeline_cache,
|
||||
&material_pipeline_specializer,
|
||||
erased_key,
|
||||
&mesh.layout,
|
||||
|
@ -40,7 +40,6 @@ use bevy_math::{Affine3A, Vec4};
|
||||
use bevy_render::{
|
||||
globals::{GlobalsBuffer, GlobalsUniform},
|
||||
prelude::{Camera, Mesh},
|
||||
render_asset::RenderAssets,
|
||||
render_phase::*,
|
||||
render_resource::*,
|
||||
renderer::{RenderDevice, RenderQueue},
|
||||
@ -817,7 +816,7 @@ pub fn check_prepass_views_need_specialization(
|
||||
}
|
||||
|
||||
pub fn specialize_prepass_material_meshes(
|
||||
params: SpecializeMeshParams<M, RenderMeshInstances>,
|
||||
params: SpecializeMeshParams<EntitySpecializationTicks, RenderMeshInstances>,
|
||||
render_materials: Res<ErasedRenderAssets<PreparedMaterial>>,
|
||||
render_material_instances: Res<RenderMaterialInstances>,
|
||||
render_lightmaps: Res<RenderLightmaps>,
|
||||
@ -879,7 +878,7 @@ pub fn specialize_prepass_material_meshes(
|
||||
else {
|
||||
continue;
|
||||
};
|
||||
let Some(mesh_instance) = render_mesh_instances.render_mesh_queue_data(*visible_entity)
|
||||
let Some(mesh_instance) = params.render_mesh_instances.render_mesh_queue_data(*visible_entity)
|
||||
else {
|
||||
continue;
|
||||
};
|
||||
@ -905,7 +904,7 @@ pub fn specialize_prepass_material_meshes(
|
||||
view_specialized_material_pipeline_cache.remove(visible_entity);
|
||||
continue;
|
||||
}
|
||||
let Some(mesh) = render_meshes.get(mesh_instance.mesh_asset_id) else {
|
||||
let Some(mesh) = params.render_meshes.get(mesh_instance.mesh_asset_id) else {
|
||||
continue;
|
||||
};
|
||||
|
||||
@ -989,7 +988,7 @@ pub fn specialize_prepass_material_meshes(
|
||||
properties: material.properties.clone(),
|
||||
};
|
||||
let pipeline_id = pipelines.specialize(
|
||||
&pipeline_cache,
|
||||
¶ms.pipeline_cache,
|
||||
&prepass_pipeline_specializer,
|
||||
erased_key,
|
||||
&mesh.layout,
|
||||
|
@ -35,7 +35,6 @@ use bevy_render::{
|
||||
use bevy_render::{
|
||||
diagnostic::RecordDiagnostics,
|
||||
primitives::{CascadesFrusta, CubemapFrusta, Frustum, HalfSpace},
|
||||
render_asset::RenderAssets,
|
||||
render_graph::{Node, NodeRunError, RenderGraphContext},
|
||||
render_phase::*,
|
||||
render_resource::*,
|
||||
@ -1685,10 +1684,9 @@ pub fn check_views_lights_need_specialization(
|
||||
}
|
||||
|
||||
pub fn specialize_shadows(
|
||||
params: SpecializeMeshParams<M, RenderMeshInstances>,
|
||||
params: SpecializeMeshParams<EntitySpecializationTicks, RenderMeshInstances>,
|
||||
prepass_pipeline: Res<PrepassPipeline>,
|
||||
(render_meshes, render_materials, render_material_instances): (
|
||||
Res<RenderAssets<RenderMesh>>,
|
||||
(render_materials, render_material_instances): (
|
||||
Res<ErasedRenderAssets<PreparedMaterial>>,
|
||||
Res<RenderMaterialInstances>,
|
||||
),
|
||||
@ -1706,9 +1704,7 @@ pub fn specialize_shadows(
|
||||
light_key_cache: Res<LightKeyCache>,
|
||||
mut specialized_material_pipeline_cache: ResMut<SpecializedShadowMaterialPipelineCache>,
|
||||
light_specialization_ticks: Res<LightSpecializationTicks>,
|
||||
) where
|
||||
M::Data: PartialEq + Eq + Hash + Clone,
|
||||
{
|
||||
) {
|
||||
// Record the retained IDs of all shadow views so that we can expire old
|
||||
// pipeline IDs.
|
||||
let mut all_shadow_views: HashSet<RetainedViewEntity, FixedHasher> = HashSet::default();
|
||||
@ -1772,8 +1768,9 @@ pub fn specialize_shadows(
|
||||
continue;
|
||||
};
|
||||
|
||||
let Some(mesh_instance) =
|
||||
render_mesh_instances.render_mesh_queue_data(visible_entity)
|
||||
let Some(mesh_instance) = params
|
||||
.render_mesh_instances
|
||||
.render_mesh_queue_data(visible_entity)
|
||||
else {
|
||||
continue;
|
||||
};
|
||||
@ -1804,7 +1801,7 @@ pub fn specialize_shadows(
|
||||
{
|
||||
continue;
|
||||
}
|
||||
let Some(mesh) = render_meshes.get(mesh_instance.mesh_asset_id) else {
|
||||
let Some(mesh) = params.render_meshes.get(mesh_instance.mesh_asset_id) else {
|
||||
continue;
|
||||
};
|
||||
|
||||
@ -1841,7 +1838,7 @@ pub fn specialize_shadows(
|
||||
properties: material.properties.clone(),
|
||||
};
|
||||
let pipeline_id = pipelines.specialize(
|
||||
&pipeline_cache,
|
||||
¶ms.pipeline_cache,
|
||||
&material_pipeline_specializer,
|
||||
erased_key,
|
||||
&mesh.layout,
|
||||
|
@ -117,7 +117,7 @@ impl Plugin for WireframePlugin {
|
||||
};
|
||||
|
||||
render_app
|
||||
.init_resource::<EntitySpecializationTicks<WireframeMaterial>>()
|
||||
.init_resource::<WireframeEntitySpecializationTicks>()
|
||||
.init_resource::<SpecializedWireframePipelineCache>()
|
||||
.init_resource::<DrawFunctions<Wireframe3d>>()
|
||||
.add_render_command::<Wireframe3d, DrawWireframe3d>()
|
||||
@ -489,6 +489,11 @@ pub struct WireframeEntitiesNeedingSpecialization {
|
||||
pub entities: Vec<Entity>,
|
||||
}
|
||||
|
||||
#[derive(Resource, Deref, DerefMut, Clone, Debug, Default)]
|
||||
pub struct WireframeEntitySpecializationTicks {
|
||||
pub entities: MainEntityHashMap<Tick>,
|
||||
}
|
||||
|
||||
/// Stores the [`SpecializedWireframeViewPipelineCache`] for each view.
|
||||
#[derive(Resource, Deref, DerefMut, Default)]
|
||||
pub struct SpecializedWireframePipelineCache {
|
||||
@ -684,7 +689,7 @@ fn extract_wireframe_3d_camera(
|
||||
|
||||
pub fn extract_wireframe_entities_needing_specialization(
|
||||
entities_needing_specialization: Extract<Res<WireframeEntitiesNeedingSpecialization>>,
|
||||
mut entity_specialization_ticks: ResMut<EntitySpecializationTicks<WireframeMaterial>>,
|
||||
mut entity_specialization_ticks: ResMut<WireframeEntitySpecializationTicks>,
|
||||
views: Query<&ExtractedView>,
|
||||
mut specialized_wireframe_pipeline_cache: ResMut<SpecializedWireframePipelineCache>,
|
||||
mut removed_meshes_query: Extract<RemovedComponents<Mesh3d>>,
|
||||
@ -725,7 +730,7 @@ pub fn check_wireframe_entities_needing_specialization(
|
||||
}
|
||||
|
||||
pub fn specialize_wireframes(
|
||||
params: SpecializeMeshParams<WireframeMaterial, RenderMeshInstances>,
|
||||
params: SpecializeMeshParams<WireframeEntitySpecializationTicks, RenderMeshInstances>,
|
||||
render_wireframe_instances: Res<RenderWireframeInstances>,
|
||||
render_visibility_ranges: Res<RenderVisibilityRanges>,
|
||||
wireframe_phases: Res<ViewBinnedRenderPhases<Wireframe3d>>,
|
||||
|
@ -3,14 +3,11 @@ use crate::{
|
||||
render_asset::RenderAssets,
|
||||
render_resource::*,
|
||||
renderer::{RenderAdapter, RenderDevice},
|
||||
sync_world::MainEntityHashMap,
|
||||
Extract,
|
||||
};
|
||||
use alloc::{borrow::Cow, sync::Arc};
|
||||
use bevy_asset::{AssetEvent, AssetId, Assets};
|
||||
use bevy_derive::{Deref, DerefMut};
|
||||
use bevy_ecs::{
|
||||
component::Tick,
|
||||
event::EventReader,
|
||||
resource::Resource,
|
||||
system::{Res, ResMut, SystemChangeTick, SystemParam},
|
||||
@ -1087,27 +1084,15 @@ impl PipelineCache {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Resource, Deref, DerefMut, Clone, Debug)]
|
||||
pub struct EntitySpecializationTicks<M> {
|
||||
#[deref]
|
||||
pub entities: MainEntityHashMap<Tick>,
|
||||
_marker: PhantomData<M>,
|
||||
}
|
||||
|
||||
impl<M> Default for EntitySpecializationTicks<M> {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
entities: MainEntityHashMap::default(),
|
||||
_marker: Default::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Parameters shared between mesh specialization systems.
|
||||
#[derive(SystemParam)]
|
||||
pub struct SpecializeMeshParams<'w, M: Send + Sync + 'static, RenderMeshInstances: Resource> {
|
||||
pub struct SpecializeMeshParams<
|
||||
'w,
|
||||
EntitySpecializationTicks: Resource,
|
||||
RenderMeshInstances: Resource,
|
||||
> {
|
||||
pub pipeline_cache: Res<'w, PipelineCache>,
|
||||
pub entity_specialization_ticks: Res<'w, EntitySpecializationTicks<M>>,
|
||||
pub entity_specialization_ticks: Res<'w, EntitySpecializationTicks>,
|
||||
pub render_mesh_instances: Res<'w, RenderMeshInstances>,
|
||||
pub render_meshes: Res<'w, RenderAssets<RenderMesh>>,
|
||||
pub ticks: SystemChangeTick,
|
||||
|
@ -24,9 +24,7 @@ use bevy_platform::collections::HashMap;
|
||||
use bevy_reflect::{prelude::ReflectDefault, Reflect};
|
||||
use bevy_render::camera::extract_cameras;
|
||||
use bevy_render::render_phase::{DrawFunctionId, InputUniformIndex};
|
||||
use bevy_render::render_resource::{
|
||||
CachedRenderPipelineId, EntitySpecializationTicks, SpecializeMeshParams,
|
||||
};
|
||||
use bevy_render::render_resource::{CachedRenderPipelineId, SpecializeMeshParams};
|
||||
use bevy_render::view::RenderVisibleEntities;
|
||||
use bevy_render::RenderStartup;
|
||||
use bevy_render::{
|
||||
@ -596,6 +594,22 @@ impl<M> Default for EntitiesNeedingSpecialization<M> {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Resource, Deref, DerefMut, Debug)]
|
||||
pub struct EntitySpecializationTicks<M> {
|
||||
#[deref]
|
||||
pub entities: MainEntityHashMap<Tick>,
|
||||
_marker: PhantomData<M>,
|
||||
}
|
||||
|
||||
impl<M> Default for EntitySpecializationTicks<M> {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
entities: MainEntityHashMap::default(),
|
||||
_marker: Default::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Stores the [`SpecializedMaterial2dViewPipelineCache`] for each view.
|
||||
#[derive(Resource, Deref, DerefMut)]
|
||||
pub struct SpecializedMaterial2dPipelineCache<M> {
|
||||
@ -661,7 +675,7 @@ pub fn check_entities_needing_specialization<M>(
|
||||
}
|
||||
|
||||
pub fn specialize_material2d_meshes<M: Material2d>(
|
||||
params: SpecializeMeshParams<M, RenderMesh2dInstances>,
|
||||
params: SpecializeMeshParams<EntitySpecializationTicks<M>, RenderMesh2dInstances>,
|
||||
material2d_pipeline: Res<Material2dPipeline<M>>,
|
||||
mut pipelines: ResMut<SpecializedMeshPipelines<Material2dPipeline<M>>>,
|
||||
render_materials: Res<RenderAssets<PreparedMaterial2d<M>>>,
|
||||
|
@ -114,7 +114,7 @@ impl Plugin for Wireframe2dPlugin {
|
||||
};
|
||||
|
||||
render_app
|
||||
.init_resource::<EntitySpecializationTicks<Wireframe2dMaterial>>()
|
||||
.init_resource::<WireframeEntitySpecializationTicks>()
|
||||
.init_resource::<SpecializedWireframePipelineCache>()
|
||||
.init_resource::<DrawFunctions<Wireframe2dPhaseItem>>()
|
||||
.add_render_command::<Wireframe2dPhaseItem, DrawWireframe2d>()
|
||||
@ -489,6 +489,11 @@ pub struct WireframeEntitiesNeedingSpecialization {
|
||||
pub entities: Vec<Entity>,
|
||||
}
|
||||
|
||||
#[derive(Resource, Deref, DerefMut, Clone, Debug, Default)]
|
||||
pub struct WireframeEntitySpecializationTicks {
|
||||
pub entities: MainEntityHashMap<Tick>,
|
||||
}
|
||||
|
||||
/// Stores the [`SpecializedWireframeViewPipelineCache`] for each view.
|
||||
#[derive(Resource, Deref, DerefMut, Default)]
|
||||
pub struct SpecializedWireframePipelineCache {
|
||||
@ -677,7 +682,7 @@ fn extract_wireframe_2d_camera(
|
||||
|
||||
pub fn extract_wireframe_entities_needing_specialization(
|
||||
entities_needing_specialization: Extract<Res<WireframeEntitiesNeedingSpecialization>>,
|
||||
mut entity_specialization_ticks: ResMut<EntitySpecializationTicks<Wireframe2dMaterial>>,
|
||||
mut entity_specialization_ticks: ResMut<WireframeEntitySpecializationTicks>,
|
||||
views: Query<&ExtractedView>,
|
||||
mut specialized_wireframe_pipeline_cache: ResMut<SpecializedWireframePipelineCache>,
|
||||
mut removed_meshes_query: Extract<RemovedComponents<Mesh2d>>,
|
||||
@ -718,7 +723,7 @@ pub fn check_wireframe_entities_needing_specialization(
|
||||
}
|
||||
|
||||
pub fn specialize_wireframes(
|
||||
params: SpecializeMeshParams<Wireframe2dMaterial, RenderMesh2dInstances>,
|
||||
params: SpecializeMeshParams<WireframeEntitySpecializationTicks, RenderMesh2dInstances>,
|
||||
render_wireframe_instances: Res<RenderWireframeInstances>,
|
||||
wireframe_phases: Res<ViewBinnedRenderPhases<Wireframe2dPhaseItem>>,
|
||||
views: Query<(&ExtractedView, &RenderVisibleEntities)>,
|
||||
|
Loading…
Reference in New Issue
Block a user