Fix MaterialDiagnosticPlugin using meshes as suffix
This commit is contained in:
parent
93f7a3f09d
commit
6a94ba406c
@ -8,11 +8,29 @@ use bevy_render::{Extract, ExtractSchedule, RenderApp};
|
||||
|
||||
use crate::{Material, MaterialBindGroupAllocator};
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct MaterialAllocatorDiagnosticPlugin<M: Material> {
|
||||
suffix: &'static str,
|
||||
_phantom: PhantomData<M>,
|
||||
}
|
||||
|
||||
impl<M: Material> MaterialAllocatorDiagnosticPlugin<M> {
|
||||
pub fn new(suffix: &'static str) -> Self {
|
||||
Self {
|
||||
suffix,
|
||||
_phantom: PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<M: Material> Default for MaterialAllocatorDiagnosticPlugin<M> {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
suffix: " materials",
|
||||
_phantom: PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<M: Material> MaterialAllocatorDiagnosticPlugin<M> {
|
||||
/// Get the [`DiagnosticPath`] for slab count
|
||||
pub fn slabs_diagnostic_path() -> DiagnosticPath {
|
||||
@ -37,7 +55,7 @@ impl<M: Material> Plugin for MaterialAllocatorDiagnosticPlugin<M> {
|
||||
Diagnostic::new(Self::slabs_size_diagnostic_path()).with_suffix(" bytes"),
|
||||
)
|
||||
.register_diagnostic(
|
||||
Diagnostic::new(Self::allocations_diagnostic_path()).with_suffix(" meshes"),
|
||||
Diagnostic::new(Self::allocations_diagnostic_path()).with_suffix(self.suffix),
|
||||
)
|
||||
.init_resource::<MaterialAllocatorMeasurements<M>>()
|
||||
.add_systems(PreUpdate, add_material_allocator_measurement::<M>);
|
||||
|
||||
@ -71,7 +71,7 @@ fn check_standard_material_leak() {
|
||||
..Default::default()
|
||||
},
|
||||
RenderAssetDiagnosticPlugin::<PreparedMaterial<StandardMaterial>>::new(" materials"),
|
||||
MaterialAllocatorDiagnosticPlugin::<StandardMaterial>::default(),
|
||||
MaterialAllocatorDiagnosticPlugin::<StandardMaterial>::new(" standard materials"),
|
||||
))
|
||||
.add_systems(Startup, mesh_setup)
|
||||
.add_systems(
|
||||
@ -132,7 +132,7 @@ fn check_standard_material_churn_leak() {
|
||||
..Default::default()
|
||||
},
|
||||
RenderAssetDiagnosticPlugin::<PreparedMaterial<StandardMaterial>>::new(" materials"),
|
||||
MaterialAllocatorDiagnosticPlugin::<StandardMaterial>::default(),
|
||||
MaterialAllocatorDiagnosticPlugin::<StandardMaterial>::new(" standard materials"),
|
||||
))
|
||||
.add_systems(Startup, mesh_setup)
|
||||
.add_systems(
|
||||
@ -197,7 +197,7 @@ fn check_standard_material_churn_insert_leak() {
|
||||
..Default::default()
|
||||
},
|
||||
RenderAssetDiagnosticPlugin::<PreparedMaterial<StandardMaterial>>::new(" materials"),
|
||||
MaterialAllocatorDiagnosticPlugin::<StandardMaterial>::default(),
|
||||
MaterialAllocatorDiagnosticPlugin::<StandardMaterial>::new(" standard materials"),
|
||||
))
|
||||
.add_systems(Startup, mesh_setup)
|
||||
.add_systems(
|
||||
|
||||
Loading…
Reference in New Issue
Block a user