Squeezing out extra performance of ShapeRenderer

Anything libgdx related goes here!

Squeezing out extra performance of ShapeRenderer

Postby FTLRalph » Wed May 08, 2019 4:32 pm

Pre-emptive sorry for the vague question, but vague answers are accepted ;)

I have an app that has heavy use of ShapeRenderer for vector-based drawing. Hundreds to thousands of shapes at 60fps. I already do as much as I can think of to get the best performance possible (blending off etc) I've even cloned ShapeRenderer class and made my own modifications (removed safety checks/line vs fill checks etc) to reduce as much logic as possible.

But I'm wondering if there's any outside-the-box stuff I can do to make it even better. Things I wouldn't even know to ask about/google about? Gotta say performance isn't "bad" right now, but depends on the device I suppose.

Thanks for any input/ideas
FTLRalph
 
Posts: 212
Joined: Sun Mar 17, 2013 11:34 pm
Location: CT, USA

Re: Squeezing out extra performance of ShapeRenderer

Postby shatterblast » Wed May 08, 2019 6:37 pm

LWJGL2 probably remains faster in the majority of LibGDX's aspects and may generally serve better in Android builds focused on 2D. Besides carrying better device support, though, LWJGL3 offers faster performance in a few key areas, including in certain areas that involve 3D. If you have not already, you might give LWJGL3 a try to see if you can squeeze out any extra Frames per Second.
shatterblast
 
Posts: 414
Joined: Sun Jul 06, 2014 1:14 pm

Re: Squeezing out extra performance of ShapeRenderer

Postby FTLRalph » Wed May 08, 2019 7:18 pm

shatterblast wrote:LWJGL2 probably remains faster in the majority of LibGDX's aspects and may generally serve better in Android builds focused on 2D. Besides carrying better device support, though, LWJGL3 offers faster performance in a few key areas, including in certain areas that involve 3D. If you have not already, you might give LWJGL3 a try to see if you can squeeze out any extra Frames per Second.


Interesting, that's something I didn't think of, worth looking into
Not sure if Android compatibility is an issue, like Opengl ES 2 vs 3 will have to see
FTLRalph
 
Posts: 212
Joined: Sun Mar 17, 2013 11:34 pm
Location: CT, USA

Re: Squeezing out extra performance of ShapeRenderer

Postby shatterblast » Wed May 08, 2019 7:24 pm

I think OpenGL ES 3 is backwards compatible up to a certain point, maybe depending on a single device's video drivers, but I have not tried it myself. Significantly older devices might have a compatibility issue, like perhaps Android 4 stuff. Assuming you use the Google Play Console, you might get something from Google's automated testing in a Pre-Launch Report when uploading your app to an Open Track Beta. That would just provide extra confirmation besides doing a test by yourself with an Android emulator.
shatterblast
 
Posts: 414
Joined: Sun Jul 06, 2014 1:14 pm

Re: Squeezing out extra performance of ShapeRenderer

Postby evilentity » Wed May 08, 2019 7:34 pm

Hard to guess without an example, but if shapes are not scaled or very complex often caching them in fbo might be worth checking out.
Looking for a freelancer? PM me!
Check out libgdx discord server!
evilentity
 
Posts: 4854
Joined: Wed Aug 24, 2011 11:37 am

Re: Squeezing out extra performance of ShapeRenderer

Postby captainflyaway » Wed May 08, 2019 8:34 pm

Try calculating all stuff once, store it in a float and use it in one method.

The lines
Code: Select all
renderer.vertex(x + width, y, z);
and
Code: Select all
renderer.vertex(x + width, y, z + depth);

appear often in the same method.

(I dont know how good java actually optimizes that anyway).
captainflyaway
 
Posts: 237
Joined: Mon Feb 20, 2017 7:52 am


Return to Libgdx

Who is online

Users browsing this forum: Google [Bot] and 1 guest