Skip to main content

viewport_lib/renderer/
stats.rs

1//! Per-frame performance counters for the viewport renderer.
2
3/// Per-frame rendering statistics.
4#[derive(Debug, Clone, Copy, Default)]
5pub struct FrameStats {
6    /// Total objects considered for rendering.
7    pub total_objects: u32,
8    /// Objects that passed visibility and frustum tests.
9    pub visible_objects: u32,
10    /// Objects culled by frustum or visibility.
11    pub culled_objects: u32,
12    /// Number of draw calls issued in the main pass.
13    pub draw_calls: u32,
14    /// Number of instanced batches (0 when using per-object path).
15    pub instanced_batches: u32,
16    /// Total triangles submitted to the GPU.
17    pub triangles_submitted: u64,
18    /// Number of draw calls in the shadow pass.
19    pub shadow_draw_calls: u32,
20}
21
22#[cfg(test)]
23mod tests {
24    use super::*;
25
26    #[test]
27    fn test_frame_stats_default_is_zero() {
28        let stats = FrameStats::default();
29        assert_eq!(stats.total_objects, 0);
30        assert_eq!(stats.visible_objects, 0);
31        assert_eq!(stats.culled_objects, 0);
32        assert_eq!(stats.draw_calls, 0);
33        assert_eq!(stats.instanced_batches, 0);
34        assert_eq!(stats.triangles_submitted, 0);
35        assert_eq!(stats.shadow_draw_calls, 0);
36    }
37}