Download presentation
Presentation is loading. Please wait.
Published byJames Cooper Modified over 11 years ago
2
Introduction to Direct3D 10 Course Porting Game Engines to Direct3D 10: Crysis / CryEngine2 Carsten Wenzel
3
Overview Introduction Introduction D3D10 & CryEngine2 D3D10 & CryEngine2 Porting, integration issues and optimizations Porting, integration issues and optimizations Random bits Random bits Conclusion Conclusion
4
Introduction Early adaptation Early adaptation Spec reviews / discussions started in 2005 Spec reviews / discussions started in 2005 Actual work began middle 2006 Actual work began middle 2006 Support from MS and IHVs was crucial Support from MS and IHVs was crucial
5
D3D10 in context of a multi-platform engine (1/3) API redesign offers a more concise view on how modern graphics hardware works API redesign offers a more concise view on how modern graphics hardware works For the sake of performance it offloads a lot of responsibility to the API user For the sake of performance it offloads a lot of responsibility to the API user
6
D3D10 in context of a multi-platform engine (2/3) CryEngine2 is designed to be multi-platform CryEngine2 is designed to be multi-platform Render implementations share one interface and a lot of common code Render implementations share one interface and a lot of common code – State & resource management – Draw list processing – Shader subsystem, etc.
7
D3D10 in context of a multi-platform engine (3/3) Certain API changes required special consideration Certain API changes required special consideration – State objects – Shader model 4.0 – Constant buffers – Strict API validation (shader linkage, etc) – Buffer updates Support for new features Support for new features – E.g. Geometry Shader, Stream Out, Texture Arrays
8
Porting and making it work (1/2) Render code separates platform / API dependent parts from independent parts Render code separates platform / API dependent parts from independent parts D3D10 renderer specializes base renderer D3D10 renderer specializes base renderer Inherits interface and all common code Inherits interface and all common code
9
Porting and making it work (2/2) Platform / API dependent parts wrapped and called from common code Platform / API dependent parts wrapped and called from common code Provided stubs implemented one at a time Provided stubs implemented one at a time #ifdef where API characteristics were awkward to map to common code flow #ifdef where API characteristics were awkward to map to common code flow
10
Special considerations (1/5): State objects Need fine grained control over render states! Need fine grained control over render states! Wrap state manipulation Wrap state manipulation Internally caches state objects Internally caches state objects Currently build state objects on demand Currently build state objects on demand Pre-warming cache might be worthwhile Pre-warming cache might be worthwhile
11
Special considerations (2/5): Shader model 4.0 Use custom shader / effect system Use custom shader / effect system Updated to support new API features and enhanced HLSL syntax Updated to support new API features and enhanced HLSL syntax Query resource bindings via Shader Reflection Query resource bindings via Shader Reflection Compile existing shaders as is (/Gec) Compile existing shaders as is (/Gec) Refactored to utilize load balancing Refactored to utilize load balancing Still use shader cache Still use shader cache
12
Special considerations (3/5): Constant buffers Group constants by frequency of update Group constants by frequency of update Each group maps to a unique CB index Each group maps to a unique CB index Constants bound via semantic which encodes group id Constants bound via semantic which encodes group id Allows preprocessor to move constants into their appropriate CB scope Allows preprocessor to move constants into their appropriate CB scope – Existing shaders automatically benefit from efficient binding – Source shader scripts devoid of API specific annotations – Shader authors dont have to worry about API
13
Special considerations (4/5): Strict API validation API rigorously checks how user drives it API rigorously checks how user drives it Simplifies lower API / driver levels Simplifies lower API / driver levels Example: Shader linkage Example: Shader linkage – Vertex layout / output signature has to match input signatures of following shader – Dimension of each passed element has to match dimension expected in following shader – Took some time to clean up / unify signatures – Nice side effect: Signature-fixed shaders run faster on DX9
14
Special considerations (5/5): Buffer updates Update methods for truly static / dynamic buffers remain as in D3D9 Update methods for truly static / dynamic buffers remain as in D3D9 Occasional updates of static buffers can cause severe pipeline stalls (e.g. updating terrain) Occasional updates of static buffers can cause severe pipeline stalls (e.g. updating terrain) Staging resources as intermediate storage Staging resources as intermediate storage This way mesh update can be pipelined This way mesh update can be pipelined
15
Random DX10 bits used in CryEngine2 GS used for particles and shadows GS used for particles and shadows Viewports for texture atlas Viewports for texture atlas Filtered texture lookups in vertex shader (FFT water) Filtered texture lookups in vertex shader (FFT water) Multi-sampled texture lookup (HDR post-processing) Multi-sampled texture lookup (HDR post-processing) Sample depth from z buffer Sample depth from z buffer Render to volume texture Render to volume texture
16
New D3D10 features are great New D3D10 features are great Perf improvements are definitely there Perf improvements are definitely there Expect several code revisions to drive the API in the most efficient way Expect several code revisions to drive the API in the most efficient way Conclusion
17
More details [1] Finding Next-Gen, Martin Mittring, SIGGRAPH 2007 [1] Finding Next-Gen, Martin Mittring, SIGGRAPH 2007 – Part of course 28, Advanced Real-time Rendering in 3D Graphics in Games – Wed Aug 8 th, Room 7AB, 8:30 am - 5:30 pm [2] Real-time Atmospheric Effects in Games Revisited, Carsten Wenzel, GDC 2007 [2] Real-time Atmospheric Effects in Games Revisited, Carsten Wenzel, GDC 2007 – Slides and course notes available online
18
Acknowledgements Crytek R&D Graphics Group Crytek R&D Graphics Group Many thanks to MS, NVIDIA and ATI for the support Many thanks to MS, NVIDIA and ATI for the support
19
Questions? *
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.