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.

So I'm creating a game and I would like to know how to perform resource streaming (rather than loading the whole file into the buffer) for things such as my maps, sounds, music, etc. I'm using C++ and DirectX9 if in case you need to know.

share|improve this question
    
As far as sound and music go, you don't want to stream sound effects because of latency problems. I would recommend FMOD or Wwise to integrate sound into your game. For the other streaming problems, hopefully you will get a proper answer. –  Jonathan Connell Aug 18 '11 at 13:53
add comment

4 Answers 4

A note, setting off multiple reads will be slower because the disk I/O keeps seeking around to pull bits of data from each open request.

To get around this I created an intermediate streaming traffic cop that prioritized multiple async read requests and serialized them to the OS. In your own game you can create priorities based on data type or how soon the new data will be needed so that audio can come in first to avoid skipping and far away data will be loaded last.

A note on audio: you do want to stream audio because data is pretty large, but you want your game to stream the data before it's needed because waiting for the actual "Play sound" call before loading will cause all sorts of delay and spoil the user experience.

Since background loading and preparing data is a complex sequence of events involving threads, callbacks and voodoo that spans several systems in your game I suggest designing the interactions carefully before laying down any code to avoid massive debugging headaches later.

share|improve this answer
    
Another note: instrument your entire streaming module thoroughly, disk throughput is limited and you'll need to know when/if you reach those limits. Your designers will love you for giving them clear, on screen diagnostics of how their levels are behaving! –  Patrick Hughes Aug 18 '11 at 18:14
add comment

It's more than just streaming the assets — the disk itself is a mechanical device and you need to minimize seeks and simultaneous parallel streams. So you need to chunk up your data so it can be streamed en masse, and then evicted all at once without any risk of leaks.

I liked DoubleFine's GDC talk about their chunking solution.

share|improve this answer
    
+1 because this is a modern solution, a meta-design to streaming that would like neatly on top of my lower level observations above, and a good link. –  Patrick Hughes Aug 20 '11 at 19:10
add comment

Specifically re streaming world data, I believe it was GPG's Dungeon Siege that was the first well-known title to achieve this really efficiently for a really large 3D world. It enabled the modern MMO (post the whole tile-based Ultima Online era).

Here's an article where Scott Bilas outlines the solutions they used. I don't doubt it would help to do further searches on the same topic. I seem to recall a GamaSutra article, but not too sure. Could be the same one.

I am sure things have come a long way since then, but that should get you started.

share|improve this answer
    
thanks I'll look into this. Btw, for anyone who is wondering, by resource streaming I mean, for example, creating a seamless map using multiple files that will be "glued" together once the player gets near to the edge of one file's data. –  Josh Vega Aug 18 '11 at 15:50
    
That is a good article by Scott, but please note in his blog that also goes over that article he mentions the way they did things was awesome at the time, but not the way to do it in this day and age any longer :) –  James Aug 18 '11 at 23:35
add comment

You want to use the concept of chunks or pack files or the like where the entire chunk is streamed. The chunk should contain the data that it needs when used in the game. World Geo, specific models for that area, textures, sound effects, scripts and the like. It should not contain background audio, that should be a streaming system on its own.

You really dont want to read an individual packed file for each of these, but you definitely do not want to read each individual asset. The FileIO will kill any overhead. (Ideally the chunk files are all packed together into one large file you can just fseek() through to get to the right chunk you want to load)

Hope this helps.

share|improve this answer
add comment

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.