-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[utils] Support CPU/GPU stats analytics #1295
Comments
Most games on Steam list their minimum required RAM and VRAM. It would be handy to have some sort of way to get a raylib program to spit out the maximum amount of RAM and VRAM it ever used while running, so that we know what to put for the minimum required stats for games we publish that were made using raylib. What do you think? |
@Obscure2020 Actually that's some of the information intended to be provided by this new feature. |
Wonderful. I am in support of these features! |
@raysan5 Maybe the big GPU and CPU profiler https://github.com/wolfpld/tracy/ can give some impressions. |
I up vote this, and would enjoy a way to know what OpenGL/GLSL support the system has prior to saying; yes the game will run fine. |
This sounds like a good idea. |
It would be useful to get the monitor frame rate if possible... |
I personally have found an easy way to get the Monitor Refresh rate; |
I've been investigating this improvement a bit further. Supporting this kind of stats data requires hooking multiple functions and designing an specific system just for it. Here some ideas: CPU RAM memory usageEvery time // core
LoadFileData();
LoadFileText();
// textures
LoadImage();
LoadImageRaw();
LoadImageAnim();
LoadImageColors();
LoadImagePalette();
GenImage*();
LoadTexture();
LoadTextureFromImage();
LoadTextureCubemap();
LoadRenderTexture();
// text
LoadFontEx();
LoadFontFromImage();
LoadFontData();
// models
LoadModel();
LoadModelFromMesh();
UploadMesh();
GenMesh*();
LoadMaterials();
LoadMaterialDefault();
LoadModelAnimations();
// audio
LoadWave();
LoadSound();
LoadSoundFromWave();
LoadWaveSamples();
LoadMusicStream();
LoadAudioBuffer(); GPU VRAM memory usageAll GPU memory allocations go through // Vertex buffers
rlLoadVertexBuffer(); // glBufferData()
rlLoadVertexBufferElement(); // glBufferData()
// Textures
rlLoadTexture(); // glTexImage2D()
rlLoadTextureDepth(); // glTexImage2D()
rlLoadTextureCubemap(); // glTexImage2D()
// FBO use texture attachments
// Shaders
rlLoadShaderProgram(); // glLinkProgram() GPU one frame analytics
GPU capabilities ->
|
Knowing gpu memory I find a useful metric as it can inflate fast if not careful or if out of control. The other metric imho would be all of the features the GPU supports in order to know fi we can use either OpenGL 1.1 or 2.1 or 3.3 or greater. |
@jmorel33 Just edited my previous comment to add additional info. Agree that GPU data is probably the most important one. As commented, supporting it requires LOT of code automation and some redesigns to store all required stats. At this point I'm evaluating the real benefits for the standard raylib users. |
Added config flag: SUPPORT_GL_DETAILS_INFO
Not sure of the automation that is required? One that allows or disallows features because of an OpenGL version? Essentially removing this burden from the programmer? Of course that would be great but I would not necessarily expect this but would be great. That said I would prefer a more recent openGL version support than the type of automation as to me it is more important. For for the beginner, having an automated way of enabling features is great. |
Some questions/ideas regarding this:
#if defined(ENABLE_STATS_SYSTEM)
stats.vram.textures += X;
stats.vram.total += X;
#endif |
Other people might have different preferences, but as I envisioned it, one ENABLE_STATS_SYSTEM might be the easiest to use. That way, it would be a single thing to turn on, compile, run, get stats. Then you could remove that single setting afterwards. I also envisioned "Only print a summary on shutdown." You're right that printing every change could become quite console intensive, and while possibly useful for some people, access at runtime might not be completely necessary. The way I saw it, I'd like to program a game, turn on ENABLE_STATS_SYSTEM, compile, run, and then while running the program keep track of how much RAM and VRAM (and other stats) it's currently using. Then, when the program shuts down, it would print out a stats summary including the highest RAM and VRAM usage it reached while running, and the results of other stats tracking. |
I just want to be able to pull the live stats of how much GDDR is used and how many triangles processed, just like how many FPS is used. I do not need a function to print the value on the screen I just need the value and let me do what I want with it. |
Maybe something like:
That way we get the best of both worlds. |
My short answer is that while I like this Idea. I think if you were going to actually do this, and do it properly, more consideration would need to be given to the API functionality as presented around the creation of the underlying data types, and that more than likely some sort of thin management layer would need to be presented. Without the proper management layer and api calls, there is entirely to much assumption that the only way data will be created and memory will be allocated is through the function calls currently present, or the RL_ allocation/deallocation/reallocation methods. Any creation of these data types by the end user that falls outside of these functions would be entirely dependent on the user to properly implement hooks into this stat tracking system, which IMHO makes it entirely to prone to user error/mistakes to make it worthwhile. It would be easy to blame the end user for not knowing or doing something right, but it still does not change the end result that the system would then be inaccurate. |
The reason why this is an important to have feature is as anything else;
etc etc We are making games, game engines, etc and we need tools. Half of my development time is concentrated on tracing, debugging tools, and analytics... |
Some more thoughts on this feature: We can differentiate two types of analysis:
1. Global stats analysis (CPU and GPU)Analyze: CPU memory usageMemory allocations should be recorded and properly tagged with data type, it would require some additional identifier for each piece of data loaded. Ideally, extra information for each piece of data should be saved...
Analyze: GPU memory usageGPU memory allocations should be recorded and properly tagged and identified. Extra information should be saved for every piece of data.
IMPLICATIONS:
2. Single Frame stats analysis (GPU)It will imply analyzing the state for a single frame:
Indepent time values depend on user use of the library (i.e.
Draw calls should be recorded individually as well as the draws saved by batching.
Resource usage (OpenGL active state) should be recorded by draw call. That implies A LOT of information recorded to be managed every frame. After this analysis, I decided that at this moment this feature is out-of-scope for raylib, it seems more proper for a higher level engine that has more control over the game scenegraph. Anyone with the need for a single-frame stats analysis could use RenderDoc, actually, that's the tool I used for raylib performance analysis. |
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:
Data loading can be registered with:
RL_MALLOC()
/RL_CALLOC()
/RL_FREE()
glBufferData()
,glTexImage2D()
,glShaderSource()
updateTime
,drawTime
,idleTime
This issue is a draft, just some notes. Need to think about the best way to organize/record this information.
The text was updated successfully, but these errors were encountered: