2
\$\begingroup\$

I'm making a 2D game for Android Mobile using LibGDX and Java in Android Studio. My game mostly runs alright with 60FPS, but for some time to time it lowers to 50FPS. I'm trying to find out what causes it. I came across this profiler and implemented it and here are the values in a very "messy" frame with lots of objects going around and messing around:

06-19 15:14:21.088 9999-10033/com.gadarts.parashoot.android I/GL Report - Calls: 498
06-19 15:14:21.088 9999-10033/com.gadarts.parashoot.android I/GL Report - Draw Calls: 37
06-19 15:14:21.088 9999-10033/com.gadarts.parashoot.android I/GL Report - Shader Switches: 8
06-19 15:14:21.088 9999-10033/com.gadarts.parashoot.android I/GL Report - Bindings: 36
06-19 15:14:21.088 9999-10033/com.gadarts.parashoot.android I/GL Report - Vertex Count: 31.945946

My question is how am I supposed to know if these are considered to be high values or low? I read the LibGDX documentation but it doesn't give any direction or indication about the values effect. Yes, it might be an opinion-based question, but at least someone can give relevant direction using these values?

Thanks in advance

\$\endgroup\$
  • \$\begingroup\$ "how am I supposed to know if these are considered to be high values or low?" You can compare them with values from ok-ish frames. Other than that: 31.945.946 - 31 million vertices are a looot. Not sure what they mean with "Calls", but Draw Calls, Shader Switches and Bindings are very low \$\endgroup\$ – Maik Semder Jun 19 '17 at 13:55
  • \$\begingroup\$ Are you sure the bottleneck is the graphics card? Did you profile the CPU side of things? \$\endgroup\$ – Maik Semder Jun 19 '17 at 13:56
2
\$\begingroup\$

There are no definitive "bad" or "good" value, but in general fewer calls are better since you spend less time doing what you're doing (e.g. drawing to the screen). The only way to know if your numbers are good or bad is to experiment. Those numbers are not there to give you definitive answers to what's going wrong they're there to help you and to point you in the right direction.

I'll give an example from one of my own prototypes: I profiled my draw calls and the number of objects on screen. I did this during normal gameplay and when my frames dropped below a certain value. The resulting numbers looked something like this:

Low Load
--------
Number of Draw Calls (avg) | Number of Objects (avg) | Type of Object
100                        | 1200                    | Mostly enemies

This didn't tell me very much all by itself. But look at the numbers when I experienced lag:

High Load
--------
Number of Draw Calls (avg) | Number of Objects (avg) | Type of Object
500                        | 2100                    | Mostly particles

Whoa! I didn't even double my amount of objects on the screen but the number of draw calls increased five-fold! This is an indicator that something is wrong. In this case it turned out that my particle batching didn't work as expected which led to necessary flushing of the batch, increasing the amount of draw calls.

This is basically what you have to do. Trial and error, just testing and trying to figure out what could be the cause of the increase. My biggest tip is to profile more than just the raw numbers - profile amount of objects and what type of objects you're dealing with. This might help you notice that when a certain object enters play you experience these drops.

\$\endgroup\$
  • \$\begingroup\$ +1 very good answer imho. Gathering numbers is one thing, finding out what is Cause and Effect is the next step and usually much more complicated \$\endgroup\$ – Maik Semder Jun 19 '17 at 14:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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