Killzone Shadow Fall: Threading the Entity Update on PS4. Jorrit Rouwé Lead Game Tech, Guerrilla Games

Similar documents
Introduction to Game Design. Truong Tuan Anh CSE-HCMUT

The Guerrilla Guide to Game Code

CS 354R: Computer Game Technology

Game Architecture. 4/8/16: Multiprocessor Game Loops

INTRODUCTION TO GAME AI

or if you want more control you can use the AddDamage method, which provides you more parameter to steering the damage behaviour.

FPS Assignment Call of Duty 4

CRYPTOSHOOTER MULTI AGENT BASED SECRET COMMUNICATION IN AUGMENTED VIRTUALITY

Chapter 1:Object Interaction with Blueprints. Creating a project and the first level

Game Programming Paradigms. Michael Chung

Engineering at a Games Company: What do we do?

Create PDF with GO2PDF for free, if you wish to remove this line, click here to buy Virtual PDF Printer

Z-Town Design Document

Quake III Fortress Game Review CIS 487

SimHQ ACE Quick Start Guide

Console Architecture 1

Console Games Are Just Like Mobile Games* (* well, not really. But they are more alike than you

Like Mobile Games* Currently a Distinguished i Engineer at Zynga, and CTO of FarmVille 2: Country Escape (for ios/android/kindle)

Pangolin: Concrete Architecture of SuperTuxKart. Caleb Aikens Russell Dawes Mohammed Gasmallah Leonard Ha Vincent Hung Joseph Landy

3D Top Down Shooter By Jonay Rosales González AKA Don Barks Gheist

Information for Parents/Carers Targets in Computing

Emergent s Gamebryo. Casey Brandt. Technical Account Manager Emergent Game Technologies. Game Tech 2009

Toon Dimension Formal Game Proposal

Design Document for: Name of Game. One Liner, i.e. The Ultimate Racing Game. Something funny here! All work Copyright 1999 by Your Company Name

the gamedesigninitiative at cornell university Lecture 3 Design Elements

VACUUM MARAUDERS V1.0

12 Final Projects. Steve Marschner CS5625 Spring 2016

Beginning ios 3D Unreal

Outline. Introduction to Game Programming Autumn Game architecture. The (classic) game loop. Fundamental concepts

TATAKAI TACTICAL BATTLE FX FOR UNITY & UNITY PRO OFFICIAL DOCUMENTATION. latest update: 4/12/2013

Game Architecture. Rabin is a good overview of everything to do with Games A lot of these slides come from the 1 st edition CS

Maze Puzzler Beta. 7. Somewhere else in the room place locks to impede the player s movement.

IMGD 1001: Programming Practices; Artificial Intelligence

The Next Generation of Gaming Consoles

The purpose of this document is to outline the structure and tools that come with FPS Control.

GALAXIAN: CSEE 4840 EMBEDDED SYSTEM DESIGN. Galaxian. CSEE 4840 Embedded System Design

the gamedesigninitiative at cornell university Lecture 3 Design Elements

Building the Server Software for Eliminate

Far Cry 2: Prima Official Game Guide (Prima Official Game Guides) By David Knight

MITOCW Project: Backgammon tutor MIT Multicore Programming Primer, IAP 2007

IMGD 1001: Programming Practices; Artificial Intelligence

Creating Dynamic Soundscapes Using an Artificial Sound Designer

XENONAUTS QUICKSTART GUIDE

Real Time Operating Systems Lecture 29.1

? 5. VR/AR AI GPU

In the end, the code and tips in this document could be used to create any type of camera.

Federico Forti, Erdi Izgi, Varalika Rathore, Francesco Forti

CS4617 Computer Architecture

Improving Performance through Superior Innovative Antenna Technologies

Music as a Game Obstacle

To experience the new content, go to the VR center in Carceburg after doing the alcohol mission.

Game Engines: Why and What? Dan White Technical Director Pipeworks Message

A retro space combat game by Chad Fillion. Chad Fillion Scripting for Interactivity ITGM 719: 5/13/13 Space Attack - Retro space shooter game

Game Programming Laboratory Conclusion report

Unity Certified Programmer

Towards a Reference Architecture for 3D First Person Shooter Games

Benchmarking C++ From video games to algorithmic trading. Alexander Radchenko

Program a Game Engine from Scratch. Chapter 1 - Introduction

Diving into VR World with Oculus. Homin Lee Software Engineer at Oculus

publi l c i c c l c a l s a s s s Ga G m a e1 e1 : M i M c i r c os o o s f o t. t Xn X a. a Fram a ew o k.ga G m a e m { G ap a hic i s c D s ev

Introduction. What do we mean by gameplay? AI World representation Behaviour simulation Physics Camera

CATS METRIX 3D - SOW. 00a First version Magnus Karlsson. 00b Updated to only include basic functionality Magnus Karlsson

CS 354R: Computer Game Technology

Unity Game Development Essentials

No Evidence. What am I Testing? Expected Outcomes Testing Method Actual Outcome Action Required

Hour of Code at Box Island! Curriculum

Experiment 02 Interaction Objects

HF_SS_PS3 Manual_Layout 1 11/5/12 3:41 PM Page 1 OUTSIDE FRONT COVER

Sensible Chuckle SuperTuxKart Concrete Architecture Report

Documentation and Discussion

the gamedesigninitiative at cornell university Lecture 4 Game Components

Pangolin: A Look at the Conceptual Architecture of SuperTuxKart. Caleb Aikens Russell Dawes Mohammed Gasmallah Leonard Ha Vincent Hung Joseph Landy

Create Your Own World

Schrödinger's Cat in a Mercedes

Royale Politique. A funny game developed for the RV course - University of Pisa

PlayStation 4 500GB Uncharted: The Nathan Drake Collection Bundle - $ delivered

8 Frames in 16ms. Michael Stallone Lead Software Engineer Engine NetherRealm Studios

CONCEPTS EXPLAINED CONCEPTS (IN ORDER)

A tutorial on scripted sequences & custsenes creation

Early Adopter : Multiprocessor Programming in the Undergraduate Program. NSF/TCPP Curriculum: Early Adoption at the University of Central Florida

Adjustable Group Behavior of Agents in Action-based Games

How To Change Controls Need For Speed The Run Pc

Cannon Ball User Manual

Instruction Manual. 1) Starting Amnesia

Ragnarok PS4 Flex Mod Chip Operation Instructions

CONTROLS THE STORY SO FAR

Gameplay Presented by: Marcin Chady

VR Best Practices: Putting the Fun in VR Funhouse. Amanda Bott - March 3, 2017

Unity 3.x. Game Development Essentials. Game development with C# and Javascript PUBLISHING

Coop Design for an Open World. David G. Bowring

CSE502: Computer Architecture CSE 502: Computer Architecture

LOOKING AHEAD: UE4 VR Roadmap. Nick Whiting Technical Director VR / AR

Understanding OpenGL

$19.95 CRUSADER: NO REMORSE ORIGIN S OFFICIAL GUIDE TO

Propietary Engine VS Commercial engine. by Zalo

Blending Autonomy and Control: Creating NPCs for Tom Clancy s The Division

Human Computer Interaction Unity 3D Labs

Distributed Simulation of Dense Crowds

Transitioning From Linear to Open World Design with Sunset Overdrive. Liz England Designer at Insomniac Games

Digitizing Color. Place Value in a Decimal Number. Place Value in a Binary Number. Chapter 11: Light, Sound, Magic: Representing Multimedia Digitally

Transcription:

Killzone Shadow Fall: Threading the Entity Update on PS4 Jorrit Rouwé Lead Game Tech, Guerrilla Games

Introduction Killzone Shadow Fall is a First Person Shooter PlayStation 4 launch title In SP up to 60 characters @ 30 FPS In MP up to 24 players @ 60 FPS Gameplay logic has lots of Branches Virtual functions Cache misses Not suitable for PS3 SPU s but PS4 has 6 x86 cores

What do we cover? What is an Entity? What we did on PS3 Multi threading on PS4 Balancing Entities across frames Performance issues found Performance results achieved Debug tools

What is an Entity?

What is an Entity? Base class for most game objects E.g. Player, Enemy, Weapon, Door Not used for static world Has Components E.g. Model, Mover, Destructibility Update at a fixed frequency 15, 30, 60 Hz Almost everything at 15 Hz Player updated at higher frequency to avoid lag

What is a Representation? Entities and Components have Representation Controls rendering, audio and VFX State is interpolated in frames where entity not updated Cheaper to interpolate than to update Introduces latency Always blend towards last update

Multi Threading Approach

PS3: 1 Entity = 1 Fiber yield fiber resume fiber PPU SPU 1 SPU 2 Time Entity 1 Entity 2 Entity 3 Entity 1 Animation Ray Cast Entity 2 Most time spent on PPU No clear concurrency model Read partial updated state Entities deadlock waiting for each other

PS4: 1 Entity = 1 Job job CPU 1 Entity 1 Animation Entity 1 CPU 2 CPU 3 Time Entity 2 Entity 3 Ray Cast Entity 2 No fibers Entity updates as a whole How to solve race conditions?

Strong Dependencies Make update order explicit: Soldier strong dependency Missile Launcher Soldier Missile Launcher Missile Time Missile

Non-dependent Entities can Execute Concurrently Soldier1 Soldier2 CPU 1 Soldier1 Weapon1 Weapon1 Weapon2 CPU 2 Time Soldier2 Weapon2 No (indirect) dependency = no access Works two ways: Weapon can access Soldier too Create dependency has 1 frame latency Global systems need locks

What about this? Soldier1 Soldier2 Pistol1 Pistol2 Bullet System Soldier1 Pistol1 Soldier2 Pistol2 Bullet System Time A few entities cause huge bottleneck

Non-exclusive Dependencies Soldier1 Soldier2 Pistol1 Pistol2 non-exclusive Bullet System CPU 1 Soldier1 Pistol1 CPU 2 Soldier2 Pistol2 Time Bullet System Barrier Access to Bullet System must be lock protected

Weak Dependencies 2 tanks fire at each other: strong Tank1 Missile1 weak Tank2 Missile2 Tank1 Missile1 Tank2 Missile2 Time or Tank2 Missile2 Tank1 Missile1 Update order reversed when circular dependency occurs Not used very often (< 10 per frame)

Non-updating Entities Entity can skip updates (LOD) Entity can update in other frame Entity1 not updating Entity2 Entity1 Entity3 Entity3 Time Do normal scheduling!

Summarizing Dependencies Symbol Strong Exclusive Weak Exclusive Strong Non-excl. Weak Non-excl. Two way access Order guaranteed Allow concurrency + + ++ ++ Require lock

Referencing Entities Dev build: CheckedPtr<Entity> Acts as normal pointer Check dependency on dereference Retail build: Entity * No overhead! Doesn t catch everything Can use pointers to members Bugs were easy to find

Working with Entities without dependency ThreadSafeEntityInterface Mostly read only Often used state (name, type, position, ) Mutex per Entity Send message (expensive) Processed single threaded when no dependency Schedule single threaded callback (expensive) Everything can be accessed

Scheduling Algorithm

Scheduling Algorithm not updating Soldier strong Missile Launcher Pistol non-exclusive Missile Bullet System weak Tank Job1 Soldier Missile Tank Pistol job dependency Job2 Bullet System Entities with exclusive dependencies merged to 1 job Dependencies determine sorting Non-exclusive dependencies become job dependencies Expensive jobs kicked first!

Scheduling Algorithm Edge Case Entity1 non-exclusive exclusive Entity2 Entity3 Entity4 Job1 Entity1 Job1 Entity1 Job2 Entity3 Entity2 Entity3 job dependency Entity2 Entity4 Entity4 Non cyclic dependency becomes cyclic job dependency Job1 and Job2 need to be merged

Balancing Entities Across Frames

Balancing Entities Across Frames Prevent all 15 Hz entities from updating in same frame Entity can move to other frame Smaller delta time for 1 update Keep parent-child linked entities together Weapon of soldier Soldier on mounted gun Locked close combat

Balancing Entities In Action Time in even frame (sum Time in across odd frame cores, running (should be average) equal) Civilian @ 15Hz update even frame Civilian @ 15Hz update odd frame Flash on switch odd / even

Performance Issues

Performance Issues Memory allocation mutex Eliminated many dynamic allocations Use stack allocator Locking physics world R/W mutex for main simulation world Second bullet collision broadphase + lock Large groups of dependent entities Player update very expensive

Cut Scene - Problem Cut Scene Civilian 1 Civilian 2 Player Camera Cut scene entity requires dependencies 10+ characters in cut scene creates huge job!

Cut Scene - Solution non-exclusive Cut Scene Sub Cut Scene 1 Sub Cut Scene 2 Sub Cut Scene 3 Civilian 1 Civilian 2 Player Camera Create sub cut scenes for non-interacting entities Master cut scene determines time and flow Scan 1 frame ahead in timeline to create dependency

Using an Object Dependencies on useable objects not possible (too many) Get list of usable objects Global system protected by lock Use icon appears on screen Player selects Create dependency Start use animation Start interaction 1 frame later (dependency valid) Hides 1 frame delay!

Grenade Explosion damages many entities Creating dependencies not option (too many) ThreadSafeEntityInterface not an option Need knowledge of parts Run line of sight checks inside update Uses scheduled callback to apply damage

Performance Results

Performance Results - Synthetic Level Counts Dependencies Max Number Updating Number Strong Strong Entities Entities Entities Humans Excl Non-Excl in Job Speedup 5000 Crates (20 µs each) 5019 5008 1 12 4 13 2.8X 100 Soldiers (700 µs each) 326 214 105 212 204 19 4.2X 500 Flags (160 µs each) 519 508 1 12 4 13 5.2X 6 cores! 5000 Crates 100 Soldiers 500 Flags

Performance Results - Levels Counts Dependencies Max Level Number Updating Number Strong Strong Entities Speedup Entities Entities Humans Excl Non-Excl in Job The Helghast (You Owe Me) 1141 206 32 71 23 20 4.1X The Patriot (On Vectan Soil) 435 257 44 199 107 15 4.3X The Remains (12p Botzone) 450 128 14 97 44 18 3.7X The Helghast The Patriot The Remains

Game Frame - The Patriot

Game Frame - Global CPU 1 (main thread) AI Physics Entity Update CPU 2 VFX & Draw Time CPU 3 Barrier 18 ms

Game Frame Entity Update Fix Prepare Link Weak and Jobs Dependency Order Jobs Cycles Execute Jobs Cut Scene Single Threaded Callbacks Sub Cheap Cut Entities Scenes (Destructibles) AI Soldier Cloth Simulation Player Player Job Entity Player OWL Representation Inventory (Helper Robot) Animation Capsule Collision

Debug Tools

Debug Tools Cut scenes Player Bullet System Dependencies get complex, we use yed to visualize!

Conclusions Easy to implement in existing engine Game programmers can program as if single threaded Very few multithreading issues

Questions? jorrit@guerrilla-games.com