Game Editor Parallelization in the Infernal Engine

By Mark Randel (9 posts) on May 10, 2010 at 3:01 pm

In previous blog entries, I have talked a lot about parallelization of the game loop and how to make good use of two or more threads while your game is running. But this is only the tip of the iceberg of what you can actually parallelize. While it is still ongoing (it may never end...), the Infernal Engine Editor has lots of parallelization too, still using the Infernal Engine Job Queue model previously discussed. The Job Queue essentially is able to asynchronously queue up standard C code via callbacks in a first come, first served method. It's a good model as most codebases are years old, and multiprocessing is still relatively new. Here are some examples of major speedups in the Infernal Engine:

Shader Creation

When loading a level, precompiled binary shaders are loaded into memory. This is a somewhat serial task - there is one disk drive and one file stream. However, the time it takes for DirectX to return a handle to a created shader may not be trivial. Shader compilation is queued up in the job queue, and lazily filled in. It is highly probable that by the time your level loads, shaders are not complete, and the editor needs to render. So if the handle for the shader has not been returned, anything with this material will not get rendered. In fact, any DirectX asset can be created asynchronously in this fashion! DirectX is threadsafe (on the PC - don't try this on the 360) and will block itself accordingly.

Optimized Collision Generation

In the Infernal Engine Editor, we load a quick version of the collision geometry for a level for speed. However, this is not in an optimized format since collision geometry may be edited on the fly. For each room/bsp node (see previous blog entries for more information), we need an optimized collision representation of that geometry so the game will run quickly. A job to create a bounding volume tree (BVT) for each node is queued up as well. This happens nicely also in the background as a level quickly loads. (A topic for future discussion: What is an efficient method to store a BVT on a modern multicore CPU?)

Lightmap Generation

In the previous generation, we used shadow maps for shadow casting. However, as lightmap size has increased (up to 16K!!!), for accurate shadow casting, we will raytrace the render BVT to see if a light can hit a point. On your Core i7 980X, this can run up to 8 threads at once, for almost exactly an 8x speedup. If you have a lightmap farm setup in the Infernal Engine, each computer on the farm will also run in parallel. (Another topic for future discussion: For modern video game lighting, are lightmaps even necessary?)

Conclusion

Quite obviously, parallelization in your game editor is just as important as parallelization in your game loop. There is almost an endless amount of work that designers, artists, and programmers do actually inside of the game editor, and the faster this work gets done, the more time gets spent on polishing your game.

Categories: Game Development, Graphics & Media
Tags:

For more complete information about compiler optimizations, see our Optimization Notice.

Comments (1)

June 12, 2010 1:54 PM PDT

lonewolfaka9
lonewolfaka9Total Points:
20
Registered User
Hey i just went thru all ur blogs since past hour :)


i was just searching for some some thread handling issue in my iPhone sdk program and thus i ran my mind into knowing more about threading and parallelism :) and found your stuff :)

Im also trying my luck in learning game programming specifically i want to go through complete game developer life cycle still
:D

If u can suggest something that can give me any directions ...

I've gud programming skills and worked on c/cpp/java /python/objectiveC/javascript/lua and lots of SDK's plus few game engines like unity and UDK ...................

i found one thing knowing a programming language and knowing a game engine aint make u an complete game programmer untill we focus more on how and what things are to be taken care off ...


waiting to hear an comment from your side

regards
lonewolfaka9

Trackbacks (6)


Leave a comment  

To obtain technical support, please go to Software Support.
Name (required)*

Email (required; will not be displayed on this page)*

Your URL (optional)


Comment*