void direct3dbase::createdeviceresources() { d3d_feature_level featurelevels[] = {...

32
Graphics with the Direct3D11.1 API made easy Phillip Napieralski Program Manager GIA2 3-113

Upload: beverly-barber

Post on 24-Dec-2015

229 views

Category:

Documents


5 download

TRANSCRIPT

Page 1: void Direct3DBase::CreateDeviceResources() { D3D_FEATURE_LEVEL featureLevels[] = { D3D_FEATURE_LEVEL_11_1, D3D_FEATURE_LEVEL_11_0,

Graphics with the Direct3D11.1 API made easyPhillip NapieralskiProgram ManagerGIA23-113

Page 2: void Direct3DBase::CreateDeviceResources() { D3D_FEATURE_LEVEL featureLevels[] = { D3D_FEATURE_LEVEL_11_1, D3D_FEATURE_LEVEL_11_0,

Transitioning to WinRT and DirectX11.1

Developing with Direct3D11.1

Debugging and testing

Case study: AccuWeather

Agenda

Page 3: void Direct3DBase::CreateDeviceResources() { D3D_FEATURE_LEVEL featureLevels[] = { D3D_FEATURE_LEVEL_11_1, D3D_FEATURE_LEVEL_11_0,

Transitioning to WinRT and DirectX11.1

Page 4: void Direct3DBase::CreateDeviceResources() { D3D_FEATURE_LEVEL featureLevels[] = { D3D_FEATURE_LEVEL_11_1, D3D_FEATURE_LEVEL_11_0,

DirectX versionsWindows XP DirectX 9 hardware DirectX 9 APIWindows Vista DirectX 10 hardware DirectX 10 APIWindows 7 DirectX 11 hardware DirectX 11 APIHow do you design your software for all this hardware

Page 5: void Direct3DBase::CreateDeviceResources() { D3D_FEATURE_LEVEL featureLevels[] = { D3D_FEATURE_LEVEL_11_1, D3D_FEATURE_LEVEL_11_0,

DirectX 11.1DirectX11.1 is the API that ships with Windows 8Better graphics stack integrationDirectX11+ utilizes tessellation and stereoscopic 3DNot all hardware supports DirectX 11 featuresCurrent ARM devices for instance

Page 6: void Direct3DBase::CreateDeviceResources() { D3D_FEATURE_LEVEL featureLevels[] = { D3D_FEATURE_LEVEL_11_1, D3D_FEATURE_LEVEL_11_0,

Windows SDKThe DirectX SDK is now part of the Windows SDKUse the Windows SDK to pass certification

This offers new opportunities for Windows Store AppsBuild-time shader compilation with Visual Studio’s HLSL compiler, FXC.exeTry the Visual Shader Designer in Visual Studio 2012

Check out MSDN for more information

Page 7: void Direct3DBase::CreateDeviceResources() { D3D_FEATURE_LEVEL featureLevels[] = { D3D_FEATURE_LEVEL_11_1, D3D_FEATURE_LEVEL_11_0,

Feature levelsDirectX11 API provides a uniform interface to access hardware capabilitiesFeature levels map to hardware capabilitiesFeature level 9 DirectX 9 hardware (ARM/power efficient machines)Feature level 10 DirectX 10 hardware (many laptops)Feature level 11 DirectX 11 hardware (high end gaming machines)

Page 8: void Direct3DBase::CreateDeviceResources() { D3D_FEATURE_LEVEL featureLevels[] = { D3D_FEATURE_LEVEL_11_1, D3D_FEATURE_LEVEL_11_0,

Feature level 9Available on all hardwareVertex shadersPixel shaders8 textures4 render targetsCube mapsVolume texturesAnisotropic filteringAntialiasingHDR rendering

More information about the features available in each level on MSDN

Page 9: void Direct3DBase::CreateDeviceResources() { D3D_FEATURE_LEVEL featureLevels[] = { D3D_FEATURE_LEVEL_11_1, D3D_FEATURE_LEVEL_11_0,

Feature level 10Available on DX10 and above hardwareVertex shadersPixel shaders8 textures4 render targetsCube mapsVolume texturesAnisotropic filteringAntialiasingHDR rendering

More information about the features available in each level on MSDN

Geometry shaders

Stream out

128 textures per shader

8 render targets

Integes in shaders

Vertex textures

Shader sampling

Constant buffers

Alpha-to-coverage

Basic DirectCompute

Async resource creation

Page 10: void Direct3DBase::CreateDeviceResources() { D3D_FEATURE_LEVEL featureLevels[] = { D3D_FEATURE_LEVEL_11_1, D3D_FEATURE_LEVEL_11_0,

Feature level 11Available on DX11 and above hardwareVertex shadersPixel shaders8 textures4 render targetsCube mapsVolume texturesAnisotropic filteringAntialiasingHDR rendering

More information about the features available in each level on MSDN

Geometry shadersStream out128 textures per shader8 render targetsIntegers in shadersVertex texturesShader samplingConstant buffersAlpha-to-coverageBasic DirectComputeAsync resource creation

Full DirectComputeRandom access writesTessellation shadersNew compression formatMultithreading

Page 11: void Direct3DBase::CreateDeviceResources() { D3D_FEATURE_LEVEL featureLevels[] = { D3D_FEATURE_LEVEL_11_1, D3D_FEATURE_LEVEL_11_0,

Feature level considerationsMax texture dimensionFeature level 9_1 supports up to 2048 x 2048

Max primitive countFeature level 9_1 supports up to 65535

InstancingSupported by feature levels 9_3 and up

Launch ARM devices support feature levels 9_1 or 9_3More information about the features available in each level on MSDN

Page 12: void Direct3DBase::CreateDeviceResources() { D3D_FEATURE_LEVEL featureLevels[] = { D3D_FEATURE_LEVEL_11_1, D3D_FEATURE_LEVEL_11_0,

Demo

Sprite sample (feature levels)

Page 13: void Direct3DBase::CreateDeviceResources() { D3D_FEATURE_LEVEL featureLevels[] = { D3D_FEATURE_LEVEL_11_1, D3D_FEATURE_LEVEL_11_0,

Developing with Direct3D11.1

Page 14: void Direct3DBase::CreateDeviceResources() { D3D_FEATURE_LEVEL featureLevels[] = { D3D_FEATURE_LEVEL_11_1, D3D_FEATURE_LEVEL_11_0,

Development recommendationsTarget feature level 9_1 and scale up featuresAdjust to maintain performanceIf you require a higher feature levelTell the user the app requires a certain feature level or higher

Page 15: void Direct3DBase::CreateDeviceResources() { D3D_FEATURE_LEVEL featureLevels[] = { D3D_FEATURE_LEVEL_11_1, D3D_FEATURE_LEVEL_11_0,

Store policyARM or Neutral packages must support feature level 9_1You may specify a higher feature level when submitting appCheck the feature level at the launch of your appNotify the user if their machine is not the appropriate feature level

Specify feature level in app descriptionMore information about feature level store policy on MSDN

Page 16: void Direct3DBase::CreateDeviceResources() { D3D_FEATURE_LEVEL featureLevels[] = { D3D_FEATURE_LEVEL_11_1, D3D_FEATURE_LEVEL_11_0,

Feature levels to supportvoid Direct3DBase::CreateDeviceResources(){ 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_2, D3D_FEATURE_LEVEL_9_1 }; // ...

Page 17: void Direct3DBase::CreateDeviceResources() { D3D_FEATURE_LEVEL featureLevels[] = { D3D_FEATURE_LEVEL_11_1, D3D_FEATURE_LEVEL_11_0,

Get the machine feature level

D3D11CreateDevice( nullptr, // use the default adapter D3D_DRIVER_TYPE_HARDWARE, 0, 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 18: void Direct3DBase::CreateDeviceResources() { D3D_FEATURE_LEVEL featureLevels[] = { D3D_FEATURE_LEVEL_11_1, D3D_FEATURE_LEVEL_11_0,

Checking the feature level

// Determine the technique that will be used to render the sprites.auto featureLevel = d3dDevice->GetFeatureLevel();

if (featureLevel >= D3D_FEATURE_LEVEL_10_0){

// Generate sprites on GPU using Geometry Shaderm_technique = RenderTechnique::GeometryShader;

}

Code from BasicSprites.cpp in the Sprite Sample on MSDN

Page 19: void Direct3DBase::CreateDeviceResources() { D3D_FEATURE_LEVEL featureLevels[] = { D3D_FEATURE_LEVEL_11_1, D3D_FEATURE_LEVEL_11_0,

Authoring a shaderSyntax highlighting for HLSLHLSL is compiled at build time with fxc.exeHigh level shader languageHLSL source files are automatically compiled to .cso

Driver translates (JITs) to it’s own instruction set whend3dDevice->CreatePixelShader(..) is called Shader model and type set in properties pane

Page 20: void Direct3DBase::CreateDeviceResources() { D3D_FEATURE_LEVEL featureLevels[] = { D3D_FEATURE_LEVEL_11_1, D3D_FEATURE_LEVEL_11_0,

Debugging and testing

Page 21: void Direct3DBase::CreateDeviceResources() { D3D_FEATURE_LEVEL featureLevels[] = { D3D_FEATURE_LEVEL_11_1, D3D_FEATURE_LEVEL_11_0,

Testing recommendationsTest individual feature levels using dxcpl.exeReview shader codeEnsure shader model matches the feature level you are targeting

Test on a variety of hardwareARM, Intel, AMD, nVidia, old and new

Confirm hardware specific issues using WARP

Page 22: void Direct3DBase::CreateDeviceResources() { D3D_FEATURE_LEVEL featureLevels[] = { D3D_FEATURE_LEVEL_11_1, D3D_FEATURE_LEVEL_11_0,

Debugging graphicsVisual studio graphics debugging for x86/x64 systems

Check out Build talk 2-032, DirectX Graphics Development with Visual Studio 2012

Page 23: void Direct3DBase::CreateDeviceResources() { D3D_FEATURE_LEVEL featureLevels[] = { D3D_FEATURE_LEVEL_11_1, D3D_FEATURE_LEVEL_11_0,

Remote debuggingTest your app on Windows RTDownload and run remote tools for your testing deviceIn your VS project properties, find the remote machineHit the green arrow to start debugging and enjoy

Remote Tools available at microsoft.comSetup instructions on MSDN

Page 24: void Direct3DBase::CreateDeviceResources() { D3D_FEATURE_LEVEL featureLevels[] = { D3D_FEATURE_LEVEL_11_1, D3D_FEATURE_LEVEL_11_0,

Stephen KeeferProgrammer

Case study: AccuWeather

Page 25: void Direct3DBase::CreateDeviceResources() { D3D_FEATURE_LEVEL featureLevels[] = { D3D_FEATURE_LEVEL_11_1, D3D_FEATURE_LEVEL_11_0,

ChallengesSupporting all feature sets (9.1 thru 11.1)Supporting multiple platforms (x86, x64, and ARM)Transferring weather data from C# (client app) to C++ (DX Renderer)Creating fully dynamic scenes, no two scenes are the sameSmall developer community

Page 26: void Direct3DBase::CreateDeviceResources() { D3D_FEATURE_LEVEL featureLevels[] = { D3D_FEATURE_LEVEL_11_1, D3D_FEATURE_LEVEL_11_0,

Overcoming challengesABI Proxy allows C# and C++ code communicationCreateSwapChainForComposition instead of CreateSwapChainForCoreWindowBlend states for transitioning

Page 27: void Direct3DBase::CreateDeviceResources() { D3D_FEATURE_LEVEL featureLevels[] = { D3D_FEATURE_LEVEL_11_1, D3D_FEATURE_LEVEL_11_0,

Instancing in DirectX 10 and 11

Page 28: void Direct3DBase::CreateDeviceResources() { D3D_FEATURE_LEVEL featureLevels[] = { D3D_FEATURE_LEVEL_11_1, D3D_FEATURE_LEVEL_11_0,

Developer takeawaysWindows 8=smooth integration of DirectX power with XAML layoutDirectX=brings your application into the future

Page 29: void Direct3DBase::CreateDeviceResources() { D3D_FEATURE_LEVEL featureLevels[] = { D3D_FEATURE_LEVEL_11_1, D3D_FEATURE_LEVEL_11_0,

Wrap upThanks to AccuWeatherWhen designing your app, consider feature levelsUtilize samples to guide this processSprite sample at dev.windows.com (click samples and search there)

Page 32: void Direct3DBase::CreateDeviceResources() { D3D_FEATURE_LEVEL featureLevels[] = { D3D_FEATURE_LEVEL_11_1, D3D_FEATURE_LEVEL_11_0,

© 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.