DirectX 11 Technology Update US

download DirectX 11 Technology Update US

of 54

description

it dx11

Transcript of DirectX 11 Technology Update US

DirectX 11 Technology Update

4/29/2010 1:45 PM1DirectX 11 Technology UpdateChuck WalbournSenior Software Design EngineerMicrosoft

4/29/2010 1:45 PM2Direct3D 11 is out and ready for use by your game today to exploit the latest in video hardware features as well as current generation machines. This talk will get you up to speed with the API, tips on how to get your renderer up and running, key feature overviews, and how to deploy your application. Attending this talk is highly recommended if you are attending other DirectX 11 presentations.Gamefest 2008Graphics TrackIntroduction to the Direct3D 11 Graphics PipelineDirect3D 11 TessellationHigh Level Shader Language (HLSL) UpdateIntroducing Version 5.0Multithreaded Rendering for GamesDirect3D 11 Compute ShaderMore Generality for Advanced Techniques

Partners TrackAdvanced Topics in GPU Tessellation (AMD)Water-Tight, Textured, Displaced Subdivision Surface Tessellation Using Direct3D 11 (NVIDIA)www.microsoftgamefest.com

Of course, these were all before the RTM of Windows 7, the DirectX SDK DirectX 11 bits, the down-level RTM, etc.4/29/2010 1:45 PM3DirectX 11 OverviewDirect3D 11 is based on Direct3D 10.1Similar API design & rendering pipelineEnables new DirectX 11 hardware featuresSupports existing DirectX 10 and 10.1 hardwareEnables some new features as wellSupports a subset of DirectX 9 SM 2.0+ hardwareSupported on Windows 7, Windows Vista, Windows Server 2008, and Windows Server 2008 R2Input AssemblerVertex ShaderPixel ShaderHull ShaderRasterizerOutput MergerTessellatorDomain ShaderGeometry ShaderStream OutputNOTE: The pipeline diagram has animation, so you have to view it to see it correctly.4/29/2010 1:45 PM4Dynamic Shader LinkageClass Linkage on DirectX 11 HWinterface construct works on older profilesHardware TessellationDirectX 11 HW onlyHLSL Shader Model 55.0 on DirectX 11 HWSome new constructs emulated on older profilesMultithreaded Rendering & Resource CreationRuntime emulation or Driver optimizedDirectComputeCS 5.0 on DirectX 11 HWCS 4.x on some DX10.x h/wBC6H/BC7 Texture FormatsDirectX 11 HW only4/29/2010 1:45 PM5Features & Feature LevelsFeature levels are well-defined sets of functionalityNot a sea of opt-in caps bitsEach feature level is a superset of the previous oneConcept was introduced with Direct3D 10.1ID3D10Device1::GetFeatureLevel()D3D10_FEATURE_LEVEL_10_1D3D10_FEATURE_LEVEL_10_0Direct3D 9 Shader Model 3.0 tried to help by being more strict about what it meant to be a Shader Model 3.0 device.

Direct3D 10 resolved the caps problem by having a strict definition of device capabilities with only a few specific optional format usages.

4/29/2010 1:45 PM6

DirectX SDK Graphics Card Capabilities article (located in the Samples\C++\Direct3D9\ConfigSystem folder)Special thanks to AndyG!4/29/2010 1:45 PM7DirectX 11 Feature LevelsFeature LevelCapabilitiesD3D_FEATURE_LEVEL_10_0(e.g. NVIDIA GeForce 8000/9000 Series; GTX 260/280)Direct3D 10 hardware: Shader Model 4.0, geometry shader, stream out, alpha-to-coverage, MSAA textures, 2-sided stencil, general render target views, texture arrays, BC4/BC5, optional DirectCompute (CS 4.0), all 9_3 features.D3D_FEATURE_LEVEL_10_1(e.g. ATI Radeon HD 2000/3000/4000 Series; NVIDIA GeForce G210/GT220)Direct3D 10.1 hardware: Shader Model 4.1, cubemap arrays, extended MSAA, optional DirectCompute (CS 4.1), all 10_0 features.D3D_FEATURE_LEVEL_11_0(e.g. ATI Radeon HD 5000 Series)Direct3D 11 hardware: Shader Model 5.0, hull & domain shaders, mandatory DirectCompute (CS 5.0), BC6H/BC7, all 10_1 features.

http://msdn.microsoft.com/en-us/library/ee422086.aspx

Note that the example cards show the maximum feature level of the part (i.e. the ATI Radeon HD 2000 / 3000 / 4000 / 5000 Series also support D3D_FEATURE_LEVEL_10_0).4/29/2010 1:45 PM810level9 Feature LevelsFeature LevelCapabilitiesD3D_FEATURE_LEVEL_9_1(e.g. Intel G965 Express Chipset, NVidia GeForce FX 5200)Direct3D 9 hardware: must support Shader Model 2.0 (vs_2_0/ps_2_0), 2K textures, volume textures, event queries, BC1-3 (aka DXTn), and a few other specific capabilities.D3D_FEATURE_LEVEL_9_2(e.g. ATI Radeon 9500)

Direct3D 9 hardware: must support Shader Model 2.0 (vs_2_0/ps_2_0), occlusion queries, float formats (no blending), extended caps, all 9_1 features.D3D_FEATURE_LEVEL_9_3(e.g. NVidia GeForce 6600, ATI Radeon X1300)

Direct3D 9 hardware: must support Shader Model 2.0 (vs_2_0/ps_2_b) with instancing, 4K textures, multiple render targets (4 MRTs), floating-point blending, all 9_2 features.Technically a 10_0+ card might not support any 10level9 feature levels if it has no Direct3D 9 support. Almost all Direct3D cards do, however, support all these features levels if they support D3D_FEATURE_LEVEL_10_0 or later. The one current special case is the Intel Integrated Graphics DX10 parts only support D3D_FEATURE_LEVEL_10_0 and D3D_FEATURE_LEVEL_9_1, but not 9_2 or 9_34/29/2010 1:45 PM9Driver Optional FeaturesDevices can expose some new DXGI_FORMATsID3D11Device::CheckFormatSupportBGRA (B8G8R8*8) formatsrequired for 9_1, 9_2, 9_3 and 11_0optional for 10_0 / 10_110:10:10:2 X2 biased High Color mode (R10G10B10_XR_BIAS_X2_A2_UNORM)required for 11_0optional for 10_0 / 10_1not available for 9_1, 9_2, or 9_3Majority of format support is defined by feature levelDetailed in the DXGI Programmers Guide in the Windows Graphics documentation

10_0: http://msdn.microsoft.com/en-us/library/ee415674.aspx10_1: http://msdn.microsoft.com/en-us/library/ee415676.aspx11_0: http://msdn.microsoft.com/en-us/library/ee416140.aspx10level9: http://msdn.microsoft.com/en-us/library/ee416138.aspx4/29/2010 1:45 PM10Driver Optional FeaturesDirectX 11 drivers can support four optional featuresID3D11Device::CheckFeatureSupportDirectComputeD3D_FEATURE_LEVEL_10_0 / 10_1 support for CS 4.x is optionalCS 5.0 is required for D3D_FEATURE_LEVEL_11_0Double-precision shader support is optionalMultithreading Driver support is optionalConcurrent object creationCommand listshttp://msdn.microsoft.com/en-us/library/ee422109.aspx4/29/2010 1:45 PM11DirectX Graphics Infrastructure (DXGI) 1.1Version 1.0 introduced in Windows VistaEnumerates adapters, display modes, and outputs (e.g. monitors)New DXGI_FORMATs and improved support for remote desktopsWindows Display Driver Model (WDDM) 1.1WDDM 1.0 introduced in Windows VistaUnified driver model for all Direct3D APIsWindows Advanced Rasterization Platform (WARP) 10Software rasterization device supporting 10.1 device functionalityNo driver optional feature supportMuch faster than the DirectX SDKs Reference deviceRelated TechnologiesGraphics APIs in Windowshttp://msdn.microsoft.com/en-us/library/ee417756.aspx

Windows Advanced Rasterization Platform (WARP) In-Depth Guidehttp://msdn.microsoft.com/en-us/library/dd285359.aspx4/29/2010 1:45 PM12Updated DxCapsViewer Utility

Demo4/29/2010 1:45 PM13

Reference = This is the compliance software device installed by the DirectX SDK.4/29/2010 1:45 PM14ID3D10DeviceID3D10DeviceChildID3D10VertexShaderID3D10GeometryShaderID3D10PixelShaderID3D10InputLayoutID3D10DepthStencilStateID3D10BlendStateID3D10RasterizerStateID3D10SamplerStateID3D10AsynchronousID3D10QueryID3D10PredicateID3D10CounterID3D10ResourceID3D10BufferID3D10Texture1DID3D10Texture2DID3D10Texture3DID3D10ViewID3D10ShaderResourceViewID3D10RenderTargetViewID3D10DepthStencilViewDirect3D 10.0 APIID3D10Predicate technically derives from ID3D10QueryID3D10Asynchronous, ID3D10Resource, and ID3D10View all derive from ID3D10DeviceChild4/29/2010 1:45 PM15ID3D10Device1ID3D10DeviceChildID3D10VertexShaderID3D10GeometryShaderID3D10PixelShaderID3D10InputLayoutID3D10DepthStencilStateID3D10BlendState1ID3D10RasterizerStateID3D10SamplerStateID3D10AsynchronousID3D10QueryID3D10PredicateID3D10CounterID3D10ResourceID3D10BufferID3D10Texture1DID3D10Texture2DID3D10Texture3DID3D10ViewID3D10ShaderResourceView1ID3D10RenderTargetViewID3D10DepthStencilViewDirect3D 10.1 APIDirect3D 10.1 still supports ID3D10BlendState and ID3D10ShaderResourceView as well4/29/2010 1:45 PM16ID3D11DeviceID3D11DeviceChildID3D11VertexShaderID3D11GeometryShaderID3D11PixelShaderID3D11InputLayoutID3D11DepthStencilStateID3D11BlendStateID3D11RasterizerStateID3D11SamplerStateID3D11AsynchronousID3D11QueryID3D11PredicateID3D11CounterID3D11ResourceID3D11BufferID3D11Texture1DID3D11Texture2DID3D11Texture3DID3D11ViewID3D11ShaderResourceViewID3D11RenderTargetViewID3D11DepthStencilViewDirect3D 11 API (partial)4/29/2010 1:45 PM17ID3D11DeviceID3D11DeviceChildID3D11AsynchronousID3D11ResourceID3D11ViewID3D11QueryID3D11PredicateID3D11CounterID3D11VertexShaderID3D11GeometryShaderID3D11PixelShaderID3D11ComputeShaderID3D11HullShaderID3D11InputLayoutID3D11DepthStencilStateID3D11BlendStateID3D11RasterizerStateID3D11SamplerStateID3D11ClassInstanceID3D11ClassLinkageID3D11CommandListID3D11BufferID3D11Texture1DID3D11Texture2DID3D11Texture3DID3D11ShaderResourceViewID3D11RenderTargetViewID3D11DepthStencilViewID3D11UnorderedAccessViewID3D11DomainShaderID3D11DeviceContextID3D11Query derives from ID3D11AsynchronousID3D11DeviceContext, ID3D11Asynchronous, ID3D11Resource, and ID3D11View derive from ID3D11DeviceChild4/29/2010 1:45 PM18Direct3D 11 API ChangeMain difference is ID3D10Device was split in twoObject creation in ID3D11Device interfaceOther methods split off into ID3D11DeviceContext interfaceRendering and state configurationMap()/Unmap() from resource objectsBegin(), End(), and GetData() from query objectsOne immediate context for rendering directly to the deviceZero or more deferred contexts for creating command listsProvides basis of multithreading improvements4/29/2010 1:45 PM19ID3D11Device is thread-safeWithout driver support for Concurrent Creates, runtime will enforce thread-safety with a coarse lockWithout driver support for Concurrent Creates, creating objects and rendering with the immediate context will not be concurrent (using the same coarse lock)Methods on most other objects (ID3D11DeviceChild-derived) are also thread-safeCan opt-out by using D3D11_CREATE_DEVICE_SINGLETHREADEDMulti-threading Rules4/29/2010 1:45 PM20ID3D11DeviceContext is not thread-safeTypical usage is one device context per thread, one of them using immediate and the rest using deferred contextsNote that DXGI methods should not be used concurrently while rendering with the immediate device contextFor example, Present() uses the immediate device contextIt is thread-safe to use the methods inherited from ID3D11DeviceChildAddRef(), Release(), QueryInterface()GetDevice(), GetPrivateData(), SetPrivateData(), SetPrivateDataInterface()Multi-threading Rules4/29/2010 1:45 PM21ID3D11DeviceContext deferred mode limitationsMap() must be used with D3D11_MAP_WRITE_DISCARD and/or D3D11_MAP_WRITE_NO_OVERWRITEGetData() for queries is not allowedQueries can be used in conjunction with predicationIf executing a deferred command list with a query activeand the command list itself uses the same query,then the command list submission is ignored as invalidMulti-threading Rules4/29/2010 1:45 PM22Concurrent creation is a no brainerMany engines already have resource loading threadsRuntime emulation is good enough for a winLess overhead than the default Direct3D 10 M/T behaviorConcurrentCreates driver support makes it betterWhen creating objects with M/T driver support, providing initial data for static objects should be more efficienti.e Use the pInitialData parameter on the Create rather than staging resources, UpdateSubResource(), or Map() when possibleMulti-threading Recommendations4/29/2010 1:45 PM23Concurrent submission depends on the scenarioUseful for Triple-core, Quad-core, or moreFor Dual-core, it is less likely to be worthwhileBest use scenario is one rendering thread per coreIdeally use the Windows Vista/Windows 7 thread pool APIIf you roll your own solution, see the DirectX SDK CoreDetection sample for the robust way to determine number of coresSimilar but not identical to Xbox 360 Command BuffersDriver CommandLists support is currently rareMulti-threading RecommendationsKnown Issue in DX11 RTM: Deferred Context UpdateSubResource with the runtime non-driver implementation will fail to handle a non 0,0,0 offset correctly.

Thread Pool API: http://msdn.microsoft.com/en-us/library/ms686766.aspx

CoreDetection shows best practices for computing thread affinity masks including taking the process mask and hyperthreading into account. In general use the GetLogicalProcessorInformation() API when its available (Windows XP Service Pack 3, Windows Vista, Windows 7, Windows Server 2008, Windows Server 2008 R2). It is available on Windows Server 2003 SP1+ (which includes Windows XP Professional x64 Edition) but it should be avoided as it has some known bugs with respect to hyper-threading (http://support.microsoft.com/kb/932370). Otherwise you have to use CPUID with vendor-specific extensions.4/29/2010 1:45 PM24Porting to Direct3D 11 from 10.xStart with a simple text translationID3D10* -> ID3D11*D3D10_* -> D3D11_*If starting with Direct3D 10.0, will need to fix up a few minor structure differences(11 matches the 10.1 version)D3D10_BLEND_DESC1D3D10_SHADER_RESOURCE_VIEW_DESC1See Migrating to Direct3D 11 http://msdn.microsoft.com/en-us/library/ee416254.aspx4/29/2010 1:45 PM25Porting to Direct3D 11 from 10.xChange rendering & state calls from device to immediate contextAfter getting port done, will want to revisit thisChange resource Map() and query Begin(), End(), & GetData() to use immediate contextCreate*Shader takes an additional class linkage parameter (can use NULL)*SetShader and *GetShader take an additional class instance parameter (can use NULL)See Migrating to Direct3D 11 http://msdn.microsoft.com/en-us/library/ee416254.aspx4/29/2010 1:45 PM26Some defines changed, so be sure you arent using magic numbers (D3D10_RESOURCE_MISC_FLAG)A minor feature was completely droppedID3D10Device::GetTextFilterSizeID3D10Device::SetTextFilterSizeD3D10_FILTER_TEXT_1BITVendor-neutral performance counters removedWere rarely implemented or consistenti.e. D3D11_COUNTER_DEVICE_DEPENDENT_0 is the only counter enumerationPorting to Direct3D 11 from 10.xSee Migrating to Direct3D 11 http://msdn.microsoft.com/en-us/library/ee416254.aspx4/29/2010 1:45 PM27Porting to Direct3D 11 from 9Essentially the same as porting from Direct3D 9 to Direct3D 10.xRemove all fixed-function pipeline usageUse state management based on immutable state objectsObey strict shader linkage and input layout rulesUse shader resource views associated with texture resourcesMap data to DXGI_FORMATs (no 16-bit formats, no 24-bit color format, strict RGB color order)Rework global constant data into several constant buffers for efficient updateSee Migrating to Direct3D 11 http://msdn.microsoft.com/en-us/library/ee416254.aspx4/29/2010 1:45 PM28Porting to Direct3D 11 from 9Start with the existing guidance for moving from Direct3D 9 to Direct3D 10SIGGRAPH 2007 Course #5Introduction to Direct3D 10http://msdn.microsoft.com/directx/presentationsGamefest 2007 talkWindows to Reality: Getting the Most out of Direct3D 10 Graphics in Your Gameshttp://www.microsoftgamefest.com/presentations/2007.htm See Direct3D 9 to Direct3D 10 Considerations http://msdn.microsoft.com/en-us/library/ee415668.aspx

4/29/2010 1:45 PM29HLSL CompilerDirectX 11 requires 4.0 or later profile shadersD3DCompile DLL contains latest HLSL compilerUsed by D3DX9, D3DX10, D3DX11, and FXC.EXECan use directly (i.e. without using D3DX)Note it is in its own DirectSetup CAB file in the REDIST folderSupports all shader models except Pixel Shader 1.x profilesVertexPixelGeometryComputeHullDomainvs_4_0ps_4_0gs_4_0cs_4_0vs_4_1ps_4_1gs_4_1cs_4_1vs_5_0ps_5_0gs_5_0cs_5_0hs_5_0ds_5_0vs_4_0_level_9_1ps_4_0_level_9_1vs_4_0_level_9_3ps_4_0_level_9_3There is a version of the HLSL compiler built into the OS through D3D10Compile*, but it well out of date and only supports 4.0 shader models.

Note there is no vs/ps_4_0_level_9_2. Use vs/ps_4_0_level_9_1 for both 9.1 and 9.2 feature levels

Not listing the D3D9 profiles here, but they are also all supported by the current HLSL compiler except ps_1_1, ps_1_2, ps_1_3, and ps_1_4.4/29/2010 1:45 PM30Shader profiles in DirectX 11 can be applied to higher feature levels, but not lower10level9 shader profiles are compiled twice internallyvs_4_0_level_9_* => vs_2_0 + vs_4_0ps_4_0_level_9_1 => ps_2_0 + ps_4_0ps_4_0_level_9_3 => ps_2_b + ps_4_0Shader Profiles and Feature LevelsShader Profile vs. Device Feature Level11_010_110_09_39_29_15_0Yes-----4_1YesYes----4_0YesYesYes---4_0_level_9_3YesYesYesYes--4_0_level_9_1YesYesYesYesYesYesNote this is also true of Direct3D 10.14/29/2010 1:45 PM31Use the latest compilerEsp. avoid the in box D3D10Compile APIsGenerally use the lowest profile possible for VS/PS when supporting 10level9For DirectComputeprefer CS 5.0 over CS 4.xPrefer CS 4.1 over CS 4.0Compile your shaders offline for your retail gameHLSL Recommendations4/29/2010 1:45 PM32Effects (FX) LibraryEffects for Direct3D 11 (FX11) is shared source in DX SDKFX9 was in D3DX9FX10 was in box with the OSPorting from FX10 -> FX11 is fairly trivialEssentially the same API without effects poolsPorting from FX9 -> FX11 requires significant code changeHLSL ProfileEffects 9fx_2_0Effects 10fx_4_0 and fx_4_1 Effects 11fx_5_04/29/2010 1:45 PM33D3DX11Includes texture loaders (BMP, JPG, PNG, DDS, TIFF, GIF)and asynchronous loaders introduced with D3DX10Does not include D3DX Math, Mesh, Sprite, or FontSee XNAMath as alternative for D3DX Mathand DXUT11 for alternative to font, etc.D3DX11 uses a CPU codec for BC6H/BC7 texture compression, which can be time-consuming.

For a fast DirectCompute 4.x solution, see the BC6HBC7EncoderDecoder11 sample.4/29/2010 1:45 PM34D3DCSXOptional extended D3DX DLL for Compute ShaderResides in its own DirectSetup / REDIST CABDirectCompute (CS 5.0) utility functionsID3DX11ScanUnsegmented Scan or MultiscanSegmented ScanID3DX11FFT1D, 2D, 3D supportReal or ComplexForward or Inverse Transform with optional scaleExpecting CS 4.x support for FFT in Feb20104/29/2010 1:45 PM35XNAMathaka xboxmath 2.0Inline C++ SSE/SSE2 optimized math libraryVMX128 optimized on Xbox~350 functionsFocused on single-precision floating-point operationsLimited integer operationsConversion to/from packed graphics formatsImplemented using Visual Studio intrinsicsSupports x86 and x64 nativeCommon 3D primitivesVectors, matrices, planes, quaternions, etc.4/29/2010 1:45 PM36DirectX 11 DeploymentDirectX 11 Runtime is included with Windows 7 and Windows Server 2008 R2DirectX 11 Runtime can be deployed down-level to Windows Vista / Server 2008D3DX11, D3DCSX, D3DCompile, etc. installed by DirectSetup / DX SDK REDISTJust like D3DX9, D3DX10, XAUDIO2, etc.The DirectX SDK does not install the DirectX 11 RuntimeThe DX SDK does install the debug layers and reference device4/29/2010 1:45 PM37New API supporting 10, 10.1, 11, 10level9, and WARP10Direct3D 11DirectX 11 RuntimeD3D glue library updated for new formats and WDDM 1.1 driver featuresDXGI 1.110.1 level software rendererWARP10Direct3D 9 Shader Model 2.0 h/w support (9_1, 9_2, 9_3 feature levels)10level9Updated existing API to support WARP10, 10level9Direct3D 10.1GDI-like 2D drawing API for working on Direct3D surfacesDirect2DHigh-quality, feature-rich font rendering API (works with Direct2D)DirectWrite4/29/2010 1:45 PM38KB 971644Platform Update for Windows Vistahttp://go.microsoft.com/fwlink/?LinkId=160189Deployed through Windows UpdateRequires Windows Vista / Server 2008 SP2 to be installed

See the D3D11InstallHelper sample in the DirectX SDK for detection, applying the KB, and messaging for RTM / SP1

Detailed in Direct3D 11 Deployment for Game Developers technical articleWill likely be included in a future Service Pack 3 for Windows Vista / Server 2008http://msdn.microsoft.com/en-us/library/ee416644.aspx4/29/2010 1:45 PM39For corporate network environments using Windows Server Update Servers (WSUS), KB 971644 is not availableUse this update insteadWindows Graphics, Imaging, and XPS Libraryhttp://support.microsoft.com/kb/971512/Local IT admin will need to approve the update through the managed WSUS serversRequires Windows Vista / Server 2008 SP2 to be installedKB 9715124/29/2010 1:45 PM40Update your existing Direct3D 10.x code path to use Direct3D 11This requires some installer/deployment workYour DX11 code path will require Windows Vista SP2+ or Windows 7For Windows Vista / Windows 7 titles10level9 feature levels can provide more hardware support, so you dont need a Direct3D9 code pathFor titles that need Windows XP support,you will need a legacy Direct3D9 code pathRecommendationsGamefest talk link on KB940105: