mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-01 09:26:26 +00:00
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:
@@ -28,6 +28,7 @@
|
||||
#endif
|
||||
|
||||
#include "CameraMath.h"
|
||||
#include "GpuMemory.h"
|
||||
#include "InstanceCompose.h"
|
||||
#include "Log.h"
|
||||
|
||||
@@ -7735,6 +7736,25 @@ void ViewportCore::render() {
|
||||
}
|
||||
stats.gl_draw_calls = draw_calls;
|
||||
stats.indirect_sub_draws = last_sub_draws_;
|
||||
stats.vram_used_bytes = pool_.total_used_bytes();
|
||||
stats.vram_capacity_bytes = pool_.total_capacity_bytes();
|
||||
#if !defined(__EMSCRIPTEN__)
|
||||
if (!device_vram_poll_timer_.isValid()
|
||||
|| device_vram_poll_timer_.elapsed() >= 1000) {
|
||||
device_vram_poll_timer_.start();
|
||||
WGPUAdapterInfo adapter_info = WGPU_ADAPTER_INFO_INIT;
|
||||
wgpuAdapterGetInfo(adapter_, &adapter_info);
|
||||
const ifcviewer::GpuMemoryInfo mem =
|
||||
ifcviewer::queryGpuMemory(adapter_info.vendorID, adapter_info.deviceID);
|
||||
wgpuAdapterInfoFreeMembers(adapter_info);
|
||||
if (mem.valid) {
|
||||
device_vram_used_bytes_ = mem.used_bytes;
|
||||
device_vram_total_bytes_ = mem.total_bytes;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
stats.device_vram_used_bytes = device_vram_used_bytes_;
|
||||
stats.device_vram_total_bytes = device_vram_total_bytes_;
|
||||
host_->onFrameStats(stats);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user