- Modifié
Draw rate optimizations
Please give me an advise about optimizing spine object's rendering.
To get deeper why our characters drawing so slow, we removed all attachments/slots/bones and put there one big with one bone/slot. After that we got raised our FPS from 21 to 33 with 250 spine objects on the scene. Now we assume bones/slots/attachments count directly affects on our draw rate
So is there any way to achieve 33 FPS without removing any bone.
Any help would be appreciated.
We use Libgdx nightly, latest Spine, runtimes versions.
Outputs are in JSON format.
We have 18 bones for each character.
Packed atlas is 256x256 size.
No meshes.
What device are you testing on?
Figure out the images you are drawing, multiply their width times height and add them all up. This is how many pixels you draw. If you are on mobile, likely you are fill rate limited, so to improve the frame rate you need to draw fewer pixels. In your test you likely improved the fill rate because your one large image has fewer pixels than all your smaller images combined.
You should try to reduce the amount of whitespace in each image. Eg, imagine a sword at 45 degrees, the image will have a lot of whitespace. Rotate the sword so the overall image size is smaller and the amount of whitespace is reduced.
Another way to draw less whitespace is using meshes. This is supported in spine-libgdx. Meshes can use slightly less, the same, a little more, or a lot more CPU than a region attachment. Minimize the number of mesh vertices to minimize the CPU usage. Eg, 3 mesh vertices is more efficient CPU-wise than a region attachment, 4 is the same, and more than 4 is less efficient. It is only a small amount of CPU used per vertex. If you are fill rate limited then trading CPU for fill rate is a good deal. One downside to using meshes is you need to use PolygonSpriteBatch to render, which has different performance characteristics than SpriteBatch.
Thank you for quick response.
We use Android devices.
Do you mean Attachment Region number doesn't affect badly on fill rate. If the pixels number is the same as in the single Attachment Region, then they will draw in same time?
Also please tell how scale ratio affects on fill rate. If we scale down characters then as you said pixels will be drawn less and FPS will go higher?
It depends what your bottleneck is. If the bottleneck is fill rate it means you draw more pixels than the GPU can draw in the time allowed. In that case nothing else matters except for how many pixels you draw.
Yes, with a smaller scale you will draw fewer pixels. GL samples the texture, so if using a texture larger than needed GL may not be able to cache very well: every read is at a significantly different texture location. You could see a performance improvement with the right size texture, then GL can load a chunk of the texture and get more than one sample from it. But this is low level, focus on fill rate, if that is indeed your problem.
Note these are standard OpenGL performance limitations, not specific to Spine. You can Google for more info. OpenGL usage on iOS and Android (and to a lesser extent, desktop) is applicable to your situation.
Thank you very much Nate.