320 likes | 506 Views
Graphics with the Direct3D11.1 API made e asy. Phillip Napieralski Program Manager GIA2 3-113. Agenda. Transitioning to WinRT and DirectX11.1 Developing with Direct3D11.1 Debugging and testing Case study: AccuWeather. Transitioning to WinRT and DirectX11.1. DirectX versions.
E N D
Graphics with the Direct3D11.1 API made easy Phillip Napieralski Program Manager GIA2 3-113
Agenda • Transitioning to WinRTand DirectX11.1 • Developing with Direct3D11.1 • Debugging and testing • Case study: AccuWeather
DirectX versions • Windows XP DirectX 9 hardware DirectX 9 API • Windows Vista DirectX 10 hardware DirectX 10 API • Windows 7 DirectX 11 hardware DirectX 11 API • How do you design your software for all this hardware
DirectX 11.1 • DirectX11.1 is the API that ships with Windows 8 • Better graphics stack integration • DirectX11+ utilizes tessellation and stereoscopic 3D • Not all hardware supports DirectX 11 features • Current ARM devices for instance
Windows SDK • The DirectX SDK is now part of the Windows SDK • Use the Windows SDK to pass certification • This offers new opportunities for Windows Store Apps • Build-time shader compilation with Visual Studio’s HLSL compiler, FXC.exe • Try the Visual Shader Designer in Visual Studio 2012 • Check out MSDN for more information
Feature levels • DirectX11 API provides a uniform interface to access hardware capabilities • Feature levels map to hardware capabilities • Feature 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)
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 • More information about the features available in each level on MSDN
Feature level 10 • Available on DX10 and above hardware • Vertex shaders • Pixel shaders • 8 textures • 4 render targets • Cube maps • Volume textures • Anisotropic filtering • Antialiasing • HDR rendering • More information about the features available in each level on MSDN Geometry shaders Stream out 128 textures per shader 8 render targets Integesin shaders Vertex textures Shader sampling Constant buffers Alpha-to-coverage Basic DirectCompute Async resource creation
Feature level 11 • Available on DX11 and above hardware • Vertex shaders • Pixel shaders • 8 textures • 4 render targets • Cube maps • Volume textures • Anisotropic filtering • Antialiasing • HDR rendering • More information about the features available in each level on MSDN Full DirectCompute Random access writes Tessellation shaders New compression format Multithreading 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
Feature level considerations • Max texture dimension • Feature level 9_1 supports up to 2048 x 2048 • Max primitive count • Feature level 9_1 supports up to 65535 • Instancing • Supported by feature levels 9_3 and up • Launch ARM devices support feature levels 9_1 or 9_3 • More information about the features available in each level on MSDN
Development recommendations • Target feature level 9_1 and scale up features • Adjust to maintain performance • If you require a higher feature level • Tell the user the app requires a certain feature level or higher
Store policy • ARM or Neutral packages must support feature level 9_1 • You may specify a higher feature level when submitting app • Check the feature level at the launch of your app • Notify the user if their machine is not the appropriate feature level • Specify feature level in app description • More information about feature level store policy on MSDN
Feature levels to support • voidDirect3DBase::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 • }; • // ...
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 );
Checking the feature level • // Determine the technique that will be used to render the sprites. • autofeatureLevel = d3dDevice->GetFeatureLevel(); • if(featureLevel >= D3D_FEATURE_LEVEL_10_0) • { • // Generate sprites on GPU using Geometry Shader • m_technique = RenderTechnique::GeometryShader; • } Code from BasicSprites.cpp in the Sprite Sample on MSDN
Authoring a shader • Syntax highlighting for HLSL • HLSL is compiled at build time with fxc.exe • High level shader language • HLSL 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
Testing recommendations • Test individual feature levels using dxcpl.exe • Review shader code • Ensure shader model matches the feature level you are targeting • Test on a variety of hardware • ARM, Intel, AMD, nVidia, old and new • Confirm hardware specific issues using WARP
Debugging graphics • Visual studio graphics debugging for x86/x64 systems • Check out Build talk • 2-032, DirectX • Graphics Development • with Visual Studio 2012
Remote debugging • Test your app on Windows RT • Download and run remote tools for your testing device • In your VS project properties, find the remote machine • Hit the green arrow to start debugging and enjoy • Remote Tools available at microsoft.com • Setup instructions on MSDN
Case study: AccuWeather • Stephen Keefer • Programmer
Challenges Supporting 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 same Small developer community
Overcoming challenges ABI Proxy allows C# and C++ code communication CreateSwapChainForComposition instead of CreateSwapChainForCoreWindow Blend states for transitioning
Developer takeaways Windows 8=smooth integration of DirectX power with XAML layout DirectX=brings your application into the future
Wrap up • Thanks to AccuWeather • When designing your app, consider feature levels • Utilize samples to guide this process • Sprite sample at dev.windows.com (click samples and search there)
Resources • Online Resources • Where is the DirectX SDK • Direct3D feature levels • Feature level store policy • Sprite sample • Remote debugging tools • Remote debugging setup • Other resources at //Build • Other graphics talks 2-032, 3-109, 3-112 and 4-102 • Please submit session evals on the Build Windows 8 App or at http://aka.ms/BuildSessions
Resources • Develop: http://msdn.microsoft.com/en-US/windows/apps/br229512 • Design: http://design.windows.com/ • Samples: http://code.msdn.microsoft.com/windowsapps/Windows-8-Modern-Style-App-Samples • Videos: http://channel9.msdn.com/Windows Please submit session evals by using the Build Windows 8 app or at http://aka.ms/BuildSessions