Parallel Game Engine Design or How I Learned

  • Slides: 19
Download presentation
Parallel Game Engine Design or How I Learned to Stop Worrying and Love Multithreading

Parallel Game Engine Design or How I Learned to Stop Worrying and Love Multithreading

Preliminaries The GGE and serial architectures n Multithreading design decisions n The new engine

Preliminaries The GGE and serial architectures n Multithreading design decisions n The new engine n Q/A n

GGE The Gamepipe Game Engine is a student built game engine using the Ogre

GGE The Gamepipe Game Engine is a student built game engine using the Ogre 3 d rendering engine for underlying scene management and basic rendering n Ogre has support for basic multithreading, mostly limited to the background loading of resources n

GGE continued n Last semester, Steve Wenzke and I explored multithreading the GGE and

GGE continued n Last semester, Steve Wenzke and I explored multithreading the GGE and were able to implement a dedicated rendering thread and limited multithreading of some higher level systems

Limitations to multithreading GGE Inconsistent and interrelated update calls for systems/game objects make separating

Limitations to multithreading GGE Inconsistent and interrelated update calls for systems/game objects make separating independent tasks difficult n Lack of a common interface for events/manipulations of scene objects like updating position n No “owner” for the scene Ogre maintains; systems access and manipulate it at will. n

Starting from scratch This semester I decided to start from scratch on a new

Starting from scratch This semester I decided to start from scratch on a new engine that would scale with an arbitrary number of threads. n Once the underlying design was pinned down, I started to port existing functionality from the GGE to the new engine with modifications owing to the new design n

Multithreading Design Decisions n Shared resources n n Synchronization n n What is shared?

Multithreading Design Decisions n Shared resources n n Synchronization n n What is shared? When? Is that a problem? Sometimes; sometimes not. Locks and/or semaphores? Something more elegant? Scalability n Can the architecture utilize 4 cores as well as it can 40?

Shared resources – Game Objects Universal Animation AI • • • Position Orientation Scale

Shared resources – Game Objects Universal Animation AI • • • Position Orientation Scale • • • Agent. State Path. Node … Physics Graphics • • • Position Orientation Scale • • • Anim. Frame Bone. List … • • • Rigid. Body Mass … • • • Scene. Node Entity …

Synchronization Physics • • • Position Orientation Scale • • • Rigid. Body Mass

Synchronization Physics • • • Position Orientation Scale • • • Rigid. Body Mass … State. Change Graphics State. Change State. Manager State. Change • • • Position Orientation Scale • • • Scene. Node Entity …

Synchronization

Synchronization

Engine Update Loop Propagate and Process State Changes Main Update Gather State Changes

Engine Update Loop Propagate and Process State Changes Main Update Gather State Changes

Main Update TBB Scheduler AI System Animation System Physics System Graphics System Process State

Main Update TBB Scheduler AI System Animation System Physics System Graphics System Process State Changes Update Gather State Changes

Demo n Stats 3300+ Game. Objects (2300 Physics objects, 1000 AI objects) n Average

Demo n Stats 3300+ Game. Objects (2300 Physics objects, 1000 AI objects) n Average fps on 4 -core/8 -thread i 7 920 = 35 -55 fps n 90% + cpu utilization across all physical/hyper threads n

Example – Parallel Boids Simulation Based on Opensteer library’s flocking simulation n Problems for

Example – Parallel Boids Simulation Based on Opensteer library’s flocking simulation n Problems for parallelization n Race condition on each AIObject’s updated position n Highly contended shared resource n

Example – Parallel Boids Simulation n Solution Separate the Simulation and Updates of local

Example – Parallel Boids Simulation n Solution Separate the Simulation and Updates of local information to two different steps, each run in parallel with a natural barrier in between n Create a concurrent, spatial data structure to maintain neighbor lists every frame n n “Fixed. Spatial. Container” maintains two 3 d arrays of tbb: : concurrent_vectors that allow for completely parallel access and updates to spatial information used in the simulation

Video n https: //gpserver 01. usc. edu/svn/gge/ogreaddons /Intel. TBBUpgrade/presentation_video/presentat ion. mp 4

Video n https: //gpserver 01. usc. edu/svn/gge/ogreaddons /Intel. TBBUpgrade/presentation_video/presentat ion. mp 4

The future n Short term plans Port over the Flash. GUI and FMOD Audio

The future n Short term plans Port over the Flash. GUI and FMOD Audio functionality from the GGE n Port over the dot. Scene parser for scene loading n n Longer term Port the animation and remainder of the physics functionality from the GGE n Further performance improvements n n Explore complete free step mode between systems

Q/A

Q/A