그래픽 최적화로 가...가버렷! (부제: 배치! 배칭을 보자!) , batch! let's take...

82

Upload: ozlael-ozlael

Post on 15-Apr-2017

7.601 views

Category:

Engineering


6 download

TRANSCRIPT

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

http://unite.unity3dkorea.com

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

ozlael.oz

ozlael

ozlael.tistory.com

Support Engineer (john Oh)

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

CPU

DRAW!

Draw Call :

GPU

OK

(Draw Call)Batch & Set Pass

(Batching)

(Culling)

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)

1 frame ...

1 frame ...

1 frame ...

1 frame ...

1 frame ...

1 frame ...

1 frame ...

...

...

CPU GPU

CPU GPU

info

info

Batch & Set Pass(Batching)

(Culling)

CPU

GPU

Frame

End

Frame

start

CPU

GPU

Frame

End

Frame

start

Logic AI Physics

Loading GC …

+Draw Call

CPU

DRAW!

Draw Call

GPU

OK

CPU

DRAW!

TEXTURE!

SHADER!

VERTEX BUFFER!

ALPHA BLENDING!

CHANGE STATES

Draw Call

GPU...

USE Z-BUFFER!

TRANSFORM

CPU (App)

GPU

COMMAND

Draw

COMMAND

SetTexture

COMMAND

Set Texture

COMMAND

Set VBO

COMMAND

Set Shader

Command Buffer

...

Video Memory

To draw

Draw Call Cost

=

Draw Call Cost

= 5122048

Draw Call

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

Batch & SetPass

(Draw Call)

(Batching)

(Culling)

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

+ Set Transform (Shader Constant)

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

Batches :

1

Batches :

17Batches :

11

Batches :

6

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)

Objects : 10 Batches : 10 SetPass Calls : 1

Objects : 10 Batches : 10 SetPass Calls : 10

!=

Batches : 10

Batches : 10

Set Pass :1

Set Pass :10

Objects : 10 Batches : 10 SetPass Calls : 1

Device Batches

Samsung Galaxy S2 85

Samsung Galaxy S3 178

Samsung Galaxy S4 215

Samsung Galaxy S5 260

배칭(Batching) 을

봐주지않겠나...

(Draw Call)Batch & Set Pass

(Culling)

Batch(in Rendering Statistics Window)

= Draw Call

+ Setting Shader + Setting Blending

+ Setting Texture + Setting Vertex Buffer

+ ...

Batching =

1 batch for

many objects

Material A Material B

Batch

s

c

e

n

e

Batch

Batches : 10 batching-> Batch :1

Texture Atlas

512

2048

Asset : Top-down Sci-Fi

Static Batching &

Dynamic BatchingPlayer Settings

Static Batching

Dynamic Batching

GPU

Vertex/Index BufferScene

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

Modular Construction

Unity Frame Debugger

동영상

드로우콜줄이기 를

봐주지않겠나...

(Draw Call)Batch & Set Pass

(Batching)

(Culling)

Batches : 32+

Realtime Shadow : X2+ batches

Shadowmap

Shadow Plane

Batches : 17(meshes:16 shadow:1)

Batches : 2

Multi-pass Shader

Draw Call & Light

3 Pixel Lights =3 Batches

3 SetPass Calls

Tris * 3

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

or

or

컬링(Culling) 을

봐주지않겠나...

(Draw Call)Batch & Set Pass

(Batching)

Frustum Culling

Occlusion Culling

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

Example

Asset : Top-Down Sci-Fi

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

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”

Player Settings

V

Thank you

[email protected]

http://unite.unity3dkorea.com

협찬:비엘북스