#[derive(Clone, Copy, Debug, Default)]
pub struct PoolReport {
pub count: u32,
pub bytes: u64,
}
#[derive(Clone, Copy, Debug, Default)]
pub struct AtlasReport {
pub pages: u32,
pub bytes: u64,
pub entries: u32,
}
#[derive(Clone, Copy, Debug, Default)]
pub struct WgpuCounters {
pub enabled: bool,
pub buffers: i64,
pub textures: i64,
pub bind_groups: i64,
pub buffer_memory: i64,
pub texture_memory: i64,
}
#[derive(Clone, Copy, Debug, Default)]
pub struct MemoryReport {
pub images: PoolReport,
pub atlas: [AtlasReport; 2],
pub targets: PoolReport,
pub host_buffer: PoolReport,
pub contours: PoolReport,
pub glyph_paths: PoolReport,
pub ramps: PoolReport,
pub raster_cache: PoolReport,
pub wgpu: WgpuCounters,
}
impl MemoryReport {
pub fn total_bytes(&self) -> u64 {
self.images.bytes
+ self.atlas.iter().map(|a| a.bytes).sum::<u64>()
+ self.targets.bytes
+ self.raster_cache.bytes
+ self.host_buffer.bytes
+ self.contours.bytes
+ self.glyph_paths.bytes
}
}
pub(crate) fn wgpu_counters(device: &wgpu::Device) -> WgpuCounters {
let hal = device.get_internal_counters().hal;
WgpuCounters {
enabled: cfg!(feature = "counters"),
buffers: hal.buffers.read() as i64,
textures: hal.textures.read() as i64,
bind_groups: hal.bind_groups.read() as i64,
buffer_memory: hal.buffer_memory.read() as i64,
texture_memory: hal.texture_memory.read() as i64,
}
}