Suckless OGL 1.0.0
A lean, high-performance C11 PBR Renderer
Loading...
Searching...
No Matches
gpu_usage.h
Go to the documentation of this file.
1#ifndef GPU_USAGE_H
2#define GPU_USAGE_H
3
4#include <stdbool.h>
5#include <stdint.h>
6#include <stdio.h>
7
8enum {
11};
12
25typedef struct {
26 FILE* streams[GPU_USAGE_MAX_FDS];
28
31
34 char engine_key[GPU_USAGE_MAX_KEY_LEN];
35
38
44
49
55
59float gpu_usage_get_load(const GPUUsageMonitor* mon);
60
65
66#endif /* GPU_USAGE_H */
void gpu_usage_update(GPUUsageMonitor *mon)
Re-reads fdinfo streams and computes GPU load %. Should be called periodically (e....
Definition gpu_usage.c:340
float gpu_usage_get_load(const GPUUsageMonitor *mon)
Returns the last computed GPU load (0.0–100.0).
Definition gpu_usage.c:347
void gpu_usage_init(GPUUsageMonitor *mon)
Scans /proc/self/fdinfo/ and opens streams for GPU engine time reading.
Definition gpu_usage.c:321
bool gpu_usage_is_available(const GPUUsageMonitor *mon)
Returns true if a supported DRM driver was detected.
Definition gpu_usage.c:355
void gpu_usage_cleanup(GPUUsageMonitor *mon)
Closes all open fdinfo streams.
Definition gpu_usage.c:331
@ GPU_USAGE_MAX_FDS
Definition gpu_usage.h:9
@ GPU_USAGE_MAX_KEY_LEN
Definition gpu_usage.h:10
Reads GPU utilization % via Linux DRM fdinfo (same method as MangoHud).
Definition gpu_usage.h:25
int stream_count
Definition gpu_usage.h:27
uint64_t prev_gpu_time_ns
Definition gpu_usage.h:29
bool available
Definition gpu_usage.h:36
float load_percent
Definition gpu_usage.h:32
uint64_t prev_wall_time_ns
Definition gpu_usage.h:30