$darkmode
Suckless OGL 1.0.0
A lean, high-performance C11 PBR Renderer
gpu_usage.h File Reference
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
Include dependency graph for gpu_usage.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  GPUUsageMonitor
 Reads GPU utilization % via Linux DRM fdinfo (same method as MangoHud). More...
 

Enumerations

enum  { GPU_USAGE_MAX_FDS = 64 , GPU_USAGE_MAX_KEY_LEN = 48 }
 

Functions

void gpu_usage_init (GPUUsageMonitor *mon)
 Scans /proc/self/fdinfo/ and opens streams for GPU engine time reading. More...
 
void gpu_usage_cleanup (GPUUsageMonitor *mon)
 Closes all open fdinfo streams. More...
 
void gpu_usage_update (GPUUsageMonitor *mon)
 Re-reads fdinfo streams and computes GPU load %. Should be called periodically (e.g., every 500ms). More...
 
float gpu_usage_get_load (const GPUUsageMonitor *mon)
 Returns the last computed GPU load (0.0–100.0). More...
 
bool gpu_usage_is_available (const GPUUsageMonitor *mon)
 Returns true if a supported DRM driver was detected. More...
 

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
GPU_USAGE_MAX_FDS 
GPU_USAGE_MAX_KEY_LEN 

Function Documentation

◆ gpu_usage_cleanup()

void gpu_usage_cleanup ( GPUUsageMonitor *  mon)

Closes all open fdinfo streams.

◆ gpu_usage_get_load()

float gpu_usage_get_load ( const GPUUsageMonitor *  mon)

Returns the last computed GPU load (0.0–100.0).

◆ gpu_usage_init()

void gpu_usage_init ( GPUUsageMonitor *  mon)

Scans /proc/self/fdinfo/ and opens streams for GPU engine time reading.

◆ gpu_usage_is_available()

bool gpu_usage_is_available ( const GPUUsageMonitor *  mon)

Returns true if a supported DRM driver was detected.

◆ gpu_usage_update()

void gpu_usage_update ( GPUUsageMonitor *  mon)

Re-reads fdinfo streams and computes GPU load %. Should be called periodically (e.g., every 500ms).