Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I am working on a little game engine. All major features are implemented yet, despite game logic which I assume not to be such a computational effort. The framerate is at least around 40 FPS, most of the time above 60 FPS.

I would like to speed up my engine now. There are several performance heavy tasks, like physics simulation and collision detection where I use Bullet Physics for, geometry drawing and texturing, deferred lighting, post effects like SSAO. Later on maybe character animation and artificial intelligence may add up.

How to find the bottleneck in such a typical OpenGL game? I am not familiar with profilers, and I have no idea how to use them, especially with asynchronous code like Bullet Physics.

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

Profiling (and adjusting code where necessary). There's different profiling software available (your compiler might provide built-in hooks for this or bring the tools like GCC and MSVC do) that won't require you to actually edit or modify your code just to take measurements.

The easiest - and most generic way to do it (which will require modifications of your codebase) - would be adding several measurements on your own, e.g. track how long it takes to render backgrounds, track how long it takes to render objects, track how long it takes to process shaders, etc.

For example, this page shows you some example screenshots on how this is presented when using the Unreal Engine 3. You don't need any fancy things for this, you don't even have to print it on screen (just log it somewhere).

One important thing to note: If you're running Windows, make sure you don't write anything to the console window; or at least try not to flush the output too often (e.g. by using std::endl). This can slow you down quite a bit compared to any real work being done.

share|improve this answer
3  
I'd remove the "maybe" in "Maybe some profiling software". Profiller will do exactly what are you suggesting in the second paragraph. It will just do it for every method/function/procedure. –  sm4 Jun 7 '13 at 10:25
    
For profiling software, I would suggest SlimTune. Worked for me and it is open source. –  Jon Jun 7 '13 at 10:47
    
Intended it to be "you could use", but will just reword it. ;) –  Mario Jun 7 '13 at 10:49
    
How to profile asynchronous tasks like Bullet Physics? I guess if there are are two tasks running on the same core, the bottleneck one will slow down both. How to detect which one is the actual reason? And how to profile OpenGL shaders? I heard that OpenGL calls in C++ code just add tasks to a quene of the video card and may return before the draw call actually is performed. –  danijar Jun 7 '13 at 11:22
    
If you'd just change the first word from Debugging to Profiling I'd vote you up :-) You start with the wrong word and then say mostly the right thing - Profiling is the only way to optimize –  Mark Mullin Jun 7 '13 at 11:33
show 3 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.