High Performance in Broad Reach Games Chas. Boyd Principal Program Manager Microsoft Corporation Agenda Windows 8 hardware diversity A unified 3D API to access the power.

Download Report

Transcript High Performance in Broad Reach Games Chas. Boyd Principal Program Manager Microsoft Corporation Agenda Windows 8 hardware diversity A unified 3D API to access the power.

High Performance
in Broad Reach Games
Chas. Boyd
Principal Program Manager
Microsoft Corporation
Agenda
Windows 8 hardware diversity
A unified 3D API to access the power of the GPU
Designing for the Broadest Reach
Optimizing Performance
Tile-based rendering optimizations
Recommendations
3 Presentations Today
Step by Step through Game Development
1) How to set up the game
2) How to code it
3) How to optimize it
<- You are here
Windows 8 PC Hardware Diversity
GPU Hardware Evolution
Year Version
Defining Feature
1996
1997
1998
1999
2000
2001
2002
2003
2006
2009
Hardware rasterization
2 Shading options to choose from
Multi-texture operations
Vertex Processing in hardware
Programmable Shaders: Vertex and Pixel
Longer shaders
High Level Shading Language, 32 instr
1000s of instructions per shader
Geometry shader, Consistent shader models
Compute Shader, Tessellation
DirectX3
DirectX5
DirectX6
DirectX7
DirectX8
DirectX8.1
DirectX9
DirectX9c
DirectX10
DirectX11
After
Before DirectX
Vertex shaders
Pixel shaders
8 Textures
4 Render Targets
Cube maps
Volume textures
Anisotropic filtering
Antialiasing
HDR rendering
Texture compression
Vertex shaders
Pixel shaders
8 Textures
4 Render Targets
Cube maps
Volume textures
Anisotropic filtering
Antialiasing
HDR rendering
Texture compression
Geometry shaders
Stream out
128 Textures per shader
8 Render Targets
Integers in shaders
Vertex textures
Shader sampling
Constant buffers
Alpha-to-coverage
Basic DirectCompute
Async resource creation
Vertex shaders
Pixel shaders
8 Textures
4 Render Targets
Cube maps
Volume textures
Anisotropic filtering
Antialiasing
HDR rendering
Texture compression
Geometry shaders
Stream out
128 Textures per shader
8 Render Targets
Integers in shaders
Vertex textures
Shader sampling
Constant buffers
Alpha-to-coverage
Basic DirectCompute
Async resource creation
Full DirectCompute
Random access writes
Tessellation shaders
New compression formats
Shader linkage
Feature Levels
Direct3D 11 provides a uniform interface to access
hardware capabilities
Feature Levels map to hardware capabilities
Feature_Level_9  DirectX 9 Hardware
Feature_Level_10  DirectX 10 Hardware
Feature_Level_11  DirectX 11 Hardware
Select Feature Levels to Support
D3D_FEATURE_LEVEL featureLevels[] =
{
D3D_FEATURE_LEVEL_11_1,
D3D_FEATURE_LEVEL_11_0,
D3D_FEATURE_LEVEL_10_1,
D3D_FEATURE_LEVEL_10_0,
D3D_FEATURE_LEVEL_9_3,
D3D_FEATURE_LEVEL_9_1
};
UINT creationFlags = D3D11_CREATE_DEVICE_BGRA_SUPPORT;
Create the Device and Context
ComPtr<ID3D11Device>
ComPtr<ID3D11DeviceContext>
nullptr
// use the default adapter
// use 0 unless a software device
// defined above
// what app will support
// should always be D3D11_SDK_VERSION
// created device
// feature level of the device
// corresponding immediate context
Development Strategy
Develop on DirectX 11 hardware
Target Feature_Level_9 and scale up
Include calibration code in game to dynamically configure for
current hardware
Be aware of Feature Level differences
Test by restricting Feature Level
Test on multiple PCs
DirectX Control Panel
Chapter 1/4
Balancing Act
Relative Performance
DirectX 9
DirectX 10 DirectX 10.1 DirectX 11 DirectX 11.1
Opposing Directions
Prune features and
image quality to meet
performance goals on
low-end hardware
Add features and image
quality to differentiate
your app on high-end
hardware
Development Strategy
Develop on DirectX 11 hardware
Target Feature_Level_9 and scale up
Include calibration code in game to dynamically
configure for current hardware
Adjust to maintain performance
Be aware of Feature Level differences
Test by restricting Feature Level
Test on multiple PCs
Differentiation
Increase Visual Quality
Higher resolution textures
Use bump maps
Texture Quality Control
Balance visual quality with performance
Scale back on size via mipmap levels
Use block-compressed
texture formats
Loader code skips mip levels
1024 x 1024
512 x 512
256 x 256
Optimization Techniques
Tune Anisotropic filter quality
Simple scalar value
MultiSampling AntiAliasing (MSAA)
Reduce sample count to maintain frame rate
Render to a lower resolution and scale up for final image
For best image quality, do not scale 2D text
Geometry
Feature_Level_11 – use tessellation for more polygon count control
Consider lower-resolution (lower vertex count) meshes
Basic Performance Checks
Be sure you are not setting state and loading data that
doesn’t change every frame
Set breakpoint in the render code
We’ve seen some apps drawing twice per frame
Make sure that the game loop routines are still in the
right order
Check to see if you are CPU bound, or GPU bound.
If GPU, check to see if you are fill-rate or vertex bound
Use PIX
PIX is a profiler mode for Visual Studio 11
You can use it to step-through DirectX API calls
And display:
event history
pixel history
DX rendering pipeline
the DX object table, and
call stacks
Chapter 3/4
More Optimizations
More Optimizations
Pure performance helps low-end hardware
But if image quality is not impacted, high-end hardware
benefits too
Minimum Precision is a new capability in Windows 8 HLSL
Minimum Precision
Reduce the number of bits of precision in shader calculations
Hints to the graphics driver where optimizations can be done
Specifies minimum rather than actual precision
min16float
min12int
min16int
Minimum Precision
HLSL Code Sample
static const
Texture2D
float4
register
// Gather 16 adjacent pixels (each bilinear sample reads a 2x2 region)
// Brightness thresholding
Minimum Precision
HLSL Code Sample
static const
Texture2D
float4
register
// Gather 16 adjacent pixels (each bilinear sample reads a 2x2 region)
// Brightness thresholding
Chapter 2/4
Tile –Based Rendering
Typical Rendering
Command stream sent to GPU
Command Stream
CommandBuffer1
Command1
Command2
Command3
Command4
Command5
Command6
CommandBuffer2
Command1
Command2
Command3
Command4
Command5
Command6
CommandBuffer3
Command1
Command2
Command3
Command4
Command5
Command6
Tile Based Rendering
Send Command Stream to GPU
Execute Command Stream for Tile 1
Execute Command Stream for Tile 2
Execute Command Stream for Tile 3
Execute Command Stream for Tile 4
Execute Command Stream for Tile 5
Execute Command Stream for Tile 6
Display the final image
Buffered Commands
CommandBuffer1
Command1
Command2
Command3
Command4
Command5
Command6
CommandBuffer2
Command1
Command2
Command3
Command4
Command5
Command6
CommandBuffer3
Command1
Command2
Command3
Command4
Command5
Command6
Tile-based Rendering Strategies
Avoid mid-scene flushes
Avoid swapping back and forth between RenderTargets
Use scissors when updating small portions of a RenderTarget
Use DISCARD and NO_OVERWRITE when possible
Tile-based Rendering Optimizations
GPUs with a tile-based rendering architecture can get a performance boost with a special flag:
m_swapChain->Present(1, 0);
// present the image on the display
ComPtr<ID3D11View> view;
m_renderTargetView.As(&view);
// get the view on the RT
m_d3dContext->DiscardView(view.Get());
// release the view
Chapter 4/4
Recommendations
Windows 8
Runs on the broadest graphics hardware diversity ever
Designed for graphics hardware acceleration
Direct3D 11 is the 3D API to access the power of the GPU
You can get Great Graphics Performance leveraging the
GPU AND hit the broadest markets
Strategy Recap for Indie Devs
Design for Feature_Level_9
Adjust at runtime for actual Feature Level
Use advanced features to differentiate when available
Dynamically calibrate for smooth performance
Use new Direct3D 11 features to better utilize
hardware
Minimum precision
Tile-based rendering optimizations
Time to Act
Biggest opportunity. Ever.
Windows 8 Consumer Preview is now available.
Check out the store.
Go build great games.
http://dev.windows.com
Q&A