Sie sind auf Seite 1von 9

|  à  à

DirectX 11 Technology Update

Chuck Walbourn
Senior Software Design Engineer

Gamefest 2008 DirectX 11 Overview

Graphics Track Introduction to the Direct3D 11 Graphics Pipeline Direct3D 11 is based on Direct3D 10.1
Direct3D 11 Tessellation Similar API design & rendering pipeline
High Level Shader Language (HLSL) Update³Introducing Enables new DirectX 11 hardware Hull Shader

Version 5.0 features Tessellator

Multithreaded Rendering for Games Supports existing DirectX 10 and 10.1 ½ 

Direct3D 11 Compute Shader³More Generality for hardware Domain Shader


Advanced Techniques Enables some new features as well                 

Partners Track Advanced Topics in GPU Tessellation (AMD) Supports a subset of DirectX 9 SM 2.0+ Π

Water-Tight, Textured, Displaced Subdivision Surface hardware  

Tessellation Using Direct3D 11 (NVIDIA) Supported on Windows 7, Windows
Vista, Windows Server 2008, and
Windows Server 2008 R2

Features & Feature Levels

Feature levels are well-defined sets of
ot a sea of ´opt-inµ caps its

Rendering &
DirectCompute HLSL Shader
Model 5
ach feature level is a superset of the previous one

‡CS 5.0 on
Resource DirectX 11 HW ‡5.0 on Linkage ‡DirectX 11 HW Formats
Creation ‡CS 4.x on some DirectX 11 HW ‡Class Linkage on only ‡DirectX 11 HW Concept was introduced with Direct D 10.1

DX10.x h/w ‡Some new DirectX 11 HW only

emulation or
Driver optimized emulated on
construct works

older profiles on older profiles


              ! "  # $    #    
|  à  à

DirectX 11 Feature Levels

 Direct3D 10 hardware: Shader Model 4.0, geometry shader, stream out,
(e.g. NVIDIA GeForce 8000/9000 alpha-to-coverage, MSAA textures, 2-sided stencil, general render
Series; GTX 260/280) target views, texture arrays, BC4/BC5, optional DirectCompute (CS
4.0), all 9_3 features.


Direct3D 10.1 hardware: Shader Model 4.1, cubemap arrays, extended
(e.g. ATI Radeon HD MSAA, optional DirectCompute (CS 4.1), all 10_0 features.
2000/3000/4000 Series; NVIDIA
GeForce G210/GT220)

 Direct3D 11 hardware: Shader Model 5.0, hull & domain shaders,

(e.g. ATI Radeon HD 5000 Series) mandatory DirectCompute (CS 5.0), BC6H/BC7, all 10_1 features.

10level9 Feature Levels Driver Optional Features

  Devices can expose some new DXGI_FORMATs
Direct3D 9 hardware: must support Shader Model 2.0 (vs_2_0/ps_2_0), ID3D11Device::CheckFormatSupport
(e.g. Intel G965 Express Chipset, 2K textures, volume textures, event queries, BC1-3 (aka DXTn), and a
NVidia GeForce FX 5200) few other specific capabilities. BGRA (B8G8R8*8) formats
required for 9_1, 9_2, 9_3 and 11_0
optional for 10_0 / 10_1
    Direct3D 9 hardware: must support Shader Model 2.0 (vs_2_0/ps_2_0), 10:10:10:2 X2 biased High Color mode
(e.g. ATI Radeon 9500) occlusion queries, float formats (no blending), extended caps, all 9_1 (R10G10B10_XR_BIAS_X2_A2_UNORM)
required for 11_0
optional for 10_0 / 10_1
    Direct3D 9 hardware: must support Shader Model 2.0 (vs_2_0/ps_2_b) not available for 9_1, 9_2, or 9_3
(e.g. NVidia GeForce 6600, ATI with instancing, 4K textures, multiple render targets (4 MRTs), floating-
Radeon X1300) point blending, all 9_2 features. Majority of format support is defined by feature level
Detailed in the DXGI Programmer·s Guide in the Windows Graphics documentation

Driver Optional Features Related Technologies

DirectX 11 drivers can support four optional features
DirectX Graphics Infrastructure (DXGI) 1.1
‡ Version 1.0 introduced in Windows Vista
DirectCompute ‡ Enumerates adapters, display modes, and outputs (e.g. monitors)
‡ New DXGI_FORMATs and improved support for remote desktops
D3D_FATUR__10_0 / 10_1 support for CS . is optional

CS .0 is required for D3D_FATUR__11_0

Windows Display Driver Model (WDDM) 1.1

Double-precision shader support is optional ‡ WDDM 1.0 introduced in Windows Vista
‡ Unified driver model for all Direct3D APIs
Multithreading Driver support is optional
Concurrent object creation
Windows Advanced Rasterization Platform (WARP) 10
Command lists
‡ Software rasterization device supporting 10.1 device functionality
‡ No ¶driver optional feature· support
‡ Much faster than the DirectX SDK·s Reference device


              ! "  # $    #    
|  à  à

Updated DxCapsViewer Utility

Direct3D 10.0 API Direct3D 10.1 API

ID3D10Device ID3D10DeviceChild ID3D10Asynchronous ID3D10Resource ID3D10View ID3D10Device1 ID3D10DeviceChild ID3D10Asynchronous ID3D10Resource ID3D10View

ID3D10Ver texShader ID3D10Ver texShader

ID3D10Buffer ID3D10Buffer
ID3D10Quer y ID3D10Shader Resour ceView ID3D10Quer y ID3D10Shader Resour ceView1
ID3D10Geometr yShader ID3D10Geometr yShader

ID3D10Pix elShader ID3D10Pix elShader

ID3D10Tex tur e1D ID3D10Tex tur e1D
ID3D10InputLayout ID3D10InputLayout
ID3D10Pr edicate ID3D10Render Tar getView ID3D10Pr edicate ID3D10Render Tar getView
ID3D10DepthStencilState ID3D10DepthStencilState
ID3D10Tex tur e2D ID3D10Tex tur e2D
ID3D10BlendState ID3D10BlendState1

ID3D10Raster izerState ID3D10Raster izerState

ID3D10Counter ID3D10DepthStencilView ID3D10Counter ID3D10DepthStencilView
ID3D10Tex tur e3D ID3D10Tex tur e3D
ID3D10Sampler State ID3D10Sampler State

Direct3D 11 API (partial) ID3D11DeviceChild ID3D11Asynchronous ID3D11Resource ID3D11View

ID3D11Device ID3D11V er texShader

ID3D11Device ID3D11DeviceChild ID3D11Asynchronous ID3D11Resource ID3D11View
ID3D11Geometr yShader ID3D11Buffer ID3D11Shader Resour ceV iew
ID3D11Quer y

ID3D11Ver texShader
ID3D11Buffer ID3D11DomainShader
ID3D11Quer y ID3D11Shader Resour ceView
ID3D11Geometr yShader ID3D11Textur e1D ID3D11Render Tar getV iew
ID3D11HullS hader

ID3D11Pix elShader ID3D11InputLayout

ID3D11Tex tur e1D ID3D11Pr edicate
ID3D11DepthStenci lStat e
ID3D11Pr edicate ID3D11Render Tar getView ID3D11BlendState
ID3D11Textur e2D ID3D11DepthStenci lV iew
ID3D11Raster izer State
ID3D11Tex tur e2D
ID3D11BlendState ID3D11Sampler State

ID3D11ClassInstanc e
ID3D11Raster izerState ID3D11Counter
ID3D11Counter ID3D11DepthStencilView ID3D11Textur e3D ID3D11Unor der edAccessV iew
ID3D11Tex tur e3D
ID3D11Sampler State ID3D11CommandList


              ! "  # $    #    
|  à  à

Direct3D 11 API Change Multi--threading Rules

Main difference is ID3D10Device was split in two ID3D11Device is thread-safe
Object creation in ID3D11Device interface Without driver support for Concurrent Creates, runtime will
Other methods split off into ID3D11DeviceContext enforce thread-safety with a coarse lock
interface Without driver support for Concurrent Creates, creating
Rendering and state configuration objects and rendering with the immediate context will not be
Map()÷Unmap() from resource objects concurrent (using the same coarse lock)
Begin(), End(), and GetData() from query objects Methods on most other objects (ID3D11DeviceChild-
One immediate context for rendering directly to the device derived) are also thread-safe
Zero or more deferred contexts for creating command lists Can opt-out by using D3D11_CREATE_DEVICE_SINGLETHREADED
Provides basis of multithreading improvements

Multi--threading Rules
Multi Multi--threading Rules
ID3D11DeviceContext is not thread-safe ID3D11DeviceContext deferred mode limitations
Typical usage is one device context per thread, one of them Map() must be used with D3D11_MAP_WRITE_DISCARD
using immediate and the rest using deferred contexts and/or D3D11_MAP_WRITE_NO_OVERWRITE
Note that DXGI methods should not be used concurrently while GetData() for queries is not allowed
rendering with the immediate device context Queries can be used in conjunction with predication
For example, Present() uses the immediate device context
If executing a deferred command list with a query active
It is thread-safe to use the methods inherited from
ID3D11DeviceChild and the command list itself uses the same query,
AddRef(), Release(), QueryInterface() then the command list submission is ignored as invalid
GetDevice(), GetPrivateData(), SetPrivateData(),

Multi--threading Recommendations
Multi M lti-
lti-t r i gR ti s




Concurrent creation is a no brainer Concurrent submission depends on the scenario

Many engines already have resource loading threads seful for Triple-core, Quad-core, or more

Runtime emulation is ´good enoughµ for a win For Dual-core, it is less likely to be worthwhile
ess overhead than the default Direct D M/T behavior est use scenario is one rendering thread per core

ConcurrentCreates driver support makes it better Ideally use the Windows ista/Windows thread pool PI

When creating objects with M/T driver support, providing If you roll your own solution, see the DirectX SD —    

s l f rt r st t t r i r f r s
initial data for static objects should be more efficient

i.e se the pInitialData parameter on the Create rather than Si il r t ti ti l t ff rs








staging resources, pdateSubResource(), or Map() when possible riv r ists s rt is rr tl r r







              ! "  # $    #    
|  à  à

Porting to Direct3D 11 from 10.x Porting to Direct3D 11 from 10.x

Start with a simple text translation Change rendering & state calls from device to immediate
ID3D10* -> ID3D11* context
D3D10_* -> D3D11_* After getting port done, will want to revisit this

If starting with Direct3D 10.0, will need to fix up a few Change resource Map() and query Begin(), End(), &
minor structure differences GetData() to use immediate context
(11 matches the 10.1 version) Create*Shader takes an additional class linkage
D3D10_BLEND_DESC1 parameter (can use NULL)
D3D10_SHADER_RESOURCE_VIEW_DESC1 *SetShader and *GetShader take an additional class
instance parameter (can use NULL)

Porting to Direct3D 11 from 10.x Porting to Direct3D 11 from 9

Some defines changed, so be sure you aren·t using magic Essentially the same as porting from Direct3D 9 to
numbers (D3D10_RESOURCE_MISC_FLAG) Direct3D 10.x
A minor feature was completely dropped Remove all fixed-function pipeline usage
ID3D10Device::GetTextFilterSize Use state management based on immutable state objects
ID3D10Device::SetTextFilterSize Obey strict shader linkage and input layout rules
D3D10_FILTER_TEXT_1BIT Use shader resource views associated with texture resources
Vendor-neutral performance counters removed Map data to DXGI_FORMATs (no 16-bit formats, no 24-bit color
format, strict RGB color order)
Were rarely implemented or consistent
Rework global constant data into several constant buffers for
i.e. D3D11_COUNTER_DEVICE_DEPENDENT_0 is the only efficient update
counter enumeration

Porting to Direct3D 11 from 9 HLSL C il r



Start with the existing guidance for moving from ir t r ir s . r l t r r fil shaders


Direct3D 9 to Direct3D 10 C ile LL tai s latest HLSL iler



SIGGRAP 200 Course # sed , , , and 




½    —an se directl (i.e. ithout using )



htt : s . i r s ft. ir t r s t ti s ote it is in its own irectSetup —  file in the IS folder



 t l Supports all shader odels except ixel Shader .x profiles



vs_4_0 ps_4_0 gs_4_0 cs_4_0

htt : . i r s ft f st. r s t ti s .ht

vs_4_1 ps_4_1 gs_4_1 cs_4_1


vs_5_0 ps_5_0 gs_5_0 cs_5_0 hs_5_0 ds_5_0

vs_4_0_level_ _1 ps_4_0_level_ _1

vs_4_0_level_ _3 ps_4_0_level_ _3


              ! "  # $    #    
|  à  à

Shader Profiles and Feature Levels HLSL Recommendations

Shader profiles in DirectX 11 can be applied to higher Use the latest compiler
feature levels, but not lower Esp. avoid the ¶in box· D3D1Compile APIs
10level9 shader profiles are compiled twice internally
Generally use the lowest profile possible for VS/PS when
vs_4_0_level_9_* => vs_2_0 + vs_4_0 supporting 1level9
ps_4_0_level_9_1 => ps_2_0 + ps_4_0
ps_4_0_level_9_3 => ps_2_ + ps_4_0 For DirectCompute

prefer CS „. over CS 4.x

        ·          

„  es - - - - - Prefer CS 4.1 over CS 4.

4 1 es es - - - -

4  es es es - - -

4  level 9 3 es es es es - -
4  level 9 1 es es es es es es

Effects (FX) Library D3DX11

Effects for Direct3D 11 (FX11) is shared source in DX SDK Includes texture loaders (BMP, JPG, PNG, DDS, TIFF, GIF)
FX9 was in D3DX9 and asynchronous loaders introduced with D3DX10
FX10 was in box with the OS Does not include D3DX Math, Mesh, Sprite, or Font
Porting from FX10 -> FX11 is fairly trivial See XNAMath as alternative for D3DX Math
Essentially the same API without effects pools and DXUT11 for alternative to font, etc.
Porting from FX9 -> FX11 requires significant code change
  D3DX11 uses a CPU codec for BC6H/BC7 texture compression,
Effects 9 fx_2_0 which can be time-consuming.
Effects 10 fx_4_0 and fx_4_1
Effects 11 fx_5_0 For a fast DirectCompute 4.x solution, see the
BC6HBC7EncoderDecoder11 sample.

ptional extended D3DX D for Compute Shader a a xboxmath 2.

esides in its own DirectSetup DIS C  Inline C SS SS 2 optimized math librar



X128 optimized on Xbox

DirectCompute (CS „.) utilit functions

~3„ functions

½DD11 c n

Focused on single-precision floating-point operations

nsegmented Scan or ultiscan

imited integer operations

Segmented Scan

Conversion to/from packed graphics formats

Implemented using isual Studio intrinsics

1D, D, 3D support
Supports x86 and x64 native

eal or Complex
Common 3D primitives

Forward or Inverse ransform with optional scale


ectors, matrices, planes, uaternions, etc.



              ! "  # $    #   
|  à  à

DirectX 11 Deployment DirectX 11 Runtime

DirectX 11 Runtime is included with Windows 7 and
Windows Server 2008 R2 Direct3D 11 ‡ New API supporting 10, 10.1, 11, 10level9, and WARP10

DirectX 11 Runtime can be deployed down-level to DXGI 1.1 ‡ D3D glue library updated for new formats and WDD 1.1 driver features

Windows Vista / Server 2008

WARP10 ‡ 10.1 level software renderer

D3DX11, D3DCSX, D3DCompile, etc. installed by

DirectSetup / DX SDK REDIST 10level9 ‡ Direct3D 9 Shader odel 2.0 h/w support (9_1, 9_2, 9_3 feature levels)

Just like D3DX9, D3DX10, XAUDIO2, etc.

Direct3D 10.1 ‡ Updated existing API to support WARP10, 10level9

The DirectX SDK does O  install the DirectX 11 Runtime

The DX SDK does install the debug layers and reference device Direct2D ‡ GDI-like 2D drawing API for working on Direct3D surfaces

DirectWrite ‡ igh- uality, feature-rich font rendering API (works with Direct2D)

KB 971644 KB 971512
     O  For corporate network environments using Windows
™ Server Update Servers (WSUS), KB 971644 is not available

Deployed through Windows Update Use this update instead
Re uires Windows Vista / Server 2008 SP2 to be installed O   
 ½ O  O 

See the D3D11InstallHelper sample in the DirectX SDK Local IT admin will need to approve the update through
for detection, applying the KB, and messaging for RTM / SP1 the managed WSUS servers
Detailed in    O    Requires Windows Vista / Server 2008 SP2 to be installed

technical article

Recommendations Recommendations
Update our existing irect 10.x code path to use If ou still onl have a legac irect 9 code path


irect 11 ow·s the time to invest in irect 11


This requires some installer/deplo ment work Take advantage of the existing resources

our 11 code path will require Windows Vista SP2 or Lessons learned moving from 9- 10 all appl to moving


Windows 7

from 9- 11

For Windows Vista / Windows 7 titles irect 11 provides


10level9 feature levels can provide more hardware the latest hardware features
support, so ou don·t need a irect 9 code path new features for existing 10.x hardware


For titles that need Windows P support, and supports the majorit of video cards with W  drivers


ou will need a legac irect 9 code path




              ! "  # $    #   

|  à  à

Latest DirectX SDK
Gamefest 2008 Graphics and Partners Tracks
Gamefest 2010 Graphics Track
Think DirectX11 Tessellation! ² what are your options?

DirectX 11 DirectCompute ² A Teraflop for Everyone

Block Compression Smorgasbord

and additional talks from AMD & NVIDIA

Ëinclude ³d3d10.h´ Ëinclude ³d3d10_1.h´

IDXGISwapChain *g_pSwapChain = NULL; IDXGISwapChain *g_pSwapChain = NULL;
ID3D10Device *g_pDevice = NULL; ID3D10Device1 *g_pDevice = NULL;
« «
// Set to desired values // Set to desired values
« «
HRESULT res = D3D10CreateDeviceAndSwapChain( NULL, D3D10_DRIVER_TYPE_HARDWARE, HRESULT res = D3D10CreateDeviceAndSwapChain1( NULL, D3D10_DRIVER_TYPE_HARDWARE,
NULL, 0, D3D10_SDK_VERSION, &sd, NULL, 0, D3D10_FEATURE_LEVEL_10_1, D3D10_1_SDK_VERSION, &sd,
&g_pSwapChain, &g_pDevice ); &g_pSwapChain, &g_pDevice );

if ( FAILED(res) ) // Error Handling if ( FAILED(res) )

// Bind render target from swap chain {
// Set up viewport res = D3D10CreateDeviceAndSwapChain1( NULL, D3D10_DRIVER_TYPE_HARDWARE,
« NULL, 0, D3D10_FEATURE_LEVEL_10_0, D3D10_1_SDK_VERSION, &sd,
&g_pSwapChain, &g_pDevice );

if ( FAILED(res) ) // Error Handling

// Bind render target from swap chain
// Set up viewport
// use g_pDevice->GetFeatureLevel() to check for 10_1; can otherwise assume 10_0

Ëinclude ³d3d11.h´ Ëinclude ³d3d11.h´

IDXGISwapChain *g_pSwapChain = NULL; IDXGISwapChain *g_pSwapChain = NULL;
ID3D11Device *g_pDevice = NULL; ID3D11Device *g_pDevice = NULL;
ID3D11DeviceContext* g_pContext = NULL; ID3D11DeviceContext* g_pContext = NULL;
« «
// Set to desired values // Set to desired values
« «

D3D_FEATURE_LEVEL flvl[] = { D3D_FEATURE_LEVEL flvl[] = {

NULL, 0, flvl, sizeof(flvl)/sizeof(D3D_FEATURE_LEVEL), HRESULT res = D3D11CreateDeviceAndSwapChain( NULL, D3D_DRIVER_TYPE_HARDWARE,
D3D11_SDK_VERSION, &sd, NULL, 0, flvl, sizeof(flvl)/sizeof(D3D_FEATURE_LEVEL),
&g_pSwapChain, &g_pDevice, &fl, &g_pContext ); D3D11_SDK_VERSION, &sd,
&g_pSwapChain, &g_pDevice, &fl, &g_pContext );
if ( FAILED(res) ) // Error Handling
// Bind render target from swap chain if ( FAILED(res) ) // Error Handling
// Set up viewport // Bind render target from swap chain
« // Set up viewport
// use g_pDevice->GetFeatureLevel() (or remem er fl a ove) to check for «

// 11_0 or 10_1, assume 10_0 otherwise // use g_pDevice->GetFeatureLevel() (or remem er fl a ove) to check feature level


              ! "  # $    #   
|  à  à

Ëinclude ³d3d11.h´
IDXGISwapChain *g_pSwapChain = NULL;
ID3D11Device *g_pDevice = NULL;
ID3D11DeviceContext* g_pContext = NULL;
DirectX 11 Debugging
DXGI_SWAP_CHAIN_DESC sd; DirectX SDK provides debugging layer
// Set to desired values
« Enabled through code
NULL, 0, NULL, 0,
the DirectX Control Panel utility
&g_pSwapChain, &g_pDevice, NULL, &g_pContext );
Control panel controls the 10 and 11
if ( FAILED(res) ) // Error Handling debugging layer through the same
// Bind render target from swap chain settings
// Set up viewport
« Unlike Direct3D 9, it is per application
// use g_pDevice->GetFeatureLevel() to check feature level
not a global setting
Prints messages to Windows debug

DirectX 11 Debugging Debug Resource Naming

Make sure your application runs ¶debug layer· clean Debug layer messages in debug window use ¶friendly
ERROR and CORRUPTION reports are critical to fix names· for resources, defaults to unnamed

Tools like ½  O assume this level of correctness Can set the name by using the SetPrivateData() API
Can also make use of the ID3D11De ug and in combination with a ¶well-known· GUID from

D3D11InfoQueue interfaces d3dcommon.h

Obtain via QueryInterface from Direct3D 11 Device
Exists only if debug layer is attached Ëifndef NDEBUG
// Only works if device is created with the D3D10 or D3D11 de ug layer
ID3D10De ug::Validate() split into

const char c_szName[] = "texture.jpg";

ValidateContext() and pO ject->SetPrivateData( WKPDID_D3DDe ugO jectName,


sizeof( c_szName ) - 1, c_szName );

New method for DX11 Debug Layer
ID3D11De ug::ReportLiveDeviceO jects()

Windows 7 / Server 2008 R2 only

A few DirectX-branded technology pieces are not
available down-level
Direct3D Ex video D and overlay extensions

Direct3D Ex D3DSWPEFFEC_FLIPE and improved frame


Directusic ¶core· API for x64 native (time stamped IDI,
software synthesizer)

Windows edia Foundation improvements are not also

© 200 -2010 icr osoft Cor por ation. All r ights r eserved.

This presentation is for informational purposes only. icrosoft makes no warranties, express or implied, in this summary.


              ! "  # $    #