Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I have ~100 sprites for each level im my XNA game. On windows it takes ~2 seconds to load them all. Unfortunately on XBOX360 it takes ~30-60 seconds. Am i doing something wrong? Essentially the loading code ist just like this:

Texture2D sprite1 = levelContent.Load<Texture2D>("images/level_1/my_sprite_1");
...
Texture2D sprite100 = levelContent.Load<Texture2D>("images/level_1/my_sprite_100");

(i use an own content manager for each level to release all level-specific textures at once) Of course i can reduse the ammount of sprites using a spritesheet, but it's extremly painfull for me now. Do i have a better option? And just curious - why is there such huge difference in image loading time?

share|improve this question
    
Do you just have really high-end PC? –  Anko Dec 9 '12 at 19:11
    
i5-430M, nvidia gt420M, 1gb vram, 4gb ram laptop –  AvrDragon Dec 9 '12 at 19:17
    
The reason Windows is so quick is probably down to the cache built in to the operating system. I'd bet that the first load after a reboot is much slower. –  Adam Dec 9 '12 at 19:40
add comment

2 Answers

up vote 2 down vote accepted

Seek times are a big problem on xbox. Combining all files into an archive to remove directory indexing helps a little bit. Either combine them into a sprite sheet or combine then into a single binary file which you read in one chunk and seperate in memory.

My experience is mostly from the DVD drive of the xbox, but the hdd is very slow too. At least on the DVD the Xbox does additional seeks for checking the directory index, which often take more time than the actual data reading. Reducing the number of files will give you the biggest benefit thought. As you have level based resources you can basically reduce it to one file which should give you a very fast load time.

This looks pretty promising and includes a section about getting it to run on xbox too. I didn't check the license, you should do that. I looked into it for a minute and it looks like you can modify it easily to load a complete file into memory and than seperating it in memory. You should do that, zip each level into a single file, load it in one chunk and than seperate the textures in memory.

share|improve this answer
1  
Make sure that, if you are using ZIP files to store all your assets, you make them uncompressed. XNB files are already compressed by the content pipeline (unless you opt out of it) and double compression will increase CPU time when loading the assets. –  r2d2rigo Dec 12 '12 at 10:57
    
True, you should profile which compression is faster in your case. By the way could you give us a number of how much disk space your 100 sprites currently require? –  Archy Dec 12 '12 at 11:18
add comment

File I/O is extremely slow on Xbox. You have to refactorize your code and start using spritesheets if you want decent load times. And it would be even better if you compress those atlases with DXT texture compression so their size is smaller.

share|improve this answer
    
Seek times are the main problem. Combining all files into an archive to remove directory indexing helps a little bit. Either combine them into a sprite sheet or combine then into a single binary file which you read in one chunk and seperate in memory. –  Archy Dec 9 '12 at 19:44
    
@Archy So you mean without folders i will get a performance boost? –  AvrDragon Dec 9 '12 at 23:45
1  
Yes. My experience is mostly from the DVD drive of the xbox, but the hdd is very slow too. At least on the DVD the Xbox does additional seeks for checking the directory index, which often take more time than the actual data reading. Reducing the number of files will give you the biggest benefit thought. As you have level based resources you can basically reduce it to one file which should give you a very fast load time. What format are your files in? –  Archy Dec 9 '12 at 23:57
    
You do not generate mipmaps on texture load, do you? –  Archy Dec 10 '12 at 0:03
    
@Archy i am using XNA for 2d game, so i am not sure, wether i can just zip it all with easyzip. The sprites are in XNB format. But at least i can try to delete all folders like "sprites/level_1, sprites/level_2 etc." and keep all sprites in just one folder. –  AvrDragon Dec 12 '12 at 9:34
show 2 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.