threading successes 04 hellgate

18
EA / Namco Bandai Flagship Studios Hellgate: London Thread for Features

Upload: guest40fc7cd

Post on 28-Jul-2015

182 views

Category:

Technology


3 download

TRANSCRIPT

Page 1: Threading Successes 04   Hellgate

EA / Namco BandaiFlagship StudiosHellgate: London

Thread for Features

Page 2: Threading Successes 04   Hellgate

2

Thread for features

•Why not reward users with high-end CPUs?•We’ll look at how Hellgate: London tackled this

issue

Page 3: Threading Successes 04   Hellgate

3

What do you do when FPS enhancement is not enough?•Threading for performance has been done.•Framerate is maxed out on 2-core.•What about 4-core? What about n-core?

– Add features that only appear or become more intense on multi-core.

– Don’t change gameplay!

Page 4: Threading Successes 04   Hellgate

4

Amdahl was a buzzkill

1 2 4 8

Cores

FPS

1 2 4 8

Cores

Features

•Speedup is limited by serial portion of code.•Features are limited only by creativity and effort.

Fast

er

Aw

eso

mer

Page 5: Threading Successes 04   Hellgate

5

Short on ideas? Use these!

Page 6: Threading Successes 04   Hellgate

6

Hellgate: London was a natural choice to thread for features•Hellgate: London was already targeting a broad range of hardware.– Graphics would scale depending upon GPU.– How should it scale depending upon CPU?

•Threading for performance deemed not enough return on investment.– Hellgate: London didn’t have a profile which

seemed to benefit from threading the graphics engine.

•Let’s thread for features!

Page 7: Threading Successes 04   Hellgate

7

Hellgate: London is architected for the future•Hellgate: London has two scaled thread pools:

•First thread pool is for loading assets.– Speeds up level loading.– Avoids framerate hitches when new sounds or

models are loaded.

•Second thread pool is for arbitrary “jobs”.– Texture color swizzling to make armor sets

appear cohesive.– What else could be done here?

Page 8: Threading Successes 04   Hellgate

8

Let it snow?

Page 9: Threading Successes 04   Hellgate

9

Weather particles were a small part of the overall frame time•Weather had a small time slice of the frame

calculation.•Calculation of the weather was moderately time-

consuming, rendering not so much.– Just ramping up particles impacted CPU severely, and

started to impact GPU somewhat.

•2x, 4x weather wouldn’t be a noticeable improvement – must go big!

•Comparing weather particle time to overall frame time showed a ratio of 1:50.– 50x weather particles possible on dual-core, in theory.– Must remain aware of GPU impact.

Page 10: Threading Successes 04   Hellgate

10

An initial fork-and-join approach didn’t work out•First try was to do a fork-and-join approach.

– Primary thread would do half the work on dual-core.– Dedicated thread would do the other half.– No data copying! Memory is consistent.

Original

Fork-and-Join

•Half of 50x is still 25x!

Render

Render

Page 11: Threading Successes 04   Hellgate

11

Second try: asynchronous update, synchronous render•Asynchronous update won’t stall the primary thread.

– Memory is no longer consistent.– Weather particles are redrawn when new positions are

available (probably every frame).

RenderOriginal

Asynchronous

•Trickier, but looks like a winner.

Render

Page 12: Threading Successes 04   Hellgate

12

Here’s the code changes that were made•A callback was defined to update weather particles.

– This used the existing job task pool.

•Vertex buffers were created to hold the weather particles.

•Particle systems were marked as regular or asynchronous.

•Asynchronous systems were split into the “good twin” and the “evil twin”:– During draw, good twin draws the evil twin’s particles from

last frame, then captures draw state for the evil twin.– During update, evil twin is processed in the callback and

fills the vertex buffer.

Page 13: Threading Successes 04   Hellgate

13

Impact to memory and GPU prevents theoretical 50x maximum•One frame delay means that more memory is required.– Also, there are more weather particles than any

other kind of particle.

•50x particles impacts framerate, but 30x...

Page 14: Threading Successes 04   Hellgate

14

Where’s my hot chocolate?

Page 15: Threading Successes 04   Hellgate

15

We could keep going...

•This could be taken further by:– Using additional “weather” particle systems for

other ambient effects.– Using the same technique to scale the weapon

effects.– Adding forces to the weather particles to

simulate localized wind.

Page 16: Threading Successes 04   Hellgate

16

Threading for features has a lot of potential•Every additional core supplies an additional thread in the pool.

•Every additional thread = an additional feature?

•We’ll see an example in the next section, after the break.

Page 17: Threading Successes 04   Hellgate

17

We learned some do’s and don’ts

•Do:– Target features in addition to performance.– Take advantage of existing threading

infrastructure.

•Don’t:– Give up on threading if your first approach fails.

Page 18: Threading Successes 04   Hellgate

18

What do you think?

•Have you tried something like this?•Have you rejected trying something like this?