bonsaiviewer: show pool and device VRAM in the performance stats

FrameStats gains the geometry pool's used/capacity bytes and, on desktop,
the device-wide used/total reported by the driver (NVML via dlopen, or
amdgpu/i915 sysfs, matched to the wgpu adapter's vendor/device id so a
switchable-graphics laptop reports the card wgpu actually picked). The
device query is polled once a second, not per frame. Web has no VRAM
query, so the device figure is omitted there.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Dion Moult
2026-08-23 13:32:59 +10:00
parent 5fa14c3dea
commit b7d2b2fa3a
7 changed files with 313 additions and 3 deletions
+10
View File
@@ -38,6 +38,16 @@ struct FrameStats {
std::uint32_t unique_meshes;
std::uint32_t gl_draw_calls; // wgpu draw-call count; name kept for bonsai parity
std::uint32_t indirect_sub_draws; // sub-draws packed into the chunk-indirect lists
// Chunk geometry pool occupancy (see BufferPool). wgpu exposes no
// adapter-wide VRAM query, so this is the viewer's own allocation,
// not the device total.
std::uint64_t vram_used_bytes;
std::uint64_t vram_capacity_bytes;
// Whole-device VRAM from the driver (NVML / sysfs, see GpuMemory.h).
// Desktop only; zero on web or when no backend could answer, so
// consumers must treat 0 as "unknown" rather than as empty.
std::uint64_t device_vram_used_bytes;
std::uint64_t device_vram_total_bytes;
};
#endif // IFCVIEWER_FRAMESTATS_H