Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (577)
games submitted by our members
Games in WIP (498)
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  
  libGDX rendering performance  (Read 2996 times)
0 Members and 2 Guests are viewing this topic.
Offline jobiho

Senior Newbie





« Posted 2013-06-27 20:12:01 »

Hi there,

I am currently developing a game where I need to render a lot of dynamic small tiles.
One tile is 6x6px targeting a resolution of 1024x768 resulting in a tile-count of 170x128=21760 tiles.

On the desktop I get a decent framerate of 400fps whereas on my test device (acer a500 tegra2) I only get about 20fps :/.

Keeping in mind that the gamelogic, ki, etc. is excluded in this test, I would be happy with a framerate of about 50fps on the tablet.

I am only! rendering tiles that are visible and there are no unnecessary texture binds involved.

Here is the code that is called for each tile:
1  
2  
3  
4  
5  
   @Override
   public void renderTile(short tileId, int screenX, int screenY) {
      batch.setColor(tileProvider.getTile(tileId).color);
      batch.draw(tileTexture, screenX - tileMap.getTileSize(), screenHeight - screenY - tileMap.getTileSize());
   }


Is there any chance to improve this?

Thanks in advance Smiley
Offline jobiho

Senior Newbie





« Reply #1 - Posted 2013-06-27 20:39:01 »

Of course all (all tiles) batch.draw() calls are called between batch.begin() / batch.end().
Offline Cero
« Reply #2 - Posted 2013-06-27 20:53:25 »

Check out this thread: http://badlogicgames.com/forum/viewtopic.php?f=11&t=9420
Rendering many tiles requires some optimization

Btw: 6x6 tiles ? why so small D=
never seen anything under 16x16

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline jobiho

Senior Newbie





« Reply #3 - Posted 2013-06-27 21:01:39 »

Hm thank you for the link but I guess caching is no solution to my problem.

The tiles (and that's why I choosed 6x6 for them) are part of a dynamic sandgame style map.
That means each tile could interact with each other tile at any given moment.
Offline davedes
« Reply #4 - Posted 2013-06-28 16:03:42 »

Maybe you would benefit from building your own batcher.
https://github.com/mattdesl/lwjgl-basics/wiki/LibGDX-Textures

But it sounds more like you need a highly optimized particle system. Or something like this, with some tweaking to work on OpenGL ES:
http://www.java-gaming.org/topics/rendering-tiles-fast-isometric-too/25292/view.html

21,760 tiles is a lot. To break it down; that's 43,520 triangles, or 130,560 vertices. If each vertex has position, (packed) color, and texcoords, then you are sending 5 floats per vertices, or 652,800 floats to the GPU per frame. Maybe there are some ways you could reduce this. For example; perhaps you could make some of the data static on the GPU.

Also ensure that your problem isn't coming from setColor or some other part of your code. Do some basic profiling to see what's up.

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 (23 views)
2014-04-15 18:08:23

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

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

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

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

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

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

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

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

CJLetsGame (190 views)
2014-04-01 02:16:10
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

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:05:20
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!