[박민근] 3 d렌더링 옵티마이징_nv_perfhud

25
3D RENDERING OPTIMIZING #1 - 박 박 박 ( 박박 ) - DEVROOKIE(CAFÉ.NAVER.COM/DEVEROOKIE) :: NVPerfHud 를 를를를를 를를를를 를를를를 !

Transcript of [박민근] 3 d렌더링 옵티마이징_nv_perfhud

Page 1: [박민근] 3 d렌더링 옵티마이징_nv_perfhud

3D RENDERING OPTIMIZING #1- 박 민 근 ( 민군 )- DEVROOKIE(CAFÉ.NAVER.COM/DEVEROOKIE)

:: NVPerfHud 를 사용하여 보틀넥을 분석하자 !

Page 2: [박민근] 3 d렌더링 옵티마이징_nv_perfhud

목차

1. 병목지점 (BottleNeck) 이 뭔데 ?2. NVPerfHud 가 뭐냠 ?3. 새끈하게 동영상으로 한번 보자4. 우왕ㅋ굳ㅋ ! 어떻게 사용하는데 ?5. 기능은 뭐가 있남 ?6. 실제로 한번 해볼까나…7. 보틀넥을 찾아라 !!8. 비전 – 병목깨기 !! 9. 또 다른 유용한 건 뭐가 있남 ?10. 참고자료

Page 3: [박민근] 3 d렌더링 옵티마이징_nv_perfhud

1.병목지점 (BottleNeck)이 뭔데 ?

게임의 처리 속도에서 가장 부하가 걸리는 지점

특정 부분에 부하가 걸려 있기 때문에 , 이 지점을 파악하고 ,

수정하지 않으면 다른 부분을 아무리 수정해도 전체적인 속도향상의 효과가 없다

병의 내용물이 아무리 많다 해도 , 병의 목부분의 넓이가 전체 내용물을 쏟아내는 속도 ( 시간 ) 를 결정한다 .

효율적인 최적화 전략이란 , 이 보틀넥을 정확히 파악하여 집중적으로 최적화 시키는 것

CPU( 프로그램 ) 와 GPU( 랜더링 ) 의 처리 속도 , 버스 , 대역폭등에 의해서 보틀넥이 발생한다 .

Page 4: [박민근] 3 d렌더링 옵티마이징_nv_perfhud

1-1. 렌더링 병목 요소 렌더링에 영향을 주는 요소

가속 하드웨어와의 병렬성 하드웨어의 물리적 대역폭의 한계

렌더링 병목 요소 프레임 버퍼 대역폭 텍스쳐 대역폭 셰이더 버텍스 , 폴리곤의 개수 시스템 메모리 전송 대역폭 기타 등등

Page 5: [박민근] 3 d렌더링 옵티마이징_nv_perfhud

2.NVPerfHud 가 뭐냠 ? Nvidia Performance Heads-Up Display

Could Your Game Run 35% Faster? (PerfHud 광고 카피. ㅡ.ㅡ)

그래픽스 렌더링 파이프라인의 문제점을 찾을 수 있는 Visual Debugging및 Profil-

ing 툴

그래픽스 파이프라인의 거의 모든 부분을 파악하고 테스트가 가능한 실시간

프로파일링 기능

프레임별로 세세한 분석이 가능한 Visual Debugging

VS에서 하지 못하는 하드웨어 수준의 3D 렌더링 분석및 디버깅

실시간 셰이더 디버깅 기능

DP별 Render Target및 Model 내용 확인 기능

DX API Call들의 내용 확인 및 분석 기능

기타 등등 졸라 멋진 기능 많음…. + 완전 무료 (멋지다! 엔비디아!!)

Page 6: [박민근] 3 d렌더링 옵티마이징_nv_perfhud

3. 새끈하게 동영상 감상 ~

Page 7: [박민근] 3 d렌더링 옵티마이징_nv_perfhud

Epic - Unreal Tournament3 Arena.net - Guild Wars DICE - Battlefield 2142 CCP Games – EVE online

Relic – Company of Heroes NTL Inc - DragonBall Blizzard - WOW Flagship – Hellgate: London

Blue Byte Soft – Settler VI Massive - World in Conflict TimeGate – F.E.A.R. Emergent Game Tech - Gamebryo

Page 8: [박민근] 3 d렌더링 옵티마이징_nv_perfhud

4. 우왕ㅋ굳ㅋ ! 어떻게 사용하는데 ?

1. Nvidia 홈페이지에서 NVPerfHud를 다운받아서 설치한다 .

2. 당연하게도 Nvidia 그래픽 카드가 있어야만 설치된다 . Geforce6.X 이상 , Windows XP 이상 , DirectX 9.0c 이상

3. 설치시에 Instrumented Driver 가 설치되는데 , 이 것이 D3D 와 GPU

사이에서 동작하여 PerfHud 의 기능들이 작동되게 해준다 .

일반 드라이버에서도 작동은 하지만 , Performance Conuter 가 동작하지 않는다 .

Page 9: [박민근] 3 d렌더링 옵티마이징_nv_perfhud

4. 우왕ㅋ굳ㅋ ! 어떻게 사용하는데 ?

4. 어플리케이션에서 Device 의 초기화 시에 어댑터를 “ PerfHud” 로 설정하고 , D3DDEVTYPE_REF 로 설정하면 코딩은 끝 !

Page 10: [박민근] 3 d렌더링 옵티마이징_nv_perfhud

4. 우왕ㅋ굳ㅋ ! 어떻게 사용하는데 ?5. 설치된 NVPerfHud 를 실행시켜서 활성화에

사용할 단축키를 설정한다 .

6. NVPerfHud 아이콘에 어플리케이션의 실행파일을 드래그엔 드롭하거나 , 우측클릭 – 보내기 – NVPerfHud 로 실행한다 .

Page 11: [박민근] 3 d렌더링 옵티마이징_nv_perfhud

5. 기능은 뭐가 있남 ?1. Performance Dashboard

1. 타이밍 그래프 & 프로그램의 보틀넥을 찾아내기 위한 다양한 그래프들을 추가 / 삭제 /변경등을 하면서 볼 수 있다 .

2. DP Call, Frame, BandWidth, Memory 등등 .. 웬만한건 다 된다 .3. 프로그램의 실행 속도 제어 ( 스피드 핵 .-_-)

Page 12: [박민근] 3 d렌더링 옵티마이징_nv_perfhud

5. 기능은 뭐가 있남 ?2. Debug Console

1. 현재 프레임을 정지시킨다 . 각 프레임별로 분석 가능2. 아래와 같은 메시지들을 볼 수 있다 .

1. The DX Debug runtime2. The PerfHUD warnings3. 프로그램의 OuputDebugString()

Page 13: [박민근] 3 d렌더링 옵티마이징_nv_perfhud

5. 기능은 뭐가 있남 ?3. Frame Debugger

1. 현재 프레임을 정지시킨다 . 2. 1 프레임내에서 그래픽스 파이프라인에 무슨 일이 일어나고 , 어떤 작업들을 일어나는지

DP Call 단위로 진행시키면서 자세히 정보를 볼 수 있다 . 3. 그래픽 파이프라인안의 Textures / Render Targets 을 확인 가능4. D3D Markers; DX API Call5. 셰이더 코드 확인 및 수정 기능

Page 14: [박민근] 3 d렌더링 옵티마이징_nv_perfhud

5. 기능은 뭐가 있남 ?4. Frame Profiler

1. 현재 프레임을 정지시킨다 .2. 프로그램이 GPU 를 어떻게 사용하고 있는지 프로파일링 한다 .3. 현재 프로그램의 모든 DP Call 및 DX API 호출에 대한 비용등을 볼 수 있고 , 비용별로 정렬할 수 있다 .4. 자동으로 각 DP Call 당 보틀넥 비율을 분석해주는 기능이 있어서 , 보틀넥을 파악하기에 가장 강력하고

효율적인 기능이다 .

Page 15: [박민근] 3 d렌더링 옵티마이징_nv_perfhud

5. 기능은 뭐가 있남 ?5. Shader Inspectors

1. 각 DP 별 셰이더 코드를 직접 볼 수 있고 , 코드를 실시간으로 수정 가능2. 셰이더의 실제 값들을 확인해 볼 수 있고 , 셰이더 중 부하가 의심나는 부분을 직접 실시간으로 수정할 수

있어서 , 셰이더에 의한 보틀넥을 분석할 수 있다 .3. 어플리케이션에서 설정된 셰이더별 상수값을 확인 가능하고 , 실시간으로 수정할 수 있다 .

Page 16: [박민근] 3 d렌더링 옵티마이징_nv_perfhud

5. 기능은 뭐가 있남 ?6. Raster Operations Inspector

1. 렌더 스테이트 및 레스터 명령 설정들을 확인하고 , 실시간으로 수정 가능2. 수정된 설정은 모든 프레임에 적용된다 .3. 각 설정을 수정하면서 Frame 향상을 찾아서 보틀넥을 분석할 수 있다 .

Page 17: [박민근] 3 d렌더링 옵티마이징_nv_perfhud

6. 실제로 한번 해볼까나…

실습

Page 18: [박민근] 3 d렌더링 옵티마이징_nv_perfhud

7. 보틀넥을 찾아라 !!

Page 19: [박민근] 3 d렌더링 옵티마이징_nv_perfhud

7. 보틀넥을 찾아라 !!1.Raster Operation Bottlenecks

1. Vary the bit depths of the color and/or depth buffers. Ex) 32 to

16

2.Texture Bandwidth Bottlenecks

1. Replace all textures in App. With a 2x2 textures. This emulates a

much faster texture-fetch with much better texture cache co-

herence.

3.Pixel Shading Bottlenecks

1. Pixel shading + frame buffer bandwidth = fillrate

2. Force the shader to the specfic color among FFP, ps 1.1 ~ ps 4.0

3. Figure out NVShaderPerf or the Shader panel in FX Composer.

4. Shader_cost = cost_per_pixel * number_of_pixels_affected.

Page 20: [박민근] 3 d렌더링 옵티마이징_nv_perfhud

7. 보틀넥을 찾아라 !!4. Vertex Processing Bottlenecks

1. Vertex attributes1. Model-space positions2. Vertex normals3. Texture coordinates

2. A set of attributes suitable for clipping and rasterization1. Homogeneous clip-space position2. Vertex lighting results3. Texture coordinates

5. Isolate the vertex unit. Ex) Ignore draw call, min geometryVertex and Index Transfer Bot-tlenecks

1. Nonlocal < AGP < PCI-Express bus < Local2. Reference “GPU_Programming_Guide”

1. Unified buffering2. Proper buffer sizing3. Managed type buffer making4. Vertex format size & 4byte aligned5. Vary AGP Aperture6. Minimize stream change

Page 21: [박민근] 3 d렌더링 옵티마이징_nv_perfhud

7. 보틀넥을 찾아라 !!5. CPU Bottlenecks

1. Watch the GPU Idle line.2. Isolate the GPU; Ignore all the DP calls.3. If the resulting frame high then not a problem otherwise CPU lim-

ited.4. CPU Bottlenecks could be caused by

1. Too many DP calls; there is driver overhead for each call2. Loading/allocating resource; Resource Creation Monitor Check3. Demanding App. Logic, physics, etc

1. The time gap between two factors below is App. Logic2. FRAME_TIME3. TIME_IN_DRIVER

1. Time the CPU Is executing driver code2. DRIVER_WAITS_FOR_GPU

Page 22: [박민근] 3 d렌더링 옵티마이징_nv_perfhud

7. 보틀넥을 찾아라 !!1. “Ctrl + N” Test : Ignore all of the D3D rendering functions, render nothing at all

1. If there is no frame improvement then,1. GPU_IDLE high2. Too much API function calls3. Too much CPU calculations

2. “Ctrl + M” Test : Render only one polygon per batch; access VS, PS, VB, IB

1. If there is no frame improvement then,1. Rendering performance is fine2. GPU’s got too much batches to process; ex) state change, material sort

bottle necks

3. “Ctrl + S” Test : Delete all the pixels; turn VS on, turn PS off

1. If there is no frame improvement then,1. VS bottlenecks are fine; ex) hot spot for skinning?

4. “Ctrl + T” Test : replace all the textures to 2x2

1. If there is no frame improvement then,1. Texture fetch is fine; ex) too much texture reference

Page 23: [박민근] 3 d렌더링 옵티마이징_nv_perfhud

8. 비전 – 병목 깨기 !!1. CPU-Intensive operations

1. If TIME_IN_DRIVER & FRAME_TIME lines spike simultaneously it’s likely1. The driver is uploading a texture from the CPU to the GPU

2. If FRAME_TIME line spikes and TIME_IN_DRIVER line doesn’t1. The APP is likely performing some CPU-Intensive operation

like decoding audio or accessing the hard disk, this situation may also be caused by the OS attending to other processes

3. If GPU_IDLE spikes, you are not sending data to GPU4. If low polys batch were many, performance will be low cos’ of a lot

of streamsources; many stream changes5. If you find that the frame rate is high, you can do more woked on

the CPU and this should not affect the frame rate(object culling, physics, game logic, ai, etc)

6. If you find that the frame rate is not adequate, you should reduce the scene complexity to lighten the GPU load

Page 24: [박민근] 3 d렌더링 옵티마이징_nv_perfhud

9. 또다른 유용한건 뭐가 있남 ?

Page 25: [박민근] 3 d렌더링 옵티마이징_nv_perfhud

10. 참고 자료