Mike36

My understanding of the game loop in XNA (excluding setup and teardown) is:

1. Update

2. Draw

I know there are benefits to multithreading an application but am unsure how to apply that to game design. I'm stuck on the idea that you need to complete all your updates for game state, running scripts, and so on, before you move on to drawing.

The only benefit to multithreading during the Update stage that I see would be to get update tasks done faster. But all the threads would have to finish up their work before moving on to drawing. Actually, that's what I do with my Earth Orbit demo: I have a thread that computes the day-night texture on the fly as Earth rotates during its day. This happens as a background task so that it is ready for the next draw.

Perhaps someone more experienced can point me in the right direction for use of multithreading in games, specifically XNA It would be nice to make use of those quad core processors coming out...

-Mike

P.S. I figured out how to do simple animations by positioning and rotating sub-meshes on my model. It takes code to do it, but that's ok, I'm going to have a scripting system in my game. Think of C# compiled during level loading.



Re: XNA Game Studio Express Game Design Question: Multithreading

Leaf.

There are a couple of presentations here that cover multi threaded game design. The others are worth a read too.

Cheers,
Leaf.






Re: XNA Game Studio Express Game Design Question: Multithreading

Mike36

Thanks for the links. I read through the presentation and gained some insight on use of threading for games (it is very helpful when doing network management systems). Interesting to note that the presentation suggested doing updates on a single thread due to overhead with synchronization and communication with other update threads. I can foresee having a thread compile my game scripts (via CompileAssemblyFromSource) while another loads level data. But when it comes to updating game data, everything goes on the update thread.



Re: XNA Game Studio Express Game Design Question: Multithreading


Re: XNA Game Studio Express Game Design Question: Multithreading

Mike36

Great article, thanks! Does give me something to think about.