Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Profiling a graphics rendering without a profiler

Nowadays we have pretty advanced tools to iron out rendering, allowing to see the different stages, time taken by draw calls, etc. But without them the graphics pipeline is quite a black box when it comes to understand what is happening inside.

Suppose for some reason you have no such tool, or a very limited one. How would you measure anyway what is taking time in your rendering?

I am aware of tricks like discarding draw calls to see the CPU time, setting a 1x1 viewport to see the cost of geometry, using a dumb fragment shader to highlight the fillrate... They are useful already but only give a rough idea of what is going on, and tell nothing about the level of parallelism.

Also, getting the time spent in each stage per draw call seem to be difficult, especially when taking into account the lack of precision due to the noise when measuring.

What tricks do you use when your backpack is almost empty and you still have to profile your rendering? What is your personal Swiss army knife consisting in?

like image 940
Julien Guertault Avatar asked Jul 14 '11 06:07

Julien Guertault


2 Answers

Frame time rendering time

Absolute time spent for small code/stage/etc. is not that relevant as GPU driver optimization/batching/parallelism/version makes it nearly impossible to have precise code measure without GPU counters. (which you can get if you use with vendors libs)

What you can measure easily is each single code change impact. You'll only get relative impact, and it's what you really need anyway. And that just using frame rendering time.

Ideally you should aim be able can edit shader or pipeline code during runtime, and have a direct way to check impact over a whole typical scene, like just comparing graphs between several code path. (beware of static scenes, otherwise you'll end with highly optimized static views, but poor dynamic scenes performance)

Here's the swiss army knife list:

  • scene states loader
  • scene recorder (camera paths/add-remove entities,texture, mesh, fake input, etc.) using scene states.
  • scene states saver
  • scene frame time logger (not just final average but each frame rendering time)
  • on-the-fly shader code reload
  • on-the-fly codepath switch
  • frame time log reader+graphs+statistic framework

Note that scene state load/save/record are handy for a lot of other things, from debugging to undo/redo to on-the-fly reload, not to mention savegames. Add a screenshot taker + image diff, and you can unit test graphic code too.

If you can, add that to your CI server so that huge code impact doesn't go unnoticed. (helps also artists when they check-in their assets, without evaluating rendering impact) A must read on that related CI graphic test work is there : http://aras-p.info/blog/2011/06/17/testing-graphics-code-4-years-later/

like image 132
Tuan Kuranes Avatar answered Nov 01 '22 02:11

Tuan Kuranes


Note: I'm responding to the question: "Profiling a graphics rendering with a profiler", since that something I was looking for ;)

I'm working mostly on Mac, and I'm using multiple tools:

  • gDebugger version 5.8 is available on Windows and Mac (this tool has been bought by AMD, the v6 version is Windows only). It gives you statistics about state changes, texture usage, draw calls, etc. It's also usefull to debug texture mapping, and see how your scene is drawn, step by step.
  • PVRUniSCoEditor it's a shader editor. It compiles on the fly and give you precious details about estimated cycles and registers usage.
  • Instruments (from XCode Utilities, OSX only), it gets informations from the OpenGL driver, it's great to find bottleneck since you can track what part of the GPU is used at 100% (tiler, renderer, texture unit, etc...)
  • Adreno Profiler a Windows tool to profile Adreno-based mobile devices. (Very good tool if you work on Android apps ;))

What's your trick about the "dumb fragment shader to highlight the fillrate" ? (drawing a plain color ? or something more advanced ?)

like image 28
Maxime Avatar answered Nov 01 '22 00:11

Maxime