Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (579)
games submitted by our members
Games in WIP (500)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Slow on Android, too many sprites ?  (Read 921 times)
0 Members and 1 Guest are viewing this topic.
Offline Cero
« Posted 2012-11-07 02:59:34 »

One of our games Black Nebula is quite slow on Android which much going on, meaning many enemies and shots.

Question is why exactly... I have now put eeeverything on one big 1024x1024 spritesheet because I thought it might be texture swapping, but didnt seem to help.

Since I can't really profile on Android, JProfiler on Desktop says that Display.swapBuffers takes a long time...
Does that mean that there are simply too many sprites on the screen ? / fillrate problem ?


Offline bach

Senior Member


Medals: 3
Projects: 2



« Reply #1 - Posted 2012-11-10 20:23:14 »

Unfortunately a little hard to tell without any more details. I see you are using libgdx?

Also - what hardware? How many sprites? What do you define as "slow"? Smiley

Give us some more insight into what goes on in your render loop and we might be able to point out a few weak spots. Fillrate issues could definitely be a candidate.

Cheers,
Bach
Offline davedes
« Reply #2 - Posted 2012-11-10 21:56:51 »

Debug your sprite batch with renderCalls to find out how many times per frame it's rendering/flushing.
1  
2  
3  
4  
5  
6  
7  
//at start of frame...
batch.totalRenderCalls = 0;

// ... render frame ...

//output the result somehow, e.g. sysout or LWJGL Display title
Display.setTitle("Calls: "+batch.totalRenderCalls);


Things that flush the batch:
  • Using a different texture
  • Changing the shader
  • Changing the projection matrix
  • Changing the view/transform matrix
  • Rendering more sprites than the batch size allows
For example, you should only change the projection matrix when the viewport/display is resized.

Other things to keep in mind:
  • Use nearest neighbour filtering where possible to improve performance
  • Minimize overdraw; i.e. for blending effects, use a shader instead of drawing sprites many times over each other
  • Try changing resolution... If the FPS improves dramatically, it may be an indication that your game is fill-rate limited.
  • Put an option to cap your particles, e.g. a slider UI, and try testing that on your Android to see if reducing particle count improves performance. If that's the case, it may be another indication that you are fill-rate bound

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Cero
« Reply #3 - Posted 2012-12-20 22:20:44 »

alright lets check this out again - havent worked on this game since

Debug your sprite batch with renderCalls to find out how many times per frame it's rendering/flushing.
1  
2  
3  
4  
5  
6  
7  
//at start of frame...
batch.totalRenderCalls = 0;

// ... render frame ...

//output the result somehow, e.g. sysout or LWJGL Display title
Display.setTitle("Calls: "+batch.totalRenderCalls);


Things that flush the batch:
  • Using a different texture
  • Changing the shader
  • Changing the projection matrix
  • Changing the view/transform matrix
  • Rendering more sprites than the batch size allows
Ok I get kinda 9 on average and like 16 if everything explodes (bomb)

For example, you should only change the projection matrix when the viewport/display is resized.
How do you do HUDs ?
I use a second camera and change projection matrix to it for HUD, when everything else was rendered.
I only have 2 textures (excluding the particle pngs), basically only 1, just the explosion effect is a large image getting bigger so this one is a texture by itself

Other things to keep in mind:
  • Use nearest neighbour filtering where possible to improve performance
  • Minimize overdraw; i.e. for blending effects, use a shader instead of drawing sprites many times over each other
  • Try changing resolution... If the FPS improves dramatically, it may be an indication that your game is fill-rate limited.
  • Put an option to cap your particles, e.g. a slider UI, and try testing that on your Android to see if reducing particle count improves performance. If that's the case, it may be another indication that you are fill-rate bound
Resolution well... I dont really have a problem on a low end PC, just android devices, but they even have 2 cores...
Im gonna try on my single core laptop to check out the performance there...

yes particles - I will double check, but I'm pretty positive that its not particles because I made this performance test:
I just stood still - enemies will come and corner you, and shoot - the hits on you is just a color filter going red on the player sprite
as more enemies approached it got slower

also going to check out on my new Galaxy S3, but I don't expect it to lag there.

Also different issue, well not really maybe, might be related.
For many reasons I wanna avoid delta timing stuff, so we have in all our games a 60 fps mode for desktop and a 30 fps mode for mobile where we just move everything twice as fast and do forth - because you can never know what the vsync fps is going to be on mobile
and my method of frame throttling may be suboptimal

Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

xsi3rr4x (41 views)
2014-04-15 18:08:23

BurntPizza (37 views)
2014-04-15 03:46:01

UprightPath (53 views)
2014-04-14 17:39:50

UprightPath (35 views)
2014-04-14 17:35:47

Porlus (52 views)
2014-04-14 15:48:38

tom_mai78101 (74 views)
2014-04-10 04:04:31

BurntPizza (133 views)
2014-04-08 23:06:04

tom_mai78101 (233 views)
2014-04-05 13:34:39

trollwarrior1 (195 views)
2014-04-04 12:06:45

CJLetsGame (203 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!