Like Tree1Likes
  • 1 Post By VirtualAce

Multi-threading a must for games?

This is a discussion on Multi-threading a must for games? within the Game Programming forums, part of the General Programming Boards category; This is a fairly general question. I plan on creating a 2d shoot-em-up game with C++ and SDL for graphics. ...

  1. #1
    Registered User Waleed Mujeeb's Avatar
    Join Date
    Jan 2012
    Posts
    22

    Multi-threading a must for games?

    This is a fairly general question. I plan on creating a 2d shoot-em-up game with C++ and SDL for graphics. With Enemy's following a certain predefined path or loop. I need to get input from user at same time.
    Will i need to use multi-threading? or i can do without it.

  2. #2
    Registered User
    Join Date
    Dec 2011
    Posts
    795
    Assuming you can get non-blocking user input, you technically don't need multi-threading.

  3. #3
    Registered User Waleed Mujeeb's Avatar
    Join Date
    Jan 2012
    Posts
    22
    That seems possible. Thanks, i might be able to do without semaphores.

  4. #4
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596
    For the most part.....no. Depending on what pieces you multi thread you could end up with a lot of synchronization overhead and crashes if you are new to threading. Most games that have been mutlithreaded to a heavy degree have had major issues. As well in Direct3D the device is not thread safe unless you specify D3DCREATE_MULTITHREAD in the create parameters. However MS recommends against this and instead recommend architecting the system so that the multi-threaded device is not needed. Input is a good candidate for threading but I'm not sure it gains you anything. A really good candidate for threading would be your update loop. Instead of having each object update itself by iterating through the list of visible objects you could tell all of the visible objects to update and notify when they are done. When they complete you can draw the frame. As well you can render-ahead and have several threads rendering several frames ahead so the frame is ready when you reach that point in time. There are some sync issues associated with this approach but they can be alleviated.

    The best candidates for multi-threading besides input are sound, scripts, data / resource caching (for games that cannot store the entire world in memory), etc.
    MK27 likes this.

  5. #5
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,249
    Creating threads to perform specific jobs is one of the primary causes of nightmares. Games can certainly benefit from parallelism, but threads are just the building blocks of parallelism, not the foundation of an architecture.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  6. #6

  7. #7
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596
    Sounds great. Unfortunately Rage had serious technical issues from the word go. And megatexture while cool in theory makes me wonder how many pixels of repeated data they are storing? No artists is going to paint every single texel on a world texture without using some kind of brush - aka repetitive texture - to get the job done quickly. So sure just because you 'can' paint every single texel in the world does not mean it is feasible. So if you are megatexturing just to store repeated textures...how is that any different than using 1 texture and repeating it (wisely) across the terrain or using texture splatting with 64 or 128 textures? I'm not sure any artist out there is asking for the ability to pain twelve trillion texels for a 512x512 world or larger.
    Last edited by VirtualAce; 04-08-2012 at 01:18 PM.

  8. #8
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,676
    Well, I was referring to threading comments in that video. I believe this video talks more on what the artists produce, and some of the challenges of delivering that content in-game on both PC's and consoles.

    https://www.youtube.com/watch?v=4zgYG-_ha28

    gg

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Using Multi-threading and/or Multi-process
    By lehe in forum C++ Programming
    Replies: 5
    Last Post: 07-14-2009, 11:43 AM
  2. Is Multi-threading necessary?
    By keira in forum Networking/Device Communication
    Replies: 2
    Last Post: 10-14-2007, 05:13 AM
  3. Multi Threading
    By beon in forum C Programming
    Replies: 5
    Last Post: 12-04-2006, 08:21 PM
  4. Multi-Threading
    By DeepFyre in forum C++ Programming
    Replies: 5
    Last Post: 09-30-2004, 06:13 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21