From c9f454509f2d0305b9ebfcb2b56435cf4c135a3b Mon Sep 17 00:00:00 2001 From: Dmitry Stepanov Date: Sat, 4 Jul 2026 21:03:33 +0300 Subject: [PATCH] print dynamic surface cache stats --- fyrox-impl/src/renderer/cache/mod.rs | 4 ++++ fyrox-impl/src/renderer/mod.rs | 1 + fyrox-impl/src/renderer/stats.rs | 5 +++++ 3 files changed, 10 insertions(+) diff --git a/fyrox-impl/src/renderer/cache/mod.rs b/fyrox-impl/src/renderer/cache/mod.rs index f57515e25..6861b45f9 100644 --- a/fyrox-impl/src/renderer/cache/mod.rs +++ b/fyrox-impl/src/renderer/cache/mod.rs @@ -277,6 +277,10 @@ impl DynamicSurfaceCache { } } + pub fn alive_count(&self) -> usize { + self.cache.len() + } + /// Clears the surfaces in the cache, does **not** clear the cache itself. pub fn clear(&mut self) { for surface in self.cache.values_mut() { diff --git a/fyrox-impl/src/renderer/mod.rs b/fyrox-impl/src/renderer/mod.rs index f3e645a72..0e89a3f2c 100644 --- a/fyrox-impl/src/renderer/mod.rs +++ b/fyrox-impl/src/renderer/mod.rs @@ -1447,6 +1447,7 @@ impl Renderer { self.statistics.texture_cache_size = self.texture_cache.alive_count(); self.statistics.shader_cache_size = self.shader_cache.alive_count(); self.statistics.uniform_buffer_cache_size = self.uniform_buffer_cache.alive_count(); + self.statistics.dynamic_surface_cache_size = self.dynamic_surface_cache.alive_count(); Ok(()) } diff --git a/fyrox-impl/src/renderer/stats.rs b/fyrox-impl/src/renderer/stats.rs index 3a5ae1531..8ffd51b01 100644 --- a/fyrox-impl/src/renderer/stats.rs +++ b/fyrox-impl/src/renderer/stats.rs @@ -144,6 +144,8 @@ pub struct Statistics { pub texture_cache_size: usize, /// The total number of vertex+index buffers pairs in the geometry cache. pub geometry_cache_size: usize, + /// The total number of cached dynamic buffers. + pub dynamic_surface_cache_size: usize, /// The total number of shaders in the shaders cache. pub shader_cache_size: usize, /// The total number of uniform buffers in the cache. @@ -171,6 +173,7 @@ impl Display for Statistics { let pipeline_stats = &self.pipeline; let texture_cache_size = self.texture_cache_size; let geometry_cache_size = self.geometry_cache_size; + let dynamic_surface_cache_size = self.dynamic_surface_cache_size; let shader_cache_size = self.shader_cache_size; let uniform_buffer_cache_size = self.uniform_buffer_cache_size; write!( @@ -183,6 +186,7 @@ impl Display for Statistics { {pipeline_stats}\n\ Texture Cache Size: {texture_cache_size}\n\ Geometry Cache Size: {geometry_cache_size}\n\ + Dynamic Surface Cache Size: {dynamic_surface_cache_size}\n\ Shader Cache Size: {shader_cache_size}\n Uniform Buffer Cache Size: {uniform_buffer_cache_size}\n", ) @@ -206,6 +210,7 @@ impl Default for Statistics { frames_per_second: 0, texture_cache_size: 0, geometry_cache_size: 0, + dynamic_surface_cache_size: 0, shader_cache_size: 0, uniform_buffer_cache_size: 0, frame_counter: 0,