modern graphics using windows 7 and direct3d 11 hardware
DESCRIPTION
CL15. Modern Graphics Using Windows 7 and Direct3D 11 Hardware. Michael Oneppo. Agenda. Windows 7 Direct3D Review Direct3D 10 Review Expanding Reach: D3D10Level9 and WARP HLSL & Shaders Direct3D 11 Multi-Threading Tessellation. DirectCompute. Direct3D 11 also offers DirectCompute - PowerPoint PPT PresentationTRANSCRIPT
Modern Graphics Using Windows 7 and Direct3D 11 HardwareMichael Oneppo
CL15
Agenda> Windows 7 Direct3D Review
> Direct3D 10 Review> Expanding Reach: D3D10Level9 and
WARP> HLSL & Shaders
> Direct3D 11> Multi-Threading> Tessellation
DirectCompute> Direct3D 11 also offers DirectCompute> Meant for general purpose
programming on the GPU (GPGPU)
> P09-16 “DirectX11 DirectCompute”Chas BoydThursday, 11:30 AM, 408A
> DirectCompute Hands-on Lab> Running every day!
When To Use Direct3D> Direct3D is a low-level, programmable
rasterizer> Bare-bones, meant for getting the
best performance possible> Use for
> High-performance, high-quality 3D> Utmost control over the GPU
Agenda> Windows 7 Direct3D Review
> Direct3D 10 Review> Expanding Reach: D3D10Level9 and
WARP> HLSL & Shaders
> Direct3D 11> Multi-Threading> Tessellation
Input Assembler• Fixed-function• Takes in vertices• Does tasks like indexing,
instancing
Review: The D3D10 PipelineInput
Assembler
VertexShader
Rasterizer/Interpolator
PixelShader
GeometryShader
OutputMerger
Vertex Buffer
Index Buffer
Texture
Texture
Depth/Stencil
Texture
Render Target
Stream Output
Vertex Shader• Programmable• Performs an operation on
each vertex produced by the input assemblerOutput Merger• Fixed-function• Combines the output of pixels into a rendered image• Blending• Depth Testing• Stenciling
Geometry Shader• Programmable• Performs an operation on
primitive (triangle, line segment, or point)
Rasterizer• Fixed-function• Converts primitives to pixelsPixel Shader• Programmable• Computes the color value of each pixel
Expanding Reach: Direct3D10 Level 9
Review: D3D10Level9 & Feature Levels> Direct3D 9 hardware had hundreds of
individual capabilities or “CAPS”> Ultra fine-grained feature control
> D3D10 Level 9 offers just 3 levels> FeatureLevel9_1> FeatureLevel9_2> FeatureLevel9_3
Feature Level 9_1: Shader model 2.0Intel 965, Geforce FXOlder S3 PartsSIS Mirage
Feature Level 9_2: Shader model 2.0Some additional features (next slide)ATI 9800ATI X200
Feature Level 9_3:Shader model 3.0 NV 6800 +ATI 1x00 series +
Super set
Super set
D3D10Level9 Feature Level Codes
static const D3D10_FEATURE_LEVEL1 levelAttempts[] ={ D3D10_FEATURE_LEVEL_10_1,
D3D10_FEATURE_LEVEL_10_0, D3D10_FEATURE_LEVEL_9_3, D3D10_FEATURE_LEVEL_9_2,
D3D10_FEATURE_LEVEL_9_1,};
D3D10Level9 Device Creation
for (UINT level = 0; level < ARRAY_SIZE(levelAttempts); level++)
{ hr = D3D10CreateDevice1( pAdapter, DriverType, Software, Flags, levelAttempts[level], D3D10_1_SDK_VERSION, &spDevice );
if (SUCCEEDED(hr))break;
}
Direct3D 10 Level 9 and DirectX> Also accessible through Direct3D 11> Direct2D automatically uses Direct3D
10 Level 9
WARP 10
Our Criteria for WARP Development> 100% conformant with Direct3D10
Spec> Performance
> Fast enough for most mainstream scenarios
> Scales very well with the number of cores on your system
> Tested against many sophisticated applications> Games> CAD software
How WARP fits in
if !(SUCCEEDED(hr)){
hr = D3D10CreateDevice1(NULL,D3D10_DRIVER_TYPE_WARP,NULL,0,D3D10_FEATURE_LEVEL_10_1,D3D10_1_SDK_VERSION,&pDevice
);}
ShadersThe heart and soul of modern graphics
programming
What is a Shader?> A script that tells a programmable
stage of the graphics hardware what calculations to do to achieve a material, transformation, or effect
> Written in HLSL> C++-like language that is designed for
this task> Has a huge number of convenience
features that exploit core features of the graphics card
> No pointers > Builtin variables (float4, matrix, etc)> Intrinsic functions (mul, normalize, etc)
Example Shader
float4 PSFloorEffect( PSSceneIn input ) : SV_TARGET{
float2 tex = float2( input.Tex.x, input.Tex.y + g_fElapsedTime*.097 );
tex.x += sin( input.Tex.y*40 )*0.001;tex.y += sin( input.Tex.y*60 )*0.001;
float4 color = BoxFilter( g_samLinearClampU, tex, 7 );
return float4( color.xyz * 0.999f, 1 );}
Agenda> Windows 7 Direct3D Review
> Direct3D 10 Review> Expanding Reach: D3D10Level9 and
WARP> HLSL & Shaders
> Direct3D 11> Multi-Threading> Tessellation
Multi-Threading
D3D11 Design Goals> Asynchronous resource loading
> Upload resources, create shaders, create state objects in parallel
> Concurrent with rendering> Multithreaded draw & state
submission> Spread out render work across many
threads
Devices and Contexts> D3D device functionality now split into
three separate interfaces> Device, Immediate Context, Deferred
Context> Device has free threaded resource
creation> Immediate Context is your single primary
device for state, draws, and queries> Deferred Contexts are your per-thread
devices for state & draws
D3D11 Interfaces
ImmediateContext
Device
DrawPrim
DrawPrim
DrawPrim
DrawPrim
DrawPrim
CreateTexture
CreateVB
CreateShader
CreateShader
CreateTexture
CreateVB
CreateShader
CreateIB
Render Thread Load Thread 2Load Thread 1
Deferred Contexts> Can create many deferred contexts
> Each one is single threaded (thread unsafe)> Deferred context generates a Command
List> Command list is consumed by Immediate or
Deferred contexts> No read-backs or downloads from the
GPU> Queries> Resource locking
> Lock with DISCARD is supported on deferred contexts
D3D11 InterfacesImmediate
ContextDeferredContext
DeferredContext
Command List Command List
DrawPrim
DrawPrim
DrawPrim
DrawPrim
DrawPrim
DrawPrim
DrawPrim
DrawPrim
DrawPrim
Execute
Execute
State Inheritance> Command lists are optimized for single
use> Less optimized for precompiled usage
scenarios> No state is inherited from immediate
context> Deferred contexts start out with default
state> Dynamic state can be injected via
resources> Constant buffers, textures, queries, VBs,
etc.
State Inheritance> State recorded in a command list does
not affect immediate context at all> Can optionally persist immediate context
state> Fastest performance: reset immediate
context state after command list execution, when executing command lists back-to-back
D3D11 on D3D10> D3D11 API is available on D3D10
hardware & drivers> D3D10 drivers can be updated to
better support some D3D11 features> Works on Windows Vista too!
Tessellation
Why Tessellate?
Pre-Tesselated Mesh: ~5500 kB
Asset Size: Comparison
Sub-D Mesh: ~130 kB
More Reasons> Continuous level of detail> Skin at the control mesh level> Faster dynamic computations at the
control mesh level> Cloth> Collisions
Direct3D 11 Tessellation Design
InputAssembler
VertexShader
Vertex Buffer
Index Buffer
Texture
GeometryShader Texture
Stream OutputRasterizer/Interpolator
PixelShader
OutputMerger
Depth/Stencil
Texture
Render Target
HullShader Texture
DomainShader Texture
Tessellator
New Primitives
Hull Shader> Operates per input primitive
> E.g. patch> Computes control point transforms
> E.g. Basis Change> Computes tessellation factors per edge
of generated patches
Tessellator> Inputs
> Takes in “Tessellation Factors” provided by the Hull shader
> Tess factors per-side in the range of [2.0..64.0]
> Outputs> UV or UVW domain points> Connectivity of those points (tris, lines)> No adjacency information
> Many possible partitioning schemes
Domain Shader> Operates on each point generated by
the tessellator> Gets ALL control points as input
> Control points and patch constant data are passed directly to the domain shader
> Evaluate primitive surface to compute position of points> Convert from U,V space into positions,
tangents
InputAssembler
VertexShader
Vertex Buffer
Index Buffer
Texture
GeometryShader Texture
Stream Output
HullShader Texture
DomainShader Texture
Tessellator
Basic Tessellation
Hull Shaders & Domain Shaders
demo
This is a lot…> There’s a lot of complexity here,
but it’s worth it> D3D11 can target almost any
surface algorithm you want> Bezier> NURBs> Dynamic and static tessellation> Displacement> Subdivision
and more…
No Compromise: Details & Performance!> Low poly count for high
performance> High poly count for
refined detail> Iteratively refine to
produce a smooth limit surface
> Modern implementations allow for creases and other hard edges
> Detail can be layered on with displacement & normal maps
FBX Format: Industry Momentum
> Data transport for geometry, textures & lighting and animation
> Integration with most common digital content creation (DCC) applications
> Support for Direct3D 11 Tessellation for “round trip” iterations> Create in your application of choice> Export via FBX> Review in DX rendering engine
SubD11 (a.k.a. “Sebastian”)
demo
The Platform Update for Windows Vista> Down-level availability of key Windows
7 features on Windows Vista> Available on Windows Update> More information:
> http://support.microsoft.com/kb/971644
44
Additional Resources> DirectX on MSDN:
> http://msdn.microsoft.com/directx> Windows 7 SDK:
> http://msdn.microsoft.com/windows> August 2009 DirectX SDK:
> http://msdn.microsoft.com/directx/sdk
YOUR FEEDBACK IS IMPORTANT TO US! Please fill out session evaluation
forms online atMicrosoftPDC.com
Learn More On Channel 9> Expand your PDC experience through
Channel 9
> Explore videos, hands-on labs, sample code and demos through the new Channel 9 training courses
channel9.msdn.com/learnBuilt by Developers for Developers….
© 2009 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.
Hull Shader Syntax
[patchsize(12)][patchconstantfunc(MyPatchConstantFunc)]MyOutPoint main(uint Id : SV_ControlPointID, InputPatch<MyInPoint, 12> InPts){ MyOutPoint result; …
result = TransformControlPoint( InPts[Id] );
return result;}
Domain Shader Syntax
void main( out MyDSOutput result, float2 myInputUV : SV_DomainPoint, MyDSInput DSInputs, OutputPatch<MyOutPoint, 12> ControlPts, MyTessFactors tessFactors ){ …
result.Position = EvaluateSurfaceUVtoXYZ( ControlPoints, myInputUV );}