Jump to content
  • Advertisement
Sign in to follow this  
Mille

Threads in game engines

This topic is 5122 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've been thinking, is anyone using multi CPU threads in their engines for the rendering part ? I was thinking of having a seperate thread for doing the 2D panel rendering, for instance the crosshair, player info, text messages etc. The purpose is speed, but I haven't heard or read about engines which uses more than one CPU thread for the entire rendering job. Any input on this ?

Share this post


Link to post
Share on other sites
Advertisement
The major problem is coordinated access to the hardware. Which thread can send commands when? What about things like render states?

Remember also that most desktop machines only have 1 CPU. As such you're faking parallelism with two threads by constantly 'switching' between the two. That switch isn't free; what you end up with is something that actually takes longer to execute on most systems. (Of course, if your user has a multiprocessor system, then you'll get gains).

The exception is single-CPU parallelism systems like Hyperthreading. With Hyperthreading you can reasonably run two threads concurrently *provided* they are doing different kinds of thing (e.g. one doing AI/calculations, one doing rendering). The reason is that Hyperthreading works by letting you run a second thread in the 'unused' parts of the CPU (for example, if you're copying stuff into a vertex buffer on one thread, the floating point math unit would likely be unused, so you could be doing some physics stuff at the same time). Two threads doing similar tasks is actually worst case - they end up repeatedly waiting for each other.

Share this post


Link to post
Share on other sites

Thanks for clearing things up superpig, I will stick to just getting the GPU working in parallel with the CPU.

Anyway, what happened to the Enginuity series ? Such cool articles!! ?

I must emit I have the Enginuity task system in my engine :)

Share this post


Link to post
Share on other sites
I think Etnu did a big thing saying that moving your rendering calls to a seperate thread sped things up.

*shrug*

~Main

Share this post


Link to post
Share on other sites
Quote:
Original post by duhroach
I think Etnu did a big thing saying that moving your rendering calls to a seperate thread sped things up.
It can do, but it depends very heavily on how you do it. You can't just move the code into a seperate thread and expect it to work.

The RTS Perimeter took this approach, btw. It had one thread for rendering, and one thread for everything else. The rendering thread ran at vsync, and the other ran at a fixed rate, something like 10FPS. Each game data structure was split into two halves, with the second half replicating the first half from the previous frame - the rendering thread would then interpolate between the two sets of data.

The result, on hyperthreading systems, was something like a 40% speed increase.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!