Top Banner
82

그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! - Unite Seoul 2016

Apr 21, 2017

Download

Engineering

ozlael ozlael
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: 그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! - Unite Seoul 2016
Page 2: 그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! - Unite Seoul 2016

그래픽최적화함께하지않겠나

http://unite.unity3dkorea.com

Page 3: 그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! - Unite Seoul 2016

그래픽최적화함께하지않겠나

ozlael.oz

ozlael

ozlael.tistory.com

Support Engineer (john Oh)

Page 4: 그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! - Unite Seoul 2016
Page 5: 그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! - Unite Seoul 2016

-- (Draw Call)- Batch & Set Pass- (Batching)-- (Culling)

Page 6: 그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! - Unite Seoul 2016

CPU

DRAW!

Draw Call :

GPU

OK

Page 7: 그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! - Unite Seoul 2016

(Draw Call)Batch & Set Pass

(Batching)

(Culling)

Page 8: 그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! - Unite Seoul 2016

Frame 1 Frame 2 Frame 3 Frame 4 Frame 5

Frame 6 Frame 7 Frame 8 Frame 9 Frame 10

1 sec

0 sec

10FPS (100ms/frame)

Page 9: 그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! - Unite Seoul 2016

1 frame ...

Page 10: 그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! - Unite Seoul 2016

1 frame ...

Page 11: 그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! - Unite Seoul 2016

1 frame ...

Page 12: 그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! - Unite Seoul 2016

1 frame ...

Page 13: 그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! - Unite Seoul 2016

1 frame ...

Page 14: 그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! - Unite Seoul 2016

1 frame ...

Page 15: 그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! - Unite Seoul 2016

1 frame ...

Page 16: 그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! - Unite Seoul 2016

...

Page 17: 그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! - Unite Seoul 2016

...

Page 18: 그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! - Unite Seoul 2016

CPU GPU

CPU GPU

info

info

Page 19: 그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! - Unite Seoul 2016

Batch & Set Pass(Batching)

(Culling)

Page 20: 그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! - Unite Seoul 2016

CPU

GPU

Frame

End

Frame

start

Page 21: 그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! - Unite Seoul 2016

CPU

GPU

Frame

End

Frame

start

Page 22: 그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! - Unite Seoul 2016

Logic AI Physics

Loading GC …

+Draw Call

Page 23: 그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! - Unite Seoul 2016

CPU

DRAW!

Draw Call

GPU

OK

Page 24: 그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! - Unite Seoul 2016

CPU

DRAW!

TEXTURE!

SHADER!

VERTEX BUFFER!

ALPHA BLENDING!

CHANGE STATES

Draw Call

GPU...

USE Z-BUFFER!

TRANSFORM

Page 25: 그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! - Unite Seoul 2016

CPU (App)

GPU

COMMAND

Draw

COMMAND

SetTexture

COMMAND

Set Texture

COMMAND

Set VBO

COMMAND

Set Shader

Command Buffer

...

Video Memory

To draw

Page 26: 그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! - Unite Seoul 2016
Page 27: 그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! - Unite Seoul 2016

Draw Call Cost

=

Page 28: 그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! - Unite Seoul 2016

Draw Call Cost

= 5122048

Page 29: 그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! - Unite Seoul 2016

Draw Call

image : http://www.upcomingmobilephone.com/

Page 30: 그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! - Unite Seoul 2016

Batch & SetPass

(Draw Call)

(Batching)

(Culling)

Page 31: 그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! - Unite Seoul 2016

Batch= Draw Call + Set VB/IB (mesh)

+ Set Transform (Shader Constant)

+ Set Shader+ Set Texture 0~7+ Set Blending + Set Z enable+ ...

Page 32: 그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! - Unite Seoul 2016

Batches :

1

Page 33: 그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! - Unite Seoul 2016

Batches :

17Batches :

11

Page 34: 그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! - Unite Seoul 2016

Batches :

6

Page 35: 그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! - Unite Seoul 2016

Batch= Draw Call + Set VB/IB (mesh)

+ Set Transform (Shader Constant)

+ Set Shader+ Set Texture 0~7+ Set Blending + Set Z enable+ ...

SetPass Call(Material&Shader)

Page 36: 그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! - Unite Seoul 2016

Objects : 10 Batches : 10 SetPass Calls : 1

Page 37: 그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! - Unite Seoul 2016

Objects : 10 Batches : 10 SetPass Calls : 10

Page 38: 그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! - Unite Seoul 2016

!=

Batches : 10

Batches : 10

Set Pass :1

Set Pass :10

Page 39: 그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! - Unite Seoul 2016

Objects : 10 Batches : 10 SetPass Calls : 1

Page 40: 그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! - Unite Seoul 2016

Device Batches

Samsung Galaxy S2 85

Samsung Galaxy S3 178

Samsung Galaxy S4 215

Samsung Galaxy S5 260

Page 41: 그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! - Unite Seoul 2016

배칭(Batching) 을

봐주지않겠나...

(Draw Call)Batch & Set Pass

(Culling)

Page 42: 그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! - Unite Seoul 2016

Batch(in Rendering Statistics Window)

= Draw Call

+ Setting Shader + Setting Blending

+ Setting Texture + Setting Vertex Buffer

+ ...

Page 43: 그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! - Unite Seoul 2016

Batching =

1 batch for

many objects

Page 44: 그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! - Unite Seoul 2016

Material A Material B

Batch

s

c

e

n

e

Batch

Page 45: 그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! - Unite Seoul 2016

Batches : 10 batching-> Batch :1

Page 46: 그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! - Unite Seoul 2016

Texture Atlas

Page 47: 그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! - Unite Seoul 2016

512

2048

Page 48: 그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! - Unite Seoul 2016

Asset : Top-down Sci-Fi

Page 49: 그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! - Unite Seoul 2016

Static Batching &

Dynamic BatchingPlayer Settings

Page 50: 그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! - Unite Seoul 2016

Static Batching

Page 51: 그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! - Unite Seoul 2016

Dynamic Batching

GPU

Vertex/Index BufferScene

Page 52: 그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! - Unite Seoul 2016

Dynamic Batching : 제약사항

Overhead- Skinned Mesh - Vertex Mesh

- position, normal, uv0 -> 300- position, normal, uv0, uv1, tangent -> 180

- http://docs.unity3d.com/kr/current/Manual/DrawCallBatching.html

Page 53: 그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! - Unite Seoul 2016
Page 54: 그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! - Unite Seoul 2016
Page 55: 그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! - Unite Seoul 2016
Page 56: 그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! - Unite Seoul 2016
Page 57: 그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! - Unite Seoul 2016
Page 58: 그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! - Unite Seoul 2016

Modular Construction

Page 59: 그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! - Unite Seoul 2016

Unity Frame Debugger

Page 60: 그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! - Unite Seoul 2016

동영상

Page 61: 그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! - Unite Seoul 2016

드로우콜줄이기 를

봐주지않겠나...

(Draw Call)Batch & Set Pass

(Batching)

(Culling)

Page 62: 그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! - Unite Seoul 2016

Batches : 32+

Realtime Shadow : X2+ batches

Shadowmap

Page 63: 그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! - Unite Seoul 2016

Shadow Plane

Batches : 17(meshes:16 shadow:1)

Page 64: 그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! - Unite Seoul 2016

Batches : 2

Multi-pass Shader

Page 65: 그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! - Unite Seoul 2016

Draw Call & Light

Page 66: 그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! - Unite Seoul 2016
Page 67: 그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! - Unite Seoul 2016

3 Pixel Lights =3 Batches

3 SetPass Calls

Tris * 3

Page 68: 그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! - Unite Seoul 2016

Pixel Light : 3 x Mesh : 6 = Batch : 18

Page 69: 그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! - Unite Seoul 2016

or

Page 70: 그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! - Unite Seoul 2016

or

Page 71: 그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! - Unite Seoul 2016

컬링(Culling) 을

봐주지않겠나...

(Draw Call)Batch & Set Pass

(Batching)

Page 72: 그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! - Unite Seoul 2016

Frustum Culling

Page 73: 그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! - Unite Seoul 2016

Occlusion Culling

Page 74: 그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! - Unite Seoul 2016
Page 75: 그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! - Unite Seoul 2016

Unity Manual : http://docs.unity3d.com/kr/current/Manual/OcclusionCulling.html

Page 76: 그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! - Unite Seoul 2016

Example

Asset : Top-Down Sci-Fi

Page 77: 그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! - Unite Seoul 2016

Device : Galaxy Note4 Rez : 2560X1440

CPU : ARMv7 VFPv3(1.9GHz) GPU : Mali-760MP(0.6GHz)

Shader : Custom Unlit Shader, Self-Illumin/Diffuse, Lightmap : 13 textures

Page 78: 그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! - Unite Seoul 2016

Condition 1

- Batching : No

- Occlusion Culling : No

Condition 2

- Batching : Yes

- Occlusion Culling : No

Condition 3

- Batching : Yes

- Occlusion Culling : Yes

FPS(ms) 41(24.3) 50(20.0) 60(16.6)

Batches 1365 157 94

SetPass Calls 134 142 81

Saved by Batching 0 1207 244

Tris 114.3K 114.3K 28.9K

-4.3ms -3.4ms

-1208 -63

-8 -61

-85.4K

Note :- This is not the official data.- This is the rough test. Not the exact reference.- Keep in mind “case by case”

Page 79: 그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! - Unite Seoul 2016
Page 80: 그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! - Unite Seoul 2016

Player Settings

V

Page 81: 그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! - Unite Seoul 2016

Thank you

[email protected]

http://unite.unity3dkorea.com

Page 82: 그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , Batch! Let's take a look at Batching! - Unite Seoul 2016

협찬:비엘북스