metal game performance optimization€¦ · metal game performance optimization •session 612....

98
#WWDC18 © 2018 Apple Inc. All rights reserved. Redistribution or public display not permitted without written permission from Apple. Guillem Viñals Gangolells, GPU Software Performance Ohad Frenkel, Game Technologies Metal Game Performance Optimization Session 612

Upload: others

Post on 25-Sep-2020

15 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam

#WWDC18

© 2018 Apple Inc. All rights reserved. Redistribution or public display not permitted without written permission from Apple.

Guillem Viñals Gangolells, GPU Software Performance Ohad Frenkel, Game Technologies

•Metal Game Performance Optimization •Session 612

Page 2: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam

Develop awesome games

Page 3: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam

technicallyDevelop awesome games

Page 4: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam

The Talos Principle Croteam / Devolver Digital

Features supported in iOS

Physically-based HDR rendering

Dynamic shadows

Real-time reflections

Multi-threaded rendering

Full-screen anti-aliasing

Post processing effects

Page 5: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam

•Profiling Tools •Frame Pacing •Thread Priorities •Thermal States •Unnecessary GPU Work

Page 6: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam

•Profiling Tools

Page 7: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam

Profile early and often

Page 8: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam

Know Your Tools

Instruments

Xcode Metal Frame Debugger

Page 9: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam

Game Performance TemplateNEW

Game Performance

Page 10: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam

Game Performance TemplateNEW

Page 11: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam

Game Performance TemplateNEW

System Trace

Page 12: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam

Game Performance TemplateNEW

System Trace Time Profiler

Page 13: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam

Game Performance TemplateNEW

System Trace Time Profiler Metal System Trace

Page 14: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam
Page 15: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam
Page 16: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam
Page 17: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam
Page 18: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam
Page 19: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam

System Trace and Time Profiler

Page 20: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam

System Trace and Time Profiler

Page 21: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam

System Trace and Time Profiler

System Trace in Depth WWDC 2016

Using Time Profiler in Instruments WWDC 2016

Page 22: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam

Metal System Trace

Page 23: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam

Metal System Trace

Page 24: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam

Metal System Trace

Metal Performance Optimization Techniques WWDC 2015

Metal 2 Optimization and Debugging WWDC 2017

Page 25: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam

Thread States ViewNEW

Page 26: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam

Thread States ViewNEW

Page 27: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam

CPU

Page 28: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam

CPU

Page 29: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam

•Frame Pacing

Page 30: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam
Page 31: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam
Page 32: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam

40 FPS 30 FPS

Page 33: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam

Micro Stuttering

Inconsistent frame rate • Frame time higher than display refresh interval • Game logic timing errors

Page 34: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam

Naive Approach

Present as fast as possible

// Render Scene

...

// Get drawable and present

if let drawable = view.currentDrawable {

// Render Final Pass

...

commandBuffer.present(drawable)

} commandBuffer.commit()

Page 35: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam

Naive Approach

Present as fast as possible

// Render Scene

...

// Get drawable and present

if let drawable = view.currentDrawable {

// Render Final Pass

...

commandBuffer.present(drawable)

} commandBuffer.commit()

Page 36: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam

Do not usleep() to pace frames!

Page 37: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam

Naive Approach

Present as fast as possible

CPU

GPU

Display

VSYNC 0 1 8 1097 82 53 64

Page 38: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam

Naive Approach

Present as fast as possible

B

A

CCPU

GPU

Display

VSYNC 0 1 8 1097 82 53 64

Page 39: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam

Naive Approach

Present as fast as possible

B

A

C

C

A

CPU

GPU

Display

VSYNC 0 1 8 1097 82 53 64

Page 40: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam

Naive Approach

Present as fast as possible

B

A

B

A

C

C

A

CPU

GPU

Display

VSYNC 0 1 8 1097 82 53 64

Page 41: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam

Naive Approach

Present as fast as possible

B

A

B

A

C

C

A

CPU

GPU

Display

VSYNC

A

B

B

C A

C

C

B

A

A

B

C

B

C

A

0 1 8 1097 82 53 64

Page 42: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam

Naive Approach

Present as fast as possible

B

A

B

A

C

C

A

CPU

GPU

Display

VSYNC

A

B

B

C A

C

C

B

A

A

B

C

B

C

A

0 1 8 1097 82 53 64

Page 43: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam

•Demo

Page 44: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam

Best Practice

Target explicit frame rate

Use the following APIs (iOS 10.3+) • MTLDrawable addPresentedHandler • MTLCommandBuffer presentDrawable afterMinimumDuration • MTLCommandBuffer presentDrawable atTime

Page 45: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam

Explicit Frame Pacing

Minimum frame duration of 33ms

0 1 8 1097 82 53 64

CPU

GPU

Display

VSYNC

Page 46: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam

Explicit Frame Pacing

Minimum frame duration of 33ms

CB

C

A

0 1 8 1097 82 53 64

CPU

GPU

Display

VSYNC

Page 47: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam

Explicit Frame Pacing

Minimum frame duration of 33ms

CB

C

A

B

B

C

A

A

B B

A

A

C

C

A

0 1 8 1097 82 53 64

CPU

GPU

Display

VSYNC

Page 48: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam

Explicit Frame Pacing

Minimum frame duration of 33ms

CB

C

A

B

B

C

A

A

B B

A

A

C

C

A

0 1 8 1097 82 53 64

CPU

GPU

Display

VSYNC

Page 49: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam

Explicit Frame Pacing

Minimum frame duration of 33ms

// Render Scene

...

// Get drawable and present at 30 FPS

if let drawable = view.currentDrawable {

// Render Final Pass

...

let duration = 33.0 / 1000.0 // Duration of 33 ms

commandBuffer.present(drawable, afterMinimumDuration: duration)

} commandBuffer.commit()

Page 50: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam

Explicit Frame Pacing

Minimum frame duration of 33ms

// Render Scene

...

// Get drawable and present at 30 FPS

if let drawable = view.currentDrawable {

// Render Final Pass

...

let duration = 33.0 / 1000.0 // Duration of 33 ms

commandBuffer.present(drawable, afterMinimumDuration: duration)

} commandBuffer.commit()

Page 51: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam

•Thread Priorities

Page 52: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam
Page 53: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam
Page 54: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam

Thread Stalling

Render thread gets preempted due to low priority • Priority decay • Priority inversion

Page 55: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam

Render thread gets preempted due to low priority

Naive Approach

0 1 8 10 11 1297 82 53 64

CPU

GPU

Display

VSYNC

Page 56: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam

Render thread gets preempted due to low priority

Naive Approach

B

C

C

A

0 1 8 10 11 1297 82 53 64

CPU

GPU

Display

VSYNC

Page 57: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam

Render thread gets preempted due to low priority

Naive Approach

B

C

C

A

0 1 8 10 11 1297 82 53 64

CPU

GPU

Display

VSYNC

Page 58: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam

Render thread gets preempted due to low priority

Naive Approach

B

C

C

A

A

B

0 1 8 10 11 1297 82 53 64

CPU

GPU

Display

VSYNC

Page 59: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam

Render thread gets preempted due to low priority

Naive Approach

B

C

C

A

A

B

A

A

C A

C

C

0 1 8 10 11 1297 82 53 64

CPU

GPU

Display

VSYNC

Page 60: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam

Render thread gets preempted due to low priority

Naive Approach

B

C

C

A

A

B

A

A

C A

C

C

0 1 8 10 11 1297 82 53 64

CPU

GPU

Display

VSYNC

Page 61: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam

•Demo

Page 62: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam

Best Practice

Configure the render thread • Priority 45 • Opt out of Quality of Service

Page 63: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam

Correct Thread Priority

Priority set to 45 and no Quality of Service

0 1 8 10 11 1297 82 53 64

CPU

GPU

Display

VSYNC

Page 64: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam

Correct Thread Priority

Priority set to 45 and no Quality of Service

CB

C

A

0 1 8 10 11 1297 82 53 64

CPU

GPU

Display

VSYNC

Page 65: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam

Correct Thread Priority

Priority set to 45 and no Quality of Service

CB

C

A

0 1 8 10 11 1297 82 53 64

CPU

GPU

Display

VSYNC

Page 66: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam

Correct Thread Priority

Priority set to 45 and no Quality of Service

CB

C

A

A

A

B

B

B

C B

A

A

C

C

A C

B

B

0 1 8 10 11 1297 82 53 64

CPU

GPU

Display

VSYNC

Page 67: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam

Correct Thread Priority

Priority set to 45 and no Quality of Service

CB

C

A

A

A

B

B

B

C B

A

A

C

C

A C

B

B

0 1 8 10 11 1297 82 53 64

CPU

GPU

Display

VSYNC

Page 68: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam

Correct Thread Priority

Priority set to 45 and no Quality of Service

... r = pthread_attr_init(&attr);

r = pthread_attr_setschedpolicy(&attr, SCHED_RR); // Opt out of Quality of Service struct sched_param param = {.sched_priority = 45}; // Configure priority 45 r = pthread_attr_setschedparam(&attr, &param); // Set priority r = pthread_create(&posixThreadID, &attr, &PosixThreadMainRoutine, NULL); r = pthread_attr_destroy(&attr); ...

Page 69: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam

Correct Thread Priority

Priority set to 45 and no Quality of Service

... r = pthread_attr_init(&attr);

r = pthread_attr_setschedpolicy(&attr, SCHED_RR); // Opt out of Quality of Service struct sched_param param = {.sched_priority = 45}; // Configure priority 45 r = pthread_attr_setschedparam(&attr, &param); // Set priority r = pthread_create(&posixThreadID, &attr, &PosixThreadMainRoutine, NULL); r = pthread_attr_destroy(&attr); ...

Page 70: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam

•Thermal States

Page 71: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam

Design for sustained performance

Page 72: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam

Thermal Throttling

Impact on system performance • High device temperature • Low power mode enabled

Page 73: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam

Best Practice

Adjust the workload to the system state

Use the following APIs • (iOS 11.0+) NSProcessInfo thermalState • (iOS 9.0+) NSProcessInfo lowPowerModeEnabled • (iOS 10.3+) MTLCommandBuffer GPUStartTime/GPUEndTime

Page 74: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam

// Determine thermal state

switch ProcessInfo.processInfo.thermalState { case .fair: // Thermals are fair // Consider taking proactive measures to prevent higher thermals case .serious: // Thermals are highly elevated // Help the system by taking corrective action case .critical: // Thermals are extremely elevated // Help the system by taking immediate corrective action default: // Thermals are okay // Go about your business }

Page 75: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam

// Determine thermal state

switch ProcessInfo.processInfo.thermalState { case .fair: // Thermals are fair // Consider taking proactive measures to prevent higher thermals case .serious: // Thermals are highly elevated // Help the system by taking corrective action case .critical: // Thermals are extremely elevated // Help the system by taking immediate corrective action default: // Thermals are okay // Go about your business }

Page 76: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam

// Determine thermal state

switch ProcessInfo.processInfo.thermalState { case .fair: // Thermals are fair // Consider taking proactive measures to prevent higher thermals case .serious: // Thermals are highly elevated // Help the system by taking corrective action case .critical: // Thermals are extremely elevated // Help the system by taking immediate corrective action default: // Thermals are okay // Go about your business }

Page 77: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam

// Determine thermal state

switch ProcessInfo.processInfo.thermalState { case .fair: // Thermals are fair // Consider taking proactive measures to prevent higher thermals case .serious: // Thermals are highly elevated // Help the system by taking corrective action case .critical: // Thermals are extremely elevated // Help the system by taking immediate corrective action default: // Thermals are okay // Go about your business }

Page 78: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam

// Determine thermal state

switch ProcessInfo.processInfo.thermalState { case .fair: // Thermals are fair // Consider taking proactive measures to prevent higher thermals case .serious: // Thermals are highly elevated // Help the system by taking corrective action case .critical: // Thermals are extremely elevated // Help the system by taking immediate corrective action default: // Thermals are okay // Go about your business }

Page 79: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam

Adjust the Workload

Target sustainable framerate

Reduce the resolution

Simplify the shadow maps

Use smaller textures

Decrease the level of detail (LOD) for geometry

Simplify post-processing and effects

Page 80: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam

•Unnecessary GPU Work

Ohad Frenkel, Game Technologies

Page 81: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam

Wasted GPU Time

Waste of power and GPU budget • Large resources • Unused GPU work

Page 82: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam

Best Practice

Profile the GPU • Understand the cost of every rendering feature • Remove excessive work

Page 83: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam

Metal System Trace

Accurate timing for Vertex, Fragment, and Compute work

Ideal to measure GPU budget

Page 84: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam

Metal System Trace

Accurate timing for Vertex, Fragment, and Compute work

Ideal to measure GPU budget

Page 85: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam

Dependency Viewer

Page 86: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam

Dependency Viewer

Page 87: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam

Dependency Viewer

Page 88: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam

Dependency Viewer

Page 89: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam

Dependency Viewer

Page 90: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam

Dependency Viewer

Page 91: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam

Dependency Viewer

Page 92: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam

•Demo

Page 93: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam

Finding Hidden Complexity

Shadow map

Main pass

HUD

Composite pass

Shadow map

HUDMain pass

CompositePass

Page 94: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam

Cascaded shadow maps (3 passes)

SSAO (5 passes)

Main pass

HDR

Post-process (5 passes)

Composite pass

And more…

Finding Hidden Complexity

Shadows

SSAO

Main pass HDR

Post- process

HUD Composite

Final blur

Page 95: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam

Profile!

Page 96: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam

Take-Away

Profile early and often

Target a consistent frame rate

Set the correct thread priorities

Adapt to system load and thermals

Don’t submit unnecessary work to the GPU

Page 97: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam

More Informationhttps://developer.apple.com/wwdc18/612

Metal Shader Debugging and Profiling WWDC 2018

Metal Debugging and Profiling Lab Technology Lab 5 Fri 12:00 PM

Metal for Game Developers WWDC 2018

Page 98: Metal Game Performance Optimization€¦ · Metal Game Performance Optimization •Session 612. Develop awesome games. Develop technically awesome games. The Talos Principle Croteam