Skip to main content
gamedev.net
🔒 Locked

Multithreading in DirectX

Started by Ninj4D4n 4 replies 850+ views
Original Post
Ninj4D4n
Ninj4D4n
Hi all, This post is related to my earlier one "AI thinking in DirectX". Do people generally write there games multithreaded when working in DirectX? If so.. what for? examples? If not... why not? Any and all comments would be helpful, i''m a pretty average to advanced C++ programmer and i''m trying my hand at game programming now, so thanks again for any help you can offer --Ninj4D4n
Pseudo
Pseudo
The classical way is to put everything into one game loop (ie, not multithreading) however, with Hyper Threaded processors comeing out, I suspect that will change. It would seem logical to keep some stuff in a single thread like all graphics in one, but you could just as well move input into it''s own, and AI into multiple threads. That way, those with HT processors will get a large performance boost.
Pseudo
Pseudo
Oh yeah, if you want more info on HT processors, I suggest TomsHardware.com they wrote several informative articles on the subject.
seacow
seacow
Once you start programming multiplayer DirectPlay, you will need to consider multithreaded. If this is your first fray into multithreaded, I''d recommend this, since Microsoft already has working samples, and with DX9 you can emulate a network connection (in case you don''t have one). It will teach you quite a bit about keeping your code clean and readable. Be warned, it is tough to debug a mulithreaded app. and a very steep learning curve once you start.

If you are already a pro, then go for it. It''s not like the technology is going to go backwards any time soon and it will give you a leg up on the rest of us who do everything in a single game loop.
thona
thona
I find it pretty hard to get more done in multiple threads on games besides decoupling the UI from a game server (running on a separate thread and hanling the logic). For SOME games you could also put the AI into a separate thread (as a separate client). The main problem being to locate parts where Multi Threading gives you something, besides added complexity.


Regards

Thomas Tomiczek
THONA Consulting Ltd.
(Microsoft MVP C#/.NET)
RegardsThomas TomiczekTHONA Consulting Ltd.(Microsoft MVP C#/.NET)
Zimans
Zimans
I myself use multi-threading to seperate the game loop and the windows message pump.

The main thread sits in the message loop handling messages making windows happy while my game runs happiy in it''s own thread. By doing this I never have to worry about always getting back to the main part of the loop to handle messages. If I need to sit in an internal loop somewhere for some function it''s not a problem.

-Zims

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.