+ All Categories
Home > Documents > Developing Metro style games on the Full Range of Windows 8 Devices Dan McLachlan Principal Program...

Developing Metro style games on the Full Range of Windows 8 Devices Dan McLachlan Principal Program...

Date post: 12-Jan-2016
Category:
Upload: lesley-parker
View: 229 times
Download: 0 times
Share this document with a friend
Popular Tags:
53
Transcript
Page 1: Developing Metro style games on the Full Range of Windows 8 Devices Dan McLachlan Principal Program Manager Lead Direct3D Microsoft Corporation.
Page 2: Developing Metro style games on the Full Range of Windows 8 Devices Dan McLachlan Principal Program Manager Lead Direct3D Microsoft Corporation.

Developing Metro style games on the Full Range of Windows 8 Devices

Dan McLachlanPrincipal Program Manager Lead Direct3DMicrosoft Corporation

Page 3: Developing Metro style games on the Full Range of Windows 8 Devices Dan McLachlan Principal Program Manager Lead Direct3D Microsoft Corporation.

Agenda

Windows 8 hardware diversity A unified 3D API to access the power of the GPU Designing for the Broadest Reach Strategies for dynamic calibration Tile-based rendering optimizations Recommendations

Page 4: Developing Metro style games on the Full Range of Windows 8 Devices Dan McLachlan Principal Program Manager Lead Direct3D Microsoft Corporation.

Windows 8 Hardware Diversity

Page 5: Developing Metro style games on the Full Range of Windows 8 Devices Dan McLachlan Principal Program Manager Lead Direct3D Microsoft Corporation.

Hardware Landscape

Page 6: Developing Metro style games on the Full Range of Windows 8 Devices Dan McLachlan Principal Program Manager Lead Direct3D Microsoft Corporation.

Wider range of hardwareimplies reconsideration of

your design point

Page 7: Developing Metro style games on the Full Range of Windows 8 Devices Dan McLachlan Principal Program Manager Lead Direct3D Microsoft Corporation.

New Category of Windows PCs

New design point Always on, always connected System on a chip Battery is primary power source Focus on low power

Both x86/x64 and ARM-based systems Covers a range of form factors

Page 8: Developing Metro style games on the Full Range of Windows 8 Devices Dan McLachlan Principal Program Manager Lead Direct3D Microsoft Corporation.

A Unified 3D API

Page 9: Developing Metro style games on the Full Range of Windows 8 Devices Dan McLachlan Principal Program Manager Lead Direct3D Microsoft Corporation.

DirectX Versions

Windows XP DirectX 9 Hardware Direct3D 9 API

Windows Vista DirectX 10 Hardware Direct3D 10 API

Windows 7 DirectX 11 Hardware Direct3D 11 API

How do you design your software for all this hardware?

Page 10: Developing Metro style games on the Full Range of Windows 8 Devices Dan McLachlan Principal Program Manager Lead Direct3D Microsoft Corporation.

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

Page 11: Developing Metro style games on the Full Range of Windows 8 Devices Dan McLachlan Principal Program Manager Lead Direct3D Microsoft Corporation.

Direct3D 11 is the APIfor driving graphics hardware

Page 12: Developing Metro style games on the Full Range of Windows 8 Devices Dan McLachlan Principal Program Manager Lead Direct3D Microsoft Corporation.

Direct3D Features (all Feature Levels)

HLSL shader programming Low-precision and high-precision instructions Consistent implementation on all devices

Page 13: Developing Metro style games on the Full Range of Windows 8 Devices Dan McLachlan Principal Program Manager Lead Direct3D Microsoft Corporation.

Feature Level 9(Available on ALL hardware)

• Vertex shaders• Pixel shaders• 8 Textures• 4 Render Targets• Cube maps• Volume textures• Anisotropic filtering• Antialiasing• HDR rendering• Texture compression

Page 14: Developing Metro style games on the Full Range of Windows 8 Devices Dan McLachlan Principal Program Manager Lead Direct3D Microsoft Corporation.

Feature Level 10(Available on DirectX 10 and later hardware)

• 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

Page 15: Developing Metro style games on the Full Range of Windows 8 Devices Dan McLachlan Principal Program Manager Lead Direct3D Microsoft Corporation.

Feature Level 11(Available on DirectX 11 and later hardware)

• 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

Page 16: Developing Metro style games on the Full Range of Windows 8 Devices Dan McLachlan Principal Program Manager Lead Direct3D Microsoft Corporation.

New Direct3D 11.1 Features

Logic operations in output merger Dynamic updates to constant buffers Low-precision math: min16_float, min10_float, min16_int

Hardware can promote silently to single-precision float UAVs at every stage Faster double-precision division instructions Video support

Graphics + Video integrated driver MSAD4 instruction Headless/Session 0

Page 17: Developing Metro style games on the Full Range of Windows 8 Devices Dan McLachlan Principal Program Manager Lead Direct3D Microsoft Corporation.

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;

Page 18: Developing Metro style games on the Full Range of Windows 8 Devices Dan McLachlan Principal Program Manager Lead Direct3D Microsoft Corporation.

Create the Device and Context

ComPtr<ID3D11Device> device;ComPtr<ID3D11DeviceContext> context;D3D11CreateDevice( nullptr, // use the default adapter D3D_DRIVER_TYPE_HARDWARE, 0, // use 0 unless a software device creationFlags, // defined above featureLevels, // what app will support ARRAYSIZE(featureLevels), D3D11_SDK_VERSION, // should always be D3D11_SDK_VERSION &device, // created device &m_featureLevel, // feature level of the device &context // corresponding immediate context );

Page 19: Developing Metro style games on the Full Range of Windows 8 Devices Dan McLachlan Principal Program Manager Lead Direct3D Microsoft Corporation.

Designing for Broadest Reach

Page 20: Developing Metro style games on the Full Range of Windows 8 Devices Dan McLachlan Principal Program Manager Lead Direct3D Microsoft Corporation.

Particle Systems with Dynamic Calibration

demo

Page 21: Developing Metro style games on the Full Range of Windows 8 Devices Dan McLachlan Principal Program Manager Lead Direct3D Microsoft Corporation.

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

Page 22: Developing Metro style games on the Full Range of Windows 8 Devices Dan McLachlan Principal Program Manager Lead Direct3D Microsoft Corporation.

DirectX Control Panel

Page 23: Developing Metro style games on the Full Range of Windows 8 Devices Dan McLachlan Principal Program Manager Lead Direct3D Microsoft Corporation.

Differentiation

Use advanced features when available Stereo 3D Tessellation

Left eye image Right eye image

L R

Page 24: Developing Metro style games on the Full Range of Windows 8 Devices Dan McLachlan Principal Program Manager Lead Direct3D Microsoft Corporation.

Differentiation

Increase Visual Quality Higher resolution textures Use bump maps

Page 25: Developing Metro style games on the Full Range of Windows 8 Devices Dan McLachlan Principal Program Manager Lead Direct3D Microsoft Corporation.

Texture Considerations

Balance visual quality with performance Scale back on size via mipmap levels Use block-compressed texture formats

512 x 512

256 x 256

1024 x 1024

Page 26: Developing Metro style games on the Full Range of Windows 8 Devices Dan McLachlan Principal Program Manager Lead Direct3D Microsoft Corporation.

Other Considerations

Geometry Feature_Level_11 – use tessellation for more polygon count control Consider lower-resolution (lower vertex count) meshes

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

Page 27: Developing Metro style games on the Full Range of Windows 8 Devices Dan McLachlan Principal Program Manager Lead Direct3D Microsoft Corporation.

Feature Level ≠ PerformanceDynamic calibration is critical to achieving

performance

Page 28: Developing Metro style games on the Full Range of Windows 8 Devices Dan McLachlan Principal Program Manager Lead Direct3D Microsoft Corporation.

Conventional Belief versus Reality

DirectX 9 DirectX 10 DirectX 10.1 DirectX 11 DirectX 11.1

Rela

tive P

erf

orm

an

ce

Page 29: Developing Metro style games on the Full Range of Windows 8 Devices Dan McLachlan Principal Program Manager Lead Direct3D Microsoft Corporation.

Calibration

Create device Set limits based on returned Feature Level Render a set of characteristic frames without presenting Adjust based on results

Page 30: Developing Metro style games on the Full Range of Windows 8 Devices Dan McLachlan Principal Program Manager Lead Direct3D Microsoft Corporation.

Calibrating Render Performance

Initialize a query event

Render a set of frames.

Wait until all rendering is completed.

Get elapsed time.

ComPtr<ID3D11Query> eventQuery;D3D11_QUERY_DESC queryDesc;queryDesc.Query = D3D11_QUERY_EVENT;queryDesc.MiscFlags = 0;

m_d3dDevice->CreateQuery(&queryDesc, &eventQuery);m_timer.reset();Render();

for (int i = 0; i < 18; i++){ m_d3dDeviceContext->Flush(); Render();}m_d3dDeviceContext->End(eventQuery.Get());if (S_FALSE == _d3dDeviceContext->GetData(eventQuery.Get(), NULL, 0, 0)){ while (S_FALSE == m_d3dDeviceContext->GetData(eventQuery.Get(), NULL, 0, D3D11_ASYNC_GETDATA_DONOTFLUSH));}m_timer.tick();float elapsedTime = m_timer.getDeltaTime();

Page 31: Developing Metro style games on the Full Range of Windows 8 Devices Dan McLachlan Principal Program Manager Lead Direct3D Microsoft Corporation.

Trade-offs: PerformanceVisual Quality

Power Consumption

Page 32: Developing Metro style games on the Full Range of Windows 8 Devices Dan McLachlan Principal Program Manager Lead Direct3D Microsoft Corporation.

Increasing Performance

Reduce rendering costs Minimize shader computation complexity Minimize redundant work

Reduce rasterization work Scale final render target if pixel bound Minimize depth complexity or overdraw

Page 33: Developing Metro style games on the Full Range of Windows 8 Devices Dan McLachlan Principal Program Manager Lead Direct3D Microsoft Corporation.

Reducing Rendering Costs

New Direct3D features, especially for reducing power consumption

Available across ALL feature levels Minimum precision Tile-based rendering optimizations

Page 34: Developing Metro style games on the Full Range of Windows 8 Devices Dan McLachlan Principal Program Manager Lead Direct3D Microsoft Corporation.

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

Page 35: Developing Metro style games on the Full Range of Windows 8 Devices Dan McLachlan Principal Program Manager Lead Direct3D Microsoft Corporation.

Minimum PrecisionHLSL Code Sample

static const float brightThreshold = 0.5f;

Texture2D sourceTexture : register(t0);float4 DownScale3x3BrightPass(QuadVertexShaderOutput input) : SV_TARGET{ float3 brightColor = 0; // Gather 16 adjacent pixels (each bilinear sample reads a 2x2 region) brightColor = sourceTexture.Sample(linearSampler, input.tex, int2(-1,-1)).rgb; brightColor += sourceTexture.Sample(linearSampler, input.tex, int2( 1,-1)).rgb; brightColor += sourceTexture.Sample(linearSampler, input.tex, int2(-1, 1)).rgb; brightColor += sourceTexture.Sample(linearSampler, input.tex, int2( 1, 1)).rgb; brightColor /= 4.0f;

// Brightness thresholding brightColor = max(0, brightColor - brightThreshold);

return float4(brightColor, 1.0f);}

Page 36: Developing Metro style games on the Full Range of Windows 8 Devices Dan McLachlan Principal Program Manager Lead Direct3D Microsoft Corporation.

Minimum PrecisionHLSL Code Sample

static const min16float brightThreshold = (min16float)0.5;

Texture2D<min16float4> sourceTexture : register(t0);float4 DownScale3x3BrightPass(QuadVertexShaderOutput input) : SV_TARGET{ min16float3 brightColor = 0; // Gather 16 adjacent pixels (each bilinear sample reads a 2x2 region) brightColor = sourceTexture.Sample(linearSampler, input.tex, int2(-1,-1)).rgb; brightColor += sourceTexture.Sample(linearSampler, input.tex, int2( 1,-1)).rgb; brightColor += sourceTexture.Sample(linearSampler, input.tex, int2(-1, 1)).rgb; brightColor += sourceTexture.Sample(linearSampler, input.tex, int2( 1, 1)).rgb; brightColor /= (min16float)4.0;

// Brightness thresholding brightColor = max(0, brightColor - brightThreshold);

return float4(brightColor, 1.0f);}

Page 37: Developing Metro style games on the Full Range of Windows 8 Devices Dan McLachlan Principal Program Manager Lead Direct3D Microsoft Corporation.

Tile-based Rendering

Some graphics architectures use tile caches Cache access is much faster than GPU memory bus Goal is to keep data in the cache as long as possible Loops over the command stream once per tile

Page 38: Developing Metro style games on the Full Range of Windows 8 Devices Dan McLachlan Principal Program Manager Lead Direct3D Microsoft Corporation.

Typical Rendering

CommandBuffer1Command1Command2Command3Command4Command5Command6CommandBuffer2Command1Command2Command3Command4Command5Command6CommandBuffer3Command1Command2Command3Command4Command5Command6

Command Stream

Command stream sent to GPU

Page 39: Developing Metro style games on the Full Range of Windows 8 Devices Dan McLachlan Principal Program Manager Lead Direct3D Microsoft Corporation.

Tile Based Rendering

CommandBuffer1Command1Command2Command3Command4Command5Command6CommandBuffer2Command1Command2Command3Command4Command5Command6CommandBuffer3Command1Command2Command3Command4Command5Command6

Buffered Commands

Send Command Stream to GPUExecute Command Stream for Tile 1Execute Command Stream for Tile 2

Execute Command Stream for Tile 3Execute Command Stream for Tile 4Execute Command Stream for Tile 5Execute Command Stream for Tile 6Display the final image

Page 40: Developing Metro style games on the Full Range of Windows 8 Devices Dan McLachlan Principal Program Manager Lead Direct3D Microsoft Corporation.

Tile-based Rendering Optimizations

The Challenge: Some rendering sequences result in Direct3D needing to do multiple copies of buffers to ensure rendering correctness.

The Solution: New Direct3D APIs provide hints to avoid unnecessary copies. Make a promise about your rendering behavior

Page 41: Developing Metro style games on the Full Range of Windows 8 Devices Dan McLachlan Principal Program Manager Lead Direct3D Microsoft Corporation.

Take advantage of tile-based rendering hints and

optimizations

Page 42: Developing Metro style games on the Full Range of Windows 8 Devices Dan McLachlan Principal Program Manager Lead Direct3D Microsoft Corporation.

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

Page 43: Developing Metro style games on the Full Range of Windows 8 Devices Dan McLachlan Principal Program Manager Lead Direct3D Microsoft Corporation.

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

Page 44: Developing Metro style games on the Full Range of Windows 8 Devices Dan McLachlan Principal Program Manager Lead Direct3D Microsoft Corporation.

Example: Dynamic Geometry

Page 45: Developing Metro style games on the Full Range of Windows 8 Devices Dan McLachlan Principal Program Manager Lead Direct3D Microsoft Corporation.

Example: Dynamic Geometry

Create vertex buffer Generate geometry data Draw Generate geometry data Draw Present

Vertex buffer

DISCARD

No Overwrite

Page 46: Developing Metro style games on the Full Range of Windows 8 Devices Dan McLachlan Principal Program Manager Lead Direct3D Microsoft Corporation.

Recommendations

Page 47: Developing Metro style games on the Full Range of Windows 8 Devices Dan McLachlan Principal Program Manager Lead Direct3D Microsoft Corporation.

System Configurations

Development machine [Asus G73 Gaming Laptop] AMD 5870M GPU (DX11) 64-bit OS, Core i7 quad core CPU, 8 GB memory

Test machine (Laptop) [HP Elitebook 2740p] DirectX 10 graphics and touch 64-bit OS, 4 GB memory

Test machine (Netbook) [HP Mini 5102T] DirectX 9.1 graphics and touch 32-bit OS, Atom processor, 1 GB to 2 GB memory

Page 48: Developing Metro style games on the Full Range of Windows 8 Devices Dan McLachlan Principal Program Manager Lead Direct3D Microsoft Corporation.

Considerations

Touch capabilities are important Minimum screen resolution of 1366 x 768 Test across a diversity of machines

Page 49: Developing Metro style games on the Full Range of Windows 8 Devices Dan McLachlan Principal Program Manager Lead Direct3D Microsoft Corporation.

Conclusion

Page 50: Developing Metro style games on the Full Range of Windows 8 Devices Dan McLachlan Principal Program Manager Lead Direct3D Microsoft Corporation.

Conclusion

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

Page 51: Developing Metro style games on the Full Range of Windows 8 Devices Dan McLachlan Principal Program Manager Lead Direct3D Microsoft Corporation.

Strategy Recap

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

Page 52: Developing Metro style games on the Full Range of Windows 8 Devices Dan McLachlan Principal Program Manager Lead Direct3D Microsoft Corporation.

Further Reading and Documentation

Direct3D 11.1 FeaturesD3D11_FEATURE_DATA_D3D11_OPTIONS structure DXGIAdapter2::GetDesc2 method

DXGI 1.2 ImprovementsCreating a DirectX Game

Unlocking the GPU with Direct3D (PDC 2008)Direct3D on Downlevel Hardware (MSDN)10Level9 ID3D11Device Methods (MSDN)10Level9 ID3D11DeviceContext Methods (MSDN)Hardware Support for Direct3D 10Level9 Formats (MSDN)

Questions? Visit the forums on the Windows Dev Center at http://forums.dev.windows.com

Page 53: Developing Metro style games on the Full Range of Windows 8 Devices Dan McLachlan Principal Program Manager Lead Direct3D Microsoft Corporation.

© 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be

interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.


Recommended