Skip to main content

molgfx_render/engine/
statistics.rs

1//! Allocation-free counters for compact ligand pose synchronization.
2
3use super::Engine;
4use crate::{DerivedCacheUsage, ResidencyCounters, ResidencyMetrics};
5use molgfx_gpu::Device;
6
7/// Counts from the most recent successful scene synchronization.
8///
9/// Pose counts describe candidates. Instance counts describe the analytic
10/// atom and bond impostors produced after reusable topology expansion.
11#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
12pub struct LigandPoseStats {
13    /// Candidates stored across all scene pose batches, including hidden and
14    /// zero-alpha candidates.
15    pub resident_poses: u64,
16    /// Alpha-positive candidates in visible batches whose owner is resident.
17    pub visible_poses: u64,
18    /// Candidates retained by the active realtime or cinematic workload policy.
19    pub selected_poses: u64,
20    /// Topology-expanded analytic instances submitted to beauty passes.
21    pub beauty_instances: u64,
22    /// Opaque analytic instances repeated by the enabled shadow route.
23    pub shadow_instances: u64,
24    /// Indirect draw groups across beauty and enabled shadow routes.
25    pub draw_groups: u32,
26}
27
28impl<D: Device> Engine<D> {
29    /// Returns current and peak recomputable cache charges in constant time.
30    #[must_use]
31    pub const fn derived_cache_usage(&self) -> DerivedCacheUsage {
32        self.derived_cache.usage()
33    }
34
35    /// Returns real workspace and lifecycle counters without scanning scene data.
36    #[must_use]
37    pub fn residency_metrics(&self) -> ResidencyMetrics {
38        self.scene_gpu.residency_metrics()
39    }
40
41    /// Returns flat cumulative counters plus the current resident-byte gauge.
42    #[must_use]
43    pub fn residency_counters(&self) -> ResidencyCounters {
44        self.residency_metrics().counters()
45    }
46
47    /// Returns compact ligand workload counters without scanning the scene.
48    #[must_use]
49    pub fn ligand_pose_stats(&self) -> LigandPoseStats {
50        let stats = self.scene_gpu.ligand_pose_statistics();
51        LigandPoseStats {
52            resident_poses: stats.resident_poses,
53            visible_poses: stats.visible_poses,
54            selected_poses: stats.selected_poses,
55            beauty_instances: stats.beauty_instances,
56            shadow_instances: stats.shadow_instances,
57            draw_groups: stats.draw_groups,
58        }
59    }
60}