[Solved] Extremely slow when using TextureAtlas, Why?

Anything libgdx related goes here!

Re: Extremely slow when using TextureAtlas, Why?

Postby mzechner » Sun Dec 19, 2010 7:28 am

TextureAtlas doesn't do any extra work when it comes to rendering. I assume you use TextureAtlas.newSprite() to get the sprite for the car? The code path will be same as when using a normal Texture in that case, so there's actually no overhead in rendering, both methods are 100% equivalent.

Unless Nate does something i don't know of yet.

It would help us if you could post the images you use, in the exact same format you use them on Android, along with your texture pack file. This way we can setup an equivalent test to your app on our side. Otherwise all we can do is guess :/
mzechner
Site Admin
 
Posts: 4879
Joined: Sat Jul 10, 2010 3:50 pm

Re: Extremely slow when using TextureAtlas, Why?

Postby NateS » Sun Dec 19, 2010 9:39 am

Sorry, I don't have any idea what is going on. TextureAtlas#getSprite returns a sprite exactly the same as "new Sprite" if the sprite has no whitespace removed when packed. Even if it did, it shouldn't affect rendering. We'll need example code showing the problem + any images required.
NateS
 
Posts: 1980
Joined: Fri Nov 12, 2010 11:08 am

Re: Extremely slow when using TextureAtlas, Why?

Postby gamefish » Sun Dec 19, 2010 4:43 pm

I uploaded the texture and pack file, please download them from here:
http://www.html5game.com/wp/wp-content/ ... ource1.png
http://www.html5game.com/wp/wp-content/ ... 10/12/pack
Note that I don't use the background in this file now. I just use the jeep at the right top.
Please test with them to see if you can find out any clue
More fancy android games at http://www.html5game.com
gamefish
 
Posts: 18
Joined: Sat Dec 18, 2010 4:20 am

Re: Extremely slow when using TextureAtlas, Why?

Postby consiliens » Mon Dec 20, 2010 2:03 am

gamefish wrote:I uploaded the texture and pack file, please download them from here:

It'd be nice to have executable example code also.
consiliens
 
Posts: 177
Joined: Wed Oct 27, 2010 6:55 am

Re: Extremely slow when using TextureAtlas, Why?

Postby gamefish » Mon Dec 20, 2010 8:18 am

update here again:
I repacked my texture atlas, now I have a 1024x128 atlas with my car in it. When I use this atlas to render my car, the performance is good. But when I use the old 1024x1024 atlas, it's still slow.
So my conclusion is a big atlas(big as 1024x1024) can cause performance issue, but a relatively small atlas like 1024x128 works just fine.

Maybe this is because the G2 video memory is not big enough?
More fancy android games at http://www.html5game.com
gamefish
 
Posts: 18
Joined: Sat Dec 18, 2010 4:20 am

Re: Extremely slow when using TextureAtlas, Why?

Postby gamefish » Mon Dec 20, 2010 8:20 am

consiliens wrote:
gamefish wrote:I uploaded the texture and pack file, please download them from here:

It'd be nice to have executable example code also.

sorry the code is just a chaos that I don't want to do a clean job and submit them up here. Please just grab the resource and load them using TextureAtlas, It's just less than ten lines of code. ;)
More fancy android games at http://www.html5game.com
gamefish
 
Posts: 18
Joined: Sat Dec 18, 2010 4:20 am

Re: Extremely slow when using TextureAtlas, Why?

Postby mzechner » Mon Dec 20, 2010 8:25 am

well, the G2 should be able to cope with a 1kx1k texture. It doesn't explain why the normal Texture approach would run faster either (hence we ask for the code, cause we don't see how that is possible). In general though it's always a good idea to trim down the texture size as much as humanly possible :)
mzechner
Site Admin
 
Posts: 4879
Joined: Sat Jul 10, 2010 3:50 pm

Re: Extremely slow when using TextureAtlas, Why?

Postby NateS » Mon Dec 20, 2010 9:23 pm

Last night I fixed an issue on a G1 where it was very slow just drawing a 730x777 image to the screen. Splitting it up into four 512x512 textures went from ~10fps to 50+ fps. If the G2 should handle the larger textures, I'm at a loss as to what you are seeing. You might just set the maxWidth and maxHeight on the TexturePacker settings to 512 to best support all devices.

I know you posted the packed images but I don't have bandwidth to write a test case at the moment. I also don't have a G2, only a G1 and Droid, so I'm not sure if that would help except to compare to what you are seeing.
NateS
 
Posts: 1980
Joined: Fri Nov 12, 2010 11:08 am

Re: Extremely slow when using TextureAtlas, Why?

Postby gamefish » Tue Dec 21, 2010 3:01 pm

So here is a test class I made, when I run this test on my G2, I get 5-6 fps when rendering the "map" sprite only, and 37 fps when rendering "jeep" sprite only. (without any debugger attached)

Could you guys please run this test when you have time, and tell me the result .

Just drop the attached java class into gdx-test project and download these two resource files and put them into data/tex
http://www.html5game.com/wp/wp-content/uploads/2010/12/resource1.png
http://www.html5game.com/wp/wp-content/uploads/2010/12/pack

Then add AtlasIssueTest.class into com.badlogic.gdx.tests.utils.GdxTests.tests
Attachments
AtlasIssueTest.zip
(1.01 KiB) Downloaded 284 times
More fancy android games at http://www.html5game.com
gamefish
 
Posts: 18
Joined: Sat Dec 18, 2010 4:20 am

Re: Extremely slow when using TextureAtlas, Why?

Postby BurningHand » Tue Dec 21, 2010 4:19 pm

Just ran some experiments with this on my ADP2. My findings:

Using as is:
5-6 fps with map sprite
42 fps with jeep sprite

Setting size of map sprite in pack file to the size of my screen (480 x 320):
61 fps

Setting size of jeep sprite in pack file to follow the power of two rule:
61 fps

Also:
I also tried it where I resize the sprite after load results in no improvement in fps.
Only changing it in the pack file itself made a difference.
IRC: nexsoftware / mobidevelop; GitHub: MobiDevelop;
BurningHand
 
Posts: 2812
Joined: Mon Oct 25, 2010 4:35 am

PreviousNext

Return to Libgdx

Who is online

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