Sign in to follow this  

Threads in game engines

This topic is 4815 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
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
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

This topic is 4815 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this