Skip to content

[utils] Support CPU/GPU stats analytics #1295

Description

@raysan5

It could be useful to keep track of some CPU/GPU analytics, like memory usage.

Info already displayed on initialization: GPU vendor, renderer, version, GLSL version

Data loading memory usage:

  • CPU: Images / Sounds / MusicStream / Font.chars
  • GPU: Textures / Shaders / Meshes / Font.texture

Data loading can be registered with: RL_MALLOC() / RL_CALLOC() / RL_FREE()

enum StatsMemType {
    CPU_RAW_DATA,
    CPU_VERTEX_DATA, 
    CPU_IMAGE, 
    CPU_TEXT, 
    CPU_FONT_DATA,
    CPU_AUDIO_BUFFER, 
    GPU_VERTEX_BUFFER, 
    GPU_TEXTURE, 
    GPU_SHADER, 
    GPU_FBO
} StatsMemType;

// Global memory usage stats
struct StatsMemAlloc {
    int id;
    int type;               // StatsMemType 
    unsigned int size;      // Size in bytes
} StatsMemAlloc;

#define STATS_MEM_RECORD(int type, int size) StatsMemAlloc(type, size)
  • GPU memory allocations (VRAM): glBufferData(), glTexImage2D(), glShaderSource()
  • Frame times: updateTime, drawTime, idleTime
  • Draw calls counter (and batching)
  • Textures information (# textures, id, format, samplerState)

This issue is a draft, just some notes. Need to think about the best way to organize/record this information.

typedef struct GpuStats {	// 1 frame? General? → FrameStats?
	int drawsCount;
	int vertexCount;
	int trianglesCount;
	int texturesCount;	// total? used in frame?
	int texturesMemory;	// in bytes
	int vertexMemory;	// in bytes, in CPU/GPU?
	float timeUpdate;	// in seconds
	float timeDraw;		
	float timeIdle;
} GpuStats;

Metadata

Metadata

Assignees

No one assigned

    Labels

    new featureThis is an addition to the library

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions