Reloading openGL assets on android

Started by
8 comments, last by Ed Welch 11 years, 1 month ago

My new game on android has bigger models and textures than my previous game.

The design I used for my previous game is a menu activity which would then call my play-level activity.

The player would choose an item from the menu, and the game activity would load.

This worked fairly well when I didn't have alot of assets. On good devices loading was almost instantaneous.

But now, my new game needs about 15 seconds to load the models and textures.

Most of the time is spent on parsing the model files and turning them into binary data for VBOs.

The other part is spent decompressing JPEGs & turning them into texture bitmaps.

I know I can reduce loading time by having my models saved in binary VBO format in the first place, and saving my textures in a GPU compressed format. But I view that as a messy solution. I only want one set of data, I shouldn't have to load it over and over. From my PC experience, I'd tackle this problem by keeping everything in global RAM, load it once when the game starts, and keep it in RAM until the game is closed. Perhaps even keep it the GPU if possible.

As far as I can tell Android requires me to have isolated RAM for different activities. So when the play-level activity ends, my data goes bye bye. And thus every time the player goes back to the menu, I reload the assets.

Of course, I can start with the play-level activity first, and have that then call the menu. But again that seems messy, why should I load the play-level activity before the player started playing?

Does anyone have a good suggestion for a design pattern here?

My Oculus Rift Game: RaiderV

My Android VR games: Time-Rider& Dozer Driver

My browser game: Vitrage - A game of stained glass

My android games : Enemies of the Crown & Killer Bees

Advertisement

But now, my new game needs about 15 seconds to load the models and textures.
Most of the time is spent on parsing the model files and turning them into binary data for VBOs.
The other part is spent decompressing JPEGs & turning them into texture bitmaps.

Sounds like you've got the problem solved already.

For PC and major consoles you use a DDS format. No decompression necessary and it is handled by the card on PC and on the big consoles. This dramatically improves texture memory sizes and texture loading speeds.

For Android you get to choose between ETC1 (supported by everyone) and optionally choose between PVRTC, ATITC, and S3TC, depending on which specialized hardware you want to support.

That will get rid of much of your known bottleneck.

If you do end up using ETC1, just know that it doesn't support Alpha, but there are workarounds.

http://en.wikipedia.org/wiki/Ericsson_Texture_Compression

I still have the problem of my models, and level files...

My Oculus Rift Game: RaiderV

My Android VR games: Time-Rider& Dozer Driver

My browser game: Vitrage - A game of stained glass

My android games : Enemies of the Crown & Killer Bees

I still have the problem of my models, and level files

I really can't think of anything other then going for custom binary format file. I think its well worth the trouble of implementing it though. I was using .dae(collada) models before, it was taking anywhere around 30 second to 1 minute depeding how many models to read. After implementing a CBF it took around 5 seconds to load all models. So my advice would be none other then CBF.

But even 5 seconds is plenty of time. After I've got the models in memory loading them over and over seems like a waste of the user's time.

My Oculus Rift Game: RaiderV

My Android VR games: Time-Rider& Dozer Driver

My browser game: Vitrage - A game of stained glass

My android games : Enemies of the Crown & Killer Bees

But even 5 seconds is plenty of time. After I've got the models in memory loading them over and over seems like a waste of the user's time.

I am sorry if I m missing something but I am not sure what you ment by loading them over and over. your models should be loaded on the memory before you start your game. you shouldn't be loading models again and again during game play. that will surely slow things down. Once you got your models all loaded, you just show what you want to show and ignore the ones you don't need.

Also you don't need to load the same models again once you loaded them to the memory once. As an example , lets say you have a zombie npc model. and if you have 10 of these zombies on your game, you only need to load the zombie once. not 10 times. same things applies to your textures. if you have a textures that is shared by different models, you don't need to load textures for these models again. you simply use the same texture.

The problem is that my menu is a different android activity. It is the activity that launches the "play level" activity. Think "angry birds" here. When the user exits to the menu, and then re-enters the "play level" mode, I relaunch the activity and have to load everything again. This is because once the activity is disposed of, all the memory it allocated is also gone.

My Oculus Rift Game: RaiderV

My Android VR games: Time-Rider& Dozer Driver

My browser game: Vitrage - A game of stained glass

My android games : Enemies of the Crown & Killer Bees

The problem is that my menu is a different android activity. It is the activity that launches the "play level" activity. Think "angry birds" here. When the user exits to the menu, and then re-enters the "play level" mode, I relaunch the activity and have to load everything again. This is because once the activity is disposed of, all the memory it allocated is also gone.

Well. I still don't see a problem here. waiting couple of seconds before a level loads is perfectly acceptable. even angry bird has that. my 5 second example was in a 3D game environment where models has skeletal animation data, position vertices, normal vertices and text coords as well as vertex weights. The entire scene is made by approximately 20k vertices. I am not sure how complex your scene is but I would suggest you not to disregard CBF without trying it.

I advise using compressed textures (i.e PVR), or if quality is an issue use compressed Targa. RLE compressed Targa loads much faster than PNG or jpg.

Also, if loading a file do not load it byte by byte, load it all in one block.

This topic is closed to new replies.

Advertisement