+void GPUMemoryStats::update()
+{
+ if (!supported) {
+ return;
+ }
+
+ GLint total, dedicated, available, evicted, evictions;
+ glGetIntegerv(GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX, &total);
+ glGetIntegerv(GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX, &dedicated);
+ glGetIntegerv(GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX, &available);
+ glGetIntegerv(GPU_MEMORY_INFO_EVICTED_MEMORY_NVX, &evicted);
+ glGetIntegerv(GPU_MEMORY_INFO_EVICTION_COUNT_NVX, &evictions);
+
+ if (glGetError() == 0) {
+ metric_memory_gpu_total_bytes = int64_t(total) * 1024;
+ metric_memory_gpu_dedicated_bytes = int64_t(dedicated) * 1024;
+ metric_memory_gpu_used_bytes = int64_t(total - available) * 1024;
+ metric_memory_gpu_evicted_bytes = int64_t(evicted) * 1024;
+ metric_memory_gpu_evictions = evictions;
+
+ if (verbose) {
+ printf(", using %d / %d MB GPU memory (%.1f%%)",
+ (total - available) / 1024, total / 1024,
+ float(100.0 * (total - available) / total));
+ }
+ }
+}