1. :: NVPerfHud를 사용하여 보틀넥을 분석하자!
3D RENDERING OPTIMIZING #1
- 박 민 근 (민군)
- DEVROOKIE(CAFÉ.NAVER.COM/DEVEROOKIE)
2. 목차
1. 병목지점(BottleNeck)이 뭔데?
2. NVPerfHud가 뭐냠?
3. 새끈하게 동영상으로 한번 보자
4. 우왕ㅋ굳ㅋ! 어떻게 사용하는데?
5. 기능은 뭐가 있남?
6. 실제로 한번 해볼까나…
7. 보틀넥을 찾아라!!
8. 비전 – 병목깨기!!
9. 또 다른 유용한 건 뭐가 있남?
10. 참고자료
3. 1.병목지점(BottleNeck)이 뭔데?
게임의 처리 속도에서 가장 부하가 걸리는 지점
특정 부분에 부하가 걸려 있기 때문에, 이 지점을 파악하고, 수
정하지 않으면 다른 부분을 아무리 수정해도 전체적인 속도향
상의 효과가 없다
병의 내용물이 아무리 많다 해도, 병의 목부분의 넓이가 전체
내용물을 쏟아내는 속도(시간)를 결정한다.
효율적인 최적화 전략이란, 이 보틀넥을 정확히 파악하여 집중
적으로 최적화 시키는 것
CPU(프로그램)와 GPU(랜더링)의 처리 속도, 버스, 대역폭등에
의해서 보틀넥이 발생한다.
4. 1-1.렌더링 병목 요소
렌더링에 영향을 주는 요소
가속 하드웨어와의 병렬성
하드웨어의 물리적 대역폭의 한계
렌더링 병목 요소
프레임 버퍼 대역폭
텍스쳐 대역폭
셰이더
버텍스, 폴리곤의 개수
시스템 메모리 전송 대역폭
기타 등등
5. 2.NVPerfHud가 뭐냠?
Nvidia Performance Heads-Up Display
Could Your Game Run 35% Faster? (PerfHud 광고 카피. ㅡ.ㅡ)
그래픽스 렌더링 파이프라인의 문제점을 찾을 수 있는 Visual Debugging및
Profiling 툴
그래픽스 파이프라인의 거의 모든 부분을 파악하고 테스트가 가능한 실시간 프로
파일링 기능
프레임별로 세세한 분석이 가능한 Visual Debugging
VS에서 하지 못하는 하드웨어 수준의 3D 렌더링 분석및 디버깅
실시간 셰이더 디버깅 기능
DP별 Render Target및 Model 내용 확인 기능
DX API Call들의 내용 확인 및 분석 기능
기타 등등 졸라 멋진 기능 많음…. + 완전 무료 (멋지다! 엔비디아!!)
7. 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
8. 4. 우왕ㅋ굳ㅋ! 어떻게 사용하는데?
1. Nvidia 홈페이지에서 NVPerfHud를 다운받아서 설치한다.
2. 당연하게도 Nvidia 그래픽 카드가 있어야만 설치된다. Geforce6.X
이상, Windows XP 이상, DirectX 9.0c 이상
3. 설치시에 Instrumented Driver가 설치되는데, 이 것이 D3D와 GPU
사이에서 동작하여 PerfHud의 기능들이 작동되게 해준다.
일반 드라이버에서도 작동은 하지만, Performance Conuter가 동작
하지 않는다.
9. 4. 우왕ㅋ굳ㅋ! 어떻게 사용하는데?
4. 어플리케이션에서 Device의 초기화 시에 어댑터를 “PerfHud”로
설정하고, D3DDEVTYPE_REF로 설정하면 코딩은 끝!
10. 4. 우왕ㅋ굳ㅋ! 어떻게 사용하는데?
5. 설치된 NVPerfHud를 실행시켜서 활성화에 사
용할 단축키를 설정한다.
6. NVPerfHud 아이콘에 어플리케이션의 실행파
일을 드래그엔 드롭하거나, 우측클릭 – 보내
기 – NVPerfHud로 실행한다.
11. 5. 기능은 뭐가 있남?
1. Performance Dashboard
1. 타이밍 그래프 & 프로그램의 보틀넥을 찾아내기 위한 다양한 그래프들을 추가/삭제/변
경등을 하면서 볼 수 있다.
2. DP Call, Frame, BandWidth, Memory등등.. 웬만한건 다 된다.
3. 프로그램의 실행 속도 제어 (스피드 핵.-_-)
12. 5. 기능은 뭐가 있남?
2. Debug Console
1. 현재 프레임을 정지시킨다. 각 프레임별로 분석 가능
2. 아래와 같은 메시지들을 볼 수 있다.
1. The DX Debug runtime
2. The PerfHUD warnings
3. 프로그램의 OuputDebugString()
13. 5. 기능은 뭐가 있남?
3. Frame Debugger
1. 현재 프레임을 정지시킨다.
2. 1프레임내에서 그래픽스 파이프라인에 무슨 일이 일어나고, 어떤 작업들을 일어나는지
DP Call 단위로 진행시키면서 자세히 정보를 볼 수 있다.
3. 그래픽 파이프라인안의 Textures / Render Targets을 확인 가능
4. D3D Markers; DX API Call
5. 셰이더 코드 확인 및 수정 기능
14. 5. 기능은 뭐가 있남?
4. Frame Profiler
1. 현재 프레임을 정지시킨다.
2. 프로그램이 GPU를 어떻게 사용하고 있는지 프로파일링 한다.
3. 현재 프로그램의 모든 DP Call및 DX API 호출에 대한 비용등을 볼 수 있고, 비용별로 정렬할 수 있다.
4. 자동으로 각 DP Call당 보틀넥 비율을 분석해주는 기능이 있어서, 보틀넥을 파악하기에 가장 강력하
고 효율적인 기능이다.
15. 5. 기능은 뭐가 있남?
5. Shader Inspectors
1. 각 DP별 셰이더 코드를 직접 볼 수 있고, 코드를 실시간으로 수정 가능
2. 셰이더의 실제 값들을 확인해 볼 수 있고, 셰이더 중 부하가 의심나는 부분을 직접 실시간으로 수정
할 수 있어서, 셰이더에 의한 보틀넥을 분석할 수 있다.
3. 어플리케이션에서 설정된 셰이더별 상수값을 확인 가능하고, 실시간으로 수정할 수 있다.
16. 5. 기능은 뭐가 있남?
6. Raster Operations Inspector
1. 렌더 스테이트 및 레스터 명령 설정들을 확인하고, 실시간으로 수정 가능
2. 수정된 설정은 모든 프레임에 적용된다.
3. 각 설정을 수정하면서 Frame 향상을 찾아서 보틀넥을 분석할 수 있다.
19. 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
coherence.
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.
20. 7. 보틀넥을 찾아라!!
4. Vertex Processing Bottlenecks
1. Vertex attributes
1. Model-space positions
2. Vertex normals
3. Texture coordinates
2. A set of attributes suitable for clipping and rasterization
1. Homogeneous clip-space position
2. Vertex lighting results
3. Texture coordinates
5. Isolate the vertex unit.
Ex) Ignore draw call, min geometryVertex and Index Transfer Bottlenecks
1. Nonlocal < AGP < PCI-Express bus < Local
2. Reference “GPU_Programming_Guide”
1. Unified buffering
2. Proper buffer sizing
3. Managed type buffer making
4. Vertex format size & 4byte aligned
5. Vary AGP Aperture
6. Minimize stream change
21. 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 limited.
4. CPU Bottlenecks could be caused by
1. Too many DP calls; there is driver overhead for each call
2. Loading/allocating resource; Resource Creation Monitor Check
3. Demanding App. Logic, physics, etc
1. The time gap between two factors below is App. Logic
2. FRAME_TIME
3. TIME_IN_DRIVER
1. Time the CPU Is executing driver code
2. DRIVER_WAITS_FOR_GPU
22. 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 high
2. Too much API function calls
3. 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 fine
2. 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
23. 8. 비전 – 병목 깨기!!
1. CPU-Intensive operations
1. If TIME_IN_DRIVER & FRAME_TIME lines spike simultaneously it’s likely
1. The driver is uploading a texture from the CPU to the GPU
2. If FRAME_TIME line spikes and TIME_IN_DRIVER line doesn’t
1. 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 GPU
4. If low polys batch were many, performance will be low cos’ of a lot of
streamsources; many stream changes
5. 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