Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualEWClay

Posted 20 February 2013 - 07:58 AM

I'll have another go at explaining why ray casts in many game engines are asynchronous and why that's important for performance.

Let's assume that the physics is already multithreaded, as this is often the case. Let's assume also that game logic and AI are not multithreaded, because that's quite difficult to do correctly. So game logic and AI are taking up a big portion of the frame time, and any calculations that can be offloaded to another thread will be a win.

Now consider ray casts. Game logic and AI may require thousands of them. Line of sight checks for AI. Damage tests for weapons. They are performed by the physics engine, which is thread safe already.

So you tell the game programmers they can use all the ray casts they want as long as they request them early and use the result later. A queue builds up all the requests for raycasts in a frame. Then, at a suitable point they are all processed. The main thread is notified that the results are ready. Everyone is happy, and the game programmers don't complain about slow ray casts anymore.

The article I linked to is a classic. It isn't academic and dreamy. It's about reality. The next generation of consoles will have eight cores (http://www.eurogamer.net/articles/df-hardware-spec-analysis-durango-vs-orbis). The PS3 already has that many. PCs won't be far behind.

Concurrency isn't "a tool that has its place", it runs through the whole design of a modern game engine, and will be even more important as time goes on.

#1EWClay

Posted 20 February 2013 - 02:35 AM

I'll have another go at explaining why ray casts in many game engines are asynchronous and why that's important for performance.

Let's assume that the physics is already multithreaded, as this is often the case. Let's assume also that game logic and AI are not multithreaded, because that's quite difficult to do correctly. So game logic and AI are taking up a big portion of the frame time, and any calculations that can be offloaded to another thread will be a win.

Now consider ray casts. Game logic and AI may require thousands of them. Line of sight checks for AI. Damage tests for weapons. They are performed by the physics engine, which is thread safe already.

So you tell the game programmers they can use all the ray casts they want as long as they request them early and use the result later. A queue builds up all the requests for raycasts in a frame. Then, at a suitable point they are all processed. The main thread is notified that the results are ready. Everyone is happy, and the game programmers don't complain about slow ray casts anymore.

The article I linked to is a classic. It isn't academic and dreamy. It's about reality. The next generation of consoles will have eight cores. The PS3 already has that many. PCs won't be far behind.

Concurrency isn't "a tool that has its place", it runs through the whole design of a modern game engine, and will be even more important as time goes on.

PARTNERS