MT libraries in modern games.

Started by
5 comments, last by Dirk Gregorius 6 years, 11 months ago

Hi Forum!

Till today I have used WINAPI functions/sync primitives and Microsoft’s PPL in pipeline.
It seems, that VS 2015 had some changes from VS 2010 in C++ std implementation, which is not as slow as it used to be.
I am going to start using MT in my game.
Target platform: PC. XBO in far future, PS4 – not sure.

I would like to know, what libraries are popular in modern (AAA) games?
There are some options:

1. C++ std library.
2. WINAPI + RAII wrappers (ATL/WTL/...)
3. Custom in-house made library.
4. Other well known library not listed here

Are there some gamedev-related topics, that are different from Windows Desktop development?
Are there some gamedev-related caveats that I should be aware of?
If game developers use custom libraries, what is difference from std library?

Thanks in advance!

Advertisement

c++ standard library all the way

If your target platforms are relatively up to date, C++ standard library is the most convenient and portable option.

If you happen to have a ton of multithreading code lying around from pre-2011, though, there's nothing wrong with using it still.

For new projects I'd personally prefer std stuff over hand-rolled wrappers.

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]

There's a lot of stuff in the PPL or any modern game engine that's not present in std though. So it's fine to use std to create threads and synchronize them with each other, signal/wait/etc... But on top of that you'll have to build your own thread pool and task queue.

Your questions about what YOU should do in YOUR game, and what AAA Studios do in AAA games, those are different.

People in AAA studios doing AAA games have budgets of tens of millions of dollars, and have over a thousand development-years to build their stuff. The studios rely on tools that are old and well-established, as well as tools that are new and heavily customized. While the teams can use the standard c++ threading libraries if they choose, generally there are enough small details they want to control that they don't use it. It isn't because the general-purpose libraries are bad, instead it is that they need more specific control than the general purpose libraries offer.

But YOU working alone or with a small team on YOUR game probably do not have a budget of tens of millions of dollars or thousands of work years. You probably have a budget of a handful of dollars and less than a single work year. You cannot afford to do the customization. So for you and your game, probably the standard library will be the easiest tool available, the least error-prone, and the most portable. You should probably use the ones in the c++ standard library, or the ones provided in another higher-level library of your choice. It isn't because the specialized libraries are bad, instead it is that you probably don't have resources to invest in the nuanced specialized details and the general forms are adequate.

Note that this is true of many features of the standard library. The standard library provides a wide range of general purpose functionality. It is what you should use in most cases for general purposes. However, there are times when you need special purposes, and that's when you need to use a special purpose library. Whenever game developers tell me they won't be using the standard libraries, my first question is to ask what specific issue they are trying to overcome. For example, not using the standard library's container system because it doesn't provide intrusive containers or containers with pre-established memory buffers needed for a specific task. Other times people let their lack of knowledge or their fears dictate using a non-standard library, which is usually a poor reason. If you are on a large team and can spend the time and effort on customized versions for specific problems, then you can do so to save those few precious nanoseconds. But if you don't have the resources, the general purpose libraries are probably the best thing for your code.

Thank you all for help!

So, C++ standard library.

Summed up:
1. There is no significant overhead in VS implementation compare to native WINAPI calls.
2. It is available on XBO and PS4 and is not banned by platform vendors (like Microsoft do for CreateFile():
“Minimum supported client: Windows XP [desktop apps only]”
3. MT principles in gamedev are much the same as in general C++ programming, and C++ standard library is a good low level abstraction layer to build games on top of it.

I also found Intel's Threading Building Blocks library very useful. It has nice parallel_for and other useful concepts which are very handy quite often.

https://www.threadingbuildingblocks.org/

This topic is closed to new replies.

Advertisement